How to remove popup menus in Eclipse RCP

I work in an RCP application and I have an idea which data model is an instance of IResources. When the popup menu is visible, I find the commands made by other plugins that I would like to remove.

Code example:

 1 MenuManager menuManager = new MenuManager ();
 2 mm.setRemoveAllWhenShown (true);
 3 Menu menu = menuManager.createContextMenu (this.treeViewer.getControl ());  
 4 this.treeViewer.getControl (). SetMenu (menu); 

 5 getSite (). RegisterContextMenu (menuManager, this.treeViewer);

If I comment on line 5, the context menu does not appear.

Can I use the contribution menu from the plugin.xml file and delete the contributions of other plugins?

Note. My popup menu is declarative and it is in the plugin.xml file.

Thanks in advance

+6
eclipse eclipse-plugin eclipse-rcp
source share
3 answers

A possible way is to subtract the so-called "Equinox transformer hooks", see http://wiki.eclipse.org/Equinox_Transforms

You can check the packages with some examples (see the wiki page for more information), I did a great job with the XSLT transformer to manipulate some plugin.xml files before they bring their extensions to the platform (only task is to find out which package contributes to annoying entries in the context menu, but you can use PluginSpy to define "evildoer": -P.

Hth tom

+3
source share

You can also use actions for anything contributed through the plugin.xml file. For objectContributions you should use the form "contributing.plugin.id/action.id". Here is an example that applies to the wizard, but the same template can be applied to a specific action:

<extension point="org.eclipse.ui.activities"> <category id="z.ex.commands.category" name="ReadMe Cat"/> <activity id="z.ex.commands.activity" name="ReadMe Act"/> <activityPatternBinding activityId="z.ex.commands.activity" isEqualityPattern="true" pattern="org.eclipse.ui.examples.readmetool/org.eclipse.ui.examples.readmetool.wizards.new.file"/> <categoryActivityBinding activityId="z.ex.commands.activity" categoryId="z.ex.commands.category"> </extension> 

You can use the browse plug-in registry to find identifiers for actions, although you will have to do some searches.

+1
source share

The objectcontibution popup menu provides visibility and expandability. If you want to hide the account assignment of an object for a particular class, you can set the state of the visiblity object as follows.

 <visibility> <not> <objectClass name="{classname}"> </objectClass> </not> </visibility> 
0
source share

All Articles