I am working on an E4 RCP application and have a context menu in which menu items are visible or independent of choice. The way I found this are the key expressions defined in the plugin.xml file as follows:
<extension
point="org.eclipse.core.expressions.definitions">
<definition
id="com.foo.bar.test.core.expression">
<with variable="org.eclipse.ui.selection">
<iterate ifEmpty="false">
<or>
<instanceof value="com.foo.bar.Class1">
</instanceof>
<instanceof value="com.foo.bar.Class2">
</instanceof>
</or>
</iterate>
</with>
</definition>
This works, and the menu item is displayed if the selected item is an instance of Class1 or Class2.
All this seems like a very unpleasant way to do something! When many of them are added, this will be the maintenance and debugging of nightmares.
Can anyone demonstrate a less XML way to do this? Pure Java programming methods would be great!
source
share