6

I frequently had this problem and didn't find a solution yet: Whenever I write a new Eclipse RCP based application and include plugins from the Eclipse platform, I 'inherit' UI contributions from some of those plugins.

Most of this contributions (menu entries, keyboard shortcuts, property pages) are useful but sometimes I'd rather disabled some of these contributions, just because I really do not need them and they might confuse the users.

Does anyone know of the official or a practical way to disable/prohibit selected contributions in Eclipse RCP applications?

3
  • I don't think removeContributionFactory() is for disabling all contribution, but is rather a "dispose" mechanism used for un-registering one view/menu contribution, and I was proposing to use that for explicitly remove contributions coming from other plugins.
    – VonC
    Sep 13, 2009 at 8:37
  • So it is: a/ not exactly what you are looking for, b/ not easy, since you have to detect those contributions and remove them. But this is what I have got so far.
    – VonC
    Sep 13, 2009 at 8:39
  • re-reading your comment: no you are not disabling all contribution (from all other plugins), but you might ending up disabling all contributions from one given external plugin.
    – VonC
    Sep 13, 2009 at 8:41

3 Answers 3

3

The only method which comes close to do that would be:

IMenuService::removeContributionFactory()

Paul Webster has been calling for a IMenuService::addOverride() to change the visibility of the menu, preventing any contribution, but that idea has not been integrated yet.

You can see an example of removing a contribution in this org.eclipse.ui.tests.menus.MenuBuilder class;

public static void removeMenuContribution() {
    if (!PlatformUI.isWorkbenchRunning()) {
        return;
    }
    IMenuService menuService = (IMenuService) PlatformUI.getWorkbench()
            .getService(IMenuService.class);
    if (menuService==null) {
        return;
    }
    menuService.removeContributionFactory(viewMenuAddition);
    viewMenuAddition = null;
    menuService.removeContributionFactory(viewToolbarAddition);
    viewMenuAddition = null;
}
1
  • Thanks! But do I get it right - I disable all contributions this way? No way to disable individual contributions, maybe identified by their ids? Sep 13, 2009 at 7:51
0

Equinox transformations can also be used to supply XLST transformations that remove unwanted UI contributions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.