Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How remove pop-up menu contributions in eclipse RCP

I'm working in a RCP application and I have a view which data model are instances of IResources. When popup menu is visible I find commands contributed by others plugins I would like to remove.

Sample of code:

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 line 5 context menu doesn't appear.

Is posible use menu-contribution from plugin.xml and remove contributions of other plugins?

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

Thanks in advance

like image 441
yeraycaballero Avatar asked Jan 20 '11 13:01

yeraycaballero


1 Answers

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

You can checkout the bundles with some examples (see the wiki-page for more infos), I made good experiences with the XSLT transformer, to manipulate certain plugin.xml files before they're contributing their extensions to the platform (the only challenge is to find out which bundle is contributing the annoying context-menu entry, but you can use PluginSpy to determinate the "evildoer" :-P.

HTH Tom

like image 69
Tom Seidel Avatar answered Oct 03 '22 09:10

Tom Seidel