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
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
You can also use activities for anything contributed through a plugin.xml. For objectContributions, you would use the form "contributing.plugin.id/action.id". Here's an example that applies to a wizard, but the same pattern 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>
The Plug-in Registry view can be used to find the IDs for actions, although you'll have to do some searching.
The popup menu objectcontibution provides an extension element visibilty and enablement. In case you want to hide the object contibution for a particular class you could set the visiblity object state as follows.
<visibility>
<not>
<objectClass
name="{classname}">
</objectClass>
</not>
</visibility>
精彩评论