views:

53

answers:

1

Hi.

I am developing an Eclipse plug-in and I'd like to associate a new menu (at the top of the screen along with File, Edit etc) with a perspective I'm creating.

I did the menu ok but it is being displayed even in other perspectives. How can I associate it only with my perspective? This is the code I am using in plugin.xml:

<plugin>
<extension point="org.eclipse.ui.perspectives">
   <perspective
         class="org.eclipse.ui.articles.perspective.API_Development"
         id="org.eclipse.ui.articles.perspective.API_Development"
         name="API Development">
   </perspective>
</extension>

<extension
         point="org.eclipse.ui.actionSets">
      <actionSet
            label="Sample Action Set"
            visible="true"
            id="API_Development_Menu.actionSet">
         <menu
               label="API Development"
               id="sampleMenu">
            <separator
                  name="sampleGroup">
            </separator>
         </menu>
      </actionSet>
   </extension>
</plugin>

Thanks and regards, Kurt

+1  A: 

The wiki article "Menu Contribution" mentions since Eclipse3.3M6 the element

 <visibleWhen/>

An org.eclipse.core.expressions.definitions extension point was added. Used to define a core expression, the definition can then be referenced from other locations.

<extension point="org.eclipse.core.expressions.definitions">
  <definition id="com.example.context">
    <with variable="activeContexts">
       <iterate operator="or">
         <equals value="org.eclipse.ui.contexts.actionSet"/>
       </iterate>
    <with>
  </definition>
</extension>

This can be called in a core expression like activeWhen, enabledWhen, visibleWhen, etc using the reference element:

<reference definitionId="com.example.context"/>

Maybe then a definition like:

could be used for your menu?

VonC