Google

April 27, 2009

Using org.eclipse.ui.menu 3.3 API for popup menu

I am not sure new qualifier still apply for an API available since Eclipse 3.3, but here are some questions I have asked myself and for which I would like to share some answers.

  • Where can I find a good introduction to the new API ?

There is a great IBM article ideal to discover the API.

  • Where can I find id for group ?

Have a look at the following interfaces :

org.eclipse.ui.IWorkbenchActionConstants

org.eclipse.ui.navigator.ICommonMenuConstant

  • Where can I find available variables ?

On the Eclipse wiki.

  • Where can I find an eclipse plug-in example ?

In one ATL plug-in for instance. Here is an example where the popup menu item is displayed only when the active perspective is the right one, and the selected files extension is ecore.

  • How can I get the selection for popup menu ?

Be careful the selection variable is not the same for classic menu and popup menu.
You have to use activeSelectionMenu.

  • How can I do to not display the menu if the selection is empty ?

You have to use count element.

<visiblewhen checkenabled="false">
<with variable="activeMenuSelection">
<iterate operator="and">
<count value="+">
</count>

</iterate>
</with>
<visiblewhen>


  • How could I call a test in Java ?

First you have to create a property tester :


<extension point="org.eclipse.core.expressions.propertyTesters">
<propertytester id="com.mycompany.project.tester.MyTester"
type="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart"
namespace="com.mycompany.project.namespace" properties="isLikeIWant"
class="com.mycompany.project.namespace.MyTesterClass">
</propertytester>
</extension>


Then you can use it with test element :



<visiblewhen checkenabled="false">
<with variable="activeMenuSelection">
<iterate operator="and">
<instanceof value="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart"></instanceof>
<test property="com.mycompany.project.namespace.isLikeIWant"></test>
</iterate>
</with>
</visiblewhen>


No comments:

Post a Comment