Eclipse RCP Schulung
15. - 19. März 2010
iPhone Schulung
26. - 29. April 2010
git Schulung
27. - 28. Mai 2010
19.07.2009

Showing menu contributions depending on active perspective

Using the variable activeWorkbenchWindow.activePerspective in org.eclipse.ui.menus you can contribute commands to the menu- or toolbar depending on the active perspective. Unfortunately, this works only for single commands and not for a complete menu or toolbar element. For example:

<extension point="org.eclipse.ui.menus">
   <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar">
      <toolbar id="de.rcpbuch.addressbook.filetoolbar">
         <command commandId="de.rcpbuch.addressbook.somecommandid" style="push">
            <visibleWhen checkEnabled="false">
               <with variable="activeWorkbenchWindow.activePerspective">
                  <equals value="de.rcpbuch.addressbook.someperspectiveid"/>
               </with>
            </visibleWhen>
         </command>
      </toolbar>
   </menuContribution>
</extension>
Kristian Rink, 11. Dezember, 15:07 Uhr

Thanks, just what I've been searching for. :) Now if I only could figure out why this ain't working on a per-toolbar rather than on a per-command level...

I'm looking forward to your comments:

Schulungen

Eclipse RCP

Ralf Ebert | Blog | Eclipse RCP | Showing menu contributions depending on active perspective