I created a menu contribution for an Eclipse plugin.
I would like the menu only to be visible when the plugin perspective is active.
A perspective determines the visible actions, views, and view layout within the window. There are many types of perspective, and each one defines the layout in a different way.
The File Menu allows you to carry out various functions on active files and folders, as well as organizing current files and creating new items. The options available from the File menu are: Name. Shortcut. Description.
The user can select a perspective by invoking the "Open Perspective" submenu of the "Window" menu. This is why copying a plugin from one installation of eclipse into the dropin folder of the other eclipse will make the perspective available to your second Eclipse installation.
Here is what I found, in an open source project, and it works for me:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="menu1"
label="Menu 1">
<visibleWhen checkEnabled="false">
<with variable="activeWorkbenchWindow.activePerspective">
<equals value="myperspective"/>
</with>
</visibleWhen>
<dynamic class="MenuPopulationClass"
id="MenuPopulation"/>
</menu>
</menuContribution>
</extension>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With