eclipse egit: Menu item and keyboard shortcut for Team -> Show in History - eclipse

Is there a way to get the git log, ie: "Team -> Show in History" appear as a menu item on the main menu bar and to have a shortcut for it?
I'd like this menu item/shortcut to work when selecting a project or project resource in Package Explorer.

You could use Shift+Alt+W (that brings up the Show In submenu) and then press H to activate the History entry.
Otherwise, you can also consider linking the History view to the selection by activating the toolbar icon with the two arrows in the History view.

The command "Team -> Show History" cannot be processed unless it's associated with a module or a folder.
That's why it's a right click menu option.

You should be able to bind the Show In (History) command to a key in the Preferences>General>Keys page. You have to select something before you execute it (like a git repo or a project in the explorer).

Related

Eclipse Mars - imported projects don't show up in Project/Enterprise Explorer

I currently have 48 projects in my workspace. All are cloned git repos that had existing projects that were then imported into Eclipse.
The last three repos that I've imported into Eclipse have imported and migrated successfully but don't show up in either the Project or Enterprise Explorer views. I can see that they exist in the .metadata/.plugins/org.eclipse.core.resources/.projects folder.
I can search the projects and create a working set, and I can add the EAR files to the server, and I can open the files, but I can't do anything that I would normally do from the Project Explorer, including viewing their properties or deleting them.
I had thought that Eclipse might have an upper limit on how many projects could be viewed, but my co-worker says she has 107 projects currently in her workspace.
Maybe the projects are hidden by an active Working Set or by Focus on Active Task.
From the first link:
How to change Eclipse's "Project Explorer" "Filters and Customization" view settings to force projects and files and folders to show up and not be hidden, such as nested projects
Tested in Eclipse Version 2021-06 (4.20.0), Build ID: 20210612-2011 on Linux Ubuntu 18.04.
Quick Summary
Go to the "Project Explorer" tab, click the 3 vertical dots in the top-right corner of that pane, then go to "Filters and Customization...", as shown here:
Uncheck the box for "Nested Projects: hide top-level project if shown as nested" and "Nested Projects: hide folders when project is shown as nested", and click "OK":
Details
I'm having this exact problem in Eclipse Version 2021-06 (4.20.0), Build ID: 20210612-2011 on Linux Ubuntu 18.04.
It turns out it's because of the Project Explorer "Filters and Customization..." settings, as I learned from #howlger's answer.
After adding a code repository directory as a project, I can see it showing up in the deprecated "Navigator" tab, shown as "Navigator (Deprecated)" in Eclipse here (I have blurred images for privacy):
However, it does not show up in the "Project Explorer" tab, which is shown below!
The problem is that the "Project Explorer" tab's "Filters and Customization..." settings are filtering out this project and not showing it. In my particular case, that is because the project I am adding is a subrepo within another git repo, which means it is a project nested within another Eclipse project, and my view settings are mistakenly set to exclude all "nested projects". Your case or reason may be different, but in either case, if your project is not showing up in your "Project Explorer" tab, then it is likely because your "Filters and Customization" settings are set to exclude it from view.
To fix this for my case, go to the "Project Explorer" tab, click the 3 vertical dots in the top-right corner of that pane, then go to "Filters and Customization...", as shown here:
Next, click the "Pre-set filters" tab, then scroll down and uncheck the box for "Nested Projects: hide top-level project if shown as nested". I recommend you also uncheck the box for "Nested Projects: hide folders when project is shown as nested", but I'm not 100% sure what that one does, as unchecking the other box alone caused my project to show up. Here is a screenshot, with the appropriate areas highlighted in yellow:
Any of the items in this list will be hidden from view in the "Project Explorer" tab if their box is checked. So, go through the list in detail and uncheck anything else you might see fit, if applicable. I took a look and left all the rest of my view settings there as-is.
Click the "OK" button when done, and voila!--my nested and previously-added project now shows up in the "Project Explorer" view!
NB: due to some sort of bug in Eclipse, you may have to repeat the above process every time you close and reopen Eclipse. :( But, you can probably do it faster now from the "Recent Filters" section of the 3-dots menu.
Update: it looks like changing the "Projects Presentation" setting from "Hierarchical" to "Flat" blocks this bug and prevents you from having to fix the "Filters and Customization" setting every time you re-open Eclipse.
Here is how: click the 3 vertical dots menu in the "Project Explorer" window --> "Projects Presentation" --> choose "Flat", as shown below:
Other references
Here is the relevant official Eclipse documentation on this: https://help.eclipse.org/: Showing or hiding files in the Project Explorer view:
Showing or hiding files in the Project Explorer view
You can choose to hide system files or generated class files in one of the navigation views. (System files are those that have only a file extension but no file name, for example .classpath.)
On the toolbar for the Project Explorer, click the Menu button Menu button [3 vertical dots] to open the drop-down menu of display options.
Select Filters and Customization..,.
In the dialog box that opens, select the Filters tab and then select the checkboxes for the types of files that you want to hide or define your own name-based filters in the User filters tab.
In addition, you can restrict the displayed files to a working set.
On the toolbar for the Project Explorer, click the Menu button [3 vertical dots] to open the drop-down menu of display options.
Choose Select Working Set...
Select an existing working set from the list or create a new one by selecting New...
My Q&A on how to blur images in GIMP: Graphic Design: How do I do a privacy blur on a section, selection, or region of an image in GIMP?
My personal Eclipse setup document: Eclipse setup instructions on a new Linux (or other OS) computer: Troubleshooting

Eclipse Mars disable 'revert file' button

When I right click and go to save my class I have accidentally clicked this a couple of times, making it rather annoying. Is there a way I can move/disable this option?
If you are talking about the Revert menu item on the File menu, you can remove it by customizing the current perspective. To do this:
Open Window=>Perspectives=>Customize Perspective
Select Menu Visibility tab
Click the '>' in front of File
Uncheck the Revert item
Click OK

Eclipse Shortcut for Team - Synchronize with Repository

What are the shortcuts for the context menu actions "Team -> Synchronize with Repository" and "Team -> Update" on the whole project?
I have already found shortcuts, but these are executed only on the file i have currently opened. But I want to execute it on the whole project without having to scroll the project explorer to the top and right-clicking on the project.
If there are no such shortcuts, how can I create them?
As john.k.doe indicates, that's the right solution, but you also need to do something else in order to make the shortcut actually work, which is go to Window > Customize Perspective > Command Groups Availability and there just check the SVN box ;)
you can almost always get the key shortcuts you want by
go to preferences type "keys" or go to General -> Keys
in the field presented when you click on "Keys"
in the left pane, type the command you are interested in setting up a shortcut for:
the image below is from my mac, but it works the same way on windows/linux, you just might choose something besides Cmd-Y as your shortcut modifier. the U under User indicates that i was the one to add that modification.
I have written a small Eclipse plug-in which selects the active project in the Package Explorer so you can execute other actions (like 'Sync with repo' and 'Update') on it. I think this approach is more flexible compared to writing a plug-in that selects the project and executes a predefined action.
You can get the plug-in at http://code.google.com/a/eclipselabs.org/p/eclipse-tweaks/downloads/list, it is named "com.xakcop.select". Download it and put it in the dropins/ folder of your Eclipse installation. Then when you restart Eclipse, you will find a new command Select project in Windows->Preferences->Keys. The default key binding is Ctrl+Shift+Backspace but you can change it to whatever you want.
When you are in the Java editor just press Ctrl+Shift+Backspace, this will select the project that the current file belongs to in Package Explorer. Then press the shortcut for "Synchronize with repository" and you are done.
The source code of the plug-in is also available as part of my eclipse-tweaks project: http://code.google.com/a/eclipselabs.org/p/eclipse-tweaks/source/browse/com.xakcop.select
I think the answer to this question adresses the issue.
The quickest way I've found to update/synchronize, after having set the shortcut keys, is to click on the minimize button in the Project/Package Explorer and then press the keys. After the update, simply clicking on the last used file in the editor returns to the previous workspace state (provided the "Link with Editor" button in Project Explorer is selected).
I should clarify: I use a working set for each project. The working sets are displayed as default Top Level Elements in the Package Explorer so, by clicking on the minimize button the desired Project' working set, they collapse and are easy to select. Then, I apply the shortcut on the selected working set.
From my point of view, the problem is the focus of the commands you execute.
The Team commands Snychronize and Update are executed on the current object (In my case). As you noticed, when you execute the command on the project, the project is synchonized - when you do it on a file, only the file is synchronized.
What I did as workaround is the following:
I created Key-Bindings for the commands Show in (Navigator) (Alt-N), Go to (Alt-G), and Show View (Naviator) (CTRL+SHIFT+Q, N).
With Alt-N I show the current File in the Navigator. I can then use the keys to navigate to the root that I want to synchronize (it's not always the whole project for me). If the root is to far away I use Alt-G and type the Project or Folder where I want to go to and execute afterwards the Synchronize commands.
(Go to works only in the current view)
If you have selected the Project once you just have to switch to the navigator (Show View command) and execute your synchronize commands.
You could also use rgerganov's plugin then you would not have to execute as many commands.
The procedure works also with other views (package explorer, project explorer)
What about this approach? It should also work for other SCM's or commands you want to execute on any object in the explorer views.

package explorer is broken

this is what I`ve done
I clicked on a project with right button and I`ve selected open in new window. I had 2 windows. First I've closed the primary one, then the new one. After that every time when I run eclipse the project that I've selected to open in new window was the default one. My package explorer every time was in it and I had to click back. I just deleted this project and now I can't navigate in package explorer. It is still set to this project but I can't go back. What can I do ? How can I select the basic package explorer view ?
There should be an Up one level or a Back button enabled on the Package explorer view toolbar - I am not talking about the main toolbars similar buttons but one just under the view header. These buttons shall allow you to return to the original level with multiple projects visible.
This is the Up One Level button that Zoltan is referring to:
Symptom:
The package explorer dialog looks as if you have drilled down into an end node but the dialog is blank and there is no "Up One Level"/"Back Button" to click.
Solution:
Ensure eclipse is not running
Delete the following file:
workspace/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml
Start Eclipse
The workbench.xml file contains settings for the state of the package explorer among other things. I suspect that the package explorer settings get corrupted somehow.
Top right there is ViewMenu option menu (triangle downside oriented) - try some options there, or click project explorer tab(top left) and try refresh etc. It is hard to see what exactly happened to you.
In Eclipse, Window → Reset Perspective...

How do I show an open file in eclipse Package Explorer?

When a file (.java for example) is open in Eclipse, how do I get the Package Explorer to show the file that I am working on?
There is a button in the Package Explorer view that looks like two yellow arrows pointed at left and right. The tooltip is "Link with Editor". Click that.
I've found that constantly syncing package explorer with editor causes package explorer view eventually to grow too long, especially with large projects. I've instead mapped a keyboard shortcut to sync package explorer with the editor. If you are using mylyn this is of course a smaller problem.
Key mappings are available at Window ⟶ Preferences ⟶ General ⟶ Keys ⟶ Show In (Show In Target Id: Package Explorer). Mine is Ctrl+Alt+⟵, be welcome to copy.
In Luna Command name has changed a little. Instead of Show In (Show In Target Id: Package Explorer) command is now Show In (Package Explorer).
From this site:
How to use Show In functionality from the popup menu
Press Alt+Shift+W while you’re in an editor. This pops up a menu with a number of choices. The choices will vary depending on what plugins you have installed. Select the option you want and press Enter.
The fastest way to select an option is to use the first letter of the option, eg. to go to the Package Explorer, press P (you may have to do this 2 or 3 times depending on how many other options start with P). The press Enter. You could also use the arrow keys.
Invoke "Show In" faster with a keyboard shortcut
If you frequently use one of the options (eg. Package Explorer), you can map a single keyboard shortcut to invoke it.
Go to Windows > Preferences > General > Keys.
Search for Show In. Eclipse will list a number of Show In options. In
our case we want Show In (Show In Target Id: Package Explorer).
Select the command you want, enter a key in Binding and you’re done.
Always link active source file with package explorer
If you like this feature, you can open the package editor and click on the double yellow arrows to always show the currently selected source file in the package explorer.
There is a double arrow icon at the top of the Package Explorer that toggles this behaviour. click on It
In your Eclipse .java file editor, right-click anywhere, then "Show In-> Package Explorer".
As shown:
As you can see, you can also open file in Navigator, Outline and so on with this.
Above project explorer window you will see the below image in the red circle , just clicked on this one mean when clicked any file in the project will showing you in project explorer.
If you want to show only one file you can
1 - Click right on the file .
2 - Select show-in .
3 - Select show in project explorer .
4 - Done.
The below image explain more about it .