Eclipse plugin: how to show menu tab only if active is active?

I created a menu tab for the Eclipse plugin.

I would like the menu to be only visible when the plugin perspective is active.

+5
source share
3 answers

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>
+4
source

I suggest using the Command Framework.

this tutorial will help you

To limit the visibility of your teams, you should check the steam. 5

+1
source

, .

, ActionSet .

visibleWhen , plugin.xml. "" → "". visibleWhen "" →

- "activeContexts"

"" → . iterate , true.

iterate New → equals, value.

value = ActionSet

, ActionSet.

0

All Articles