Eclipse: Selection Lost when switching Perspective makes Toolbar entry disappear - eclipse

I have a condition using which I display an entry in the toolbar. I use
menuContribution + command + visibleWhen to display this entry. As soon as I switch to another perspective my entry in the toolbar vanishes even though I have that project/project node selected in my project explorer.
Is it because I use
<visibleWhen> <with variable="selection"> in my plugin.xml ?
How can I keep my toolbar entry visible even if perspectives are switched ,at least it should display in certain fixed perspectives if not all of them....
I want to avoid using actionSets to display my entry in the toolbar as they are not friendly with the propertyTester I am using.
Any help in this regard will be really appreciated,
Thanks !

I am guessing when you shift perspectives, the selection is lost and that is the reason your contributions are not visible. Even though in the project explorer view (or something), the selection is present, it would sometimes be in grey shade indicating no selection. You need to handle selection via code, not extension points.

Related

eclipse 'hide view' while customizing perspective not coming into effect

It's really frustating, that a simple customizing of perspective is not working. I had given it a try multiple times, but didn't get a solution yet.
Problem: Hide all the view in the java perspective and only show Console and Tasks.
Tried:
I'm aware of Windows Menu -> Perspective -> Customize Perspective ->> 4th Tab(Shortcuts) --> 2nd Dropdown (Views)
Here I select and deselect the views I need, but each time I open eclipse or switch perspectives I get back all the tons of views back again (Task List, problems, error log, javadoc, declarations, Outline, and what not...). I want to remove all the clutter from the screen. I am aware of the 'Save Perspective as' option in the same menu trail above, but that also does not have any effect.
Anyone gone through the same pain? How to make this work?
Note: I am on ubuntu 15.10 . Eclipse version : Mars
That customize option only changes the 'Show View' menu not the actual open views.
If you actually close the views you don't want that should be remembered.

Eclipse Outline view is hiding code

I'm using the Kepler CDT release (4.3.1) of Eclipse. When I click on anything in the Outline view, the corresponding editor view is reduced to showing just that item. If I click on a variable, I get a single line with just that variable. The Edit->Expand Selection options are all dimmed out. Hitting Shift-Alt-Up Arrow just moves me up to the previous item in the outline view. If I change editor tabs and come back then the Expand Selection options enable and I can manually hit Shift-Alt-Up Arrow a number of times to make the entire file visible again but clicking on anything in the outline view again will just reduce the view. Is there some new setting in Kepler that will make outline stop doing this?
Turns out the feature for Show Source of Selected Element Only was turned on. In Kepler the toolbar button for this is not visible. Even searching under quick access doesn't turn it up so it's somewhat of a puzzle how it could have been turned on. I actually thought maybe it had been removed from Kepler.
In the Customize Perspective dialog under the Tool Bar Visibility tab. In the Tool Bar Structure section I opened the area for Editor Presentation. I noticed there was actually a check next to the box for Show Source of Selected Element Only. However, it wasn't visible in the toolbar (a bug I've seen before in Eclipse) so I unchecked it and checked it. Then I exited the dialog. Now the button showed up on the toolbar. I then toggled the feature on and then off. Now clicking in the outline view works correctly.just moves to the correct spot.

how to make element in main menu visible/invisible (depends of editor type)

In my RCP application I have two types of editors (one is for *.xsd files and second for other text files). I have added new element to main menu and I want to show it only when xsd editor is active, when other editor is active it should be invisible (In Eclipse 'Refactor' option is visible when open is java file and invisible when open is xml file). How to make visible/invisible element in main menu depends of editor type?
Have a look at the org.eclipse.ui.menus extension point, specifically the visibleWhen element. You can add commands to the main menu sub-menus and make them visible when the activeEditorId == your editor id.
<visibleWhen>
<with variable="activeEditorId">
<equals value="org.eclipse.example.my.editor"/>
</with>
</visibleWhen>
See also Core Expressions.
As far as I know you can't alter the visibility of a menu item. What you have to do is not add the item in the first place, depending on that editor is active. If you can post your code as to how you added your menu item (since there are multiple ways to do this), I could help you further about exactly how to check.
If there is no active handler for the menu item's command, the item won't appear in your menu.
Have a look at this question for an example of using activeWhen to control the availability of a command in a menu based on the current selection.

Hide Eclipse Menu Bar (auto-hide)

I'm trying to hide Eclipse menu bar to save some screen real estate. I found I can do this using perspectives but that would permanently take out the menu from that perspective. The behavior that I want to get is something along of auto-hide, so that the menu remains hidden until I hit ALT+F for example or any other ALT key combo.
Is there's a setting or a plugin that can do this?
Thanks!
This is just a work around. Create two perspectives.
First one named - With Menu.
Second one named - Without Menu.
In the "Without Menu" perspective remove all menu items and Save.
To create the effect of hiding and showing, switch between perspectives by using
Ctrl+F8.
Theres a fast view option- just right click the tab and select Fast View. It'll bring the entire window down to the eclipse taskbar. You can recover the window by just clicking on it's icon.
Source: https://bugs.eclipse.org/bugs/show_bug.cgi?id=56119
Have a look here Is there a Macro Recorder for Eclipse? You could set up the macro so respond to ALT+F possibly.

How to Display Current Function in Eclipse

I miss a certain functionality in Eclipse. I would like to know the name of the current function the cursor is currently inside. This is useful when browsing unknown code using the search function, for example.
Any idea how to show it? Maybe a plugin?
I'm using the "Toggle Breadcrumb" option from toolbar:
It shows a nice breadcrumb, ending with current function name.
It's quite handy for me, as Outline becomes cumbersome to use if you have zilions of functions.
It produces the following structure above your Java Editor (truncated at the picture below):
The "Outline" view shows the current function.
It may be necessary to enable the 'Link to Editor' option in the Outline View dropdown menu. This might be off by default for CDT.
I was looking for something similar (Xcode-like bar at the top showing the current function, where you can also go to another function by clicking on it to open a popup list of functions). Here is what I settled on with Eclipse 3.5.1 CDT:
I moved the Outline view to the top, resized it to make it a 1-line horizontal strip (don't make it too narrow), and selected "Link With Editor" in its menu, so that it always shows the current function. However, this doesn't open a popup list like Xcode. For that functionality, I assigned a shortcut to the "Show Outline" command which does open a popup list of all functions.
The Eclipse function 'show outline' will pop up a list of outline objects, and it will highlight the object your cursor is inside in grey. It's typically bound to 'ctrl-o' (the letter 'o', not zero), but you can re-bind it as you see fit. I'm running Eclipse with the CDT plugin and it works pretty well for me.
To enable the breadcrumb invoke Toggle Java Editor Breadcrumb in the toolbar or press Alt+Shift+B in the Java editor.
You can also display the Quick Outline (ctrl+o). This way you see the context quickly without having to have a permanent Outline Window linked to the Editor.
Use the "Link With Editor" option on the outline menu
Press Ctrl+o (cursor is currently inside a function at a particular line).
It highlights the current method, or name of the class if the cursor is outside the method body.
You can click on highlighted method.
It has got inline search feature ...start typing name of the method to navigate to the specified method or method with matching search pattern.
If you press again Ctrl+o to shows the inherited members/methods.
Using outline with "link with editor" option worked also for me, thanks!
Just an addition, you can move outline pane in to the same window group as search, progress etc. saves the space in your perspective instead of keeping it at another group.