Eclipse RCP - conditionally displaying menu

201 Views Asked by At

I am working on an Eclipse RCP product (based on Eclipse 3.6) which has multiple applications/plugins. Following is the use case in which I have got stuck: There are 3 plugins A, B and C. I need to display a menu contribution in "Edit" menu in plugins A and B (not in C), only when plugin C is installed. If plugin C is not installed the menu contribution should not be displayed - not even in a disabled state. On doing some search I found that there is a property tester which can determine if a plugin is installed - it is to be used as:

<with variable="platform">
    <test property="org.eclipse.core.runtime.isBundleInstalled" args="com.mybundle"/>
</with>

However when i tried it didn't work for me. I am not sure if use of this property is relevant in the context that I am trying to use it in. Can somebody help? If the codeless option is not viable then I will have to show/hide the menu contribution programmatically but I do not know where this should ideally be done. Should I write a PerspectiveListener for plugins A and B and add the menu contribution in case of PerspectiveActivated after verifying that C is installed?

Please help.

Thanks and regards, Pradyumna

1

There are 1 best solutions below

0
On

I had made a mistake because of which isBundleInstalled was not working. The variable platform was not available and hence I did not get the expected output. Replacing it with org.eclipse.core.runtime.Platform did the trick.