Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Plugin: How to show a menu contribution only when a persective is active?

I created a menu contribution for an Eclipse plugin.

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

like image 326
Matthieu Napoli Avatar asked Nov 24 '10 15:11

Matthieu Napoli


People also ask

Which determines the visible actions views and view layout within the Eclipse window?

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.

What is Eclipse menu?

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.

How to install perspective in Eclipse?

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.


1 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>
like image 130
Matthieu Napoli Avatar answered Oct 05 '22 06:10

Matthieu Napoli