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?

Lii
  • 11,553
  • 8
  • 64
  • 88
Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
  • 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 '09 at 08: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 '09 at 08: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 '09 at 08:41

3 Answers3

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;
}
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks! But do I get it right - I disable *all* contributions this way? No way to disable individual contributions, maybe identified by their ids? – Andreas Dolk Sep 13 '09 at 07:51
0

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

tekumara
  • 8,357
  • 10
  • 57
  • 69