views:

719

answers:

2

Hi - 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 ECP applications?

+1  A: 

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
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_D
+1  A: 

Take a look at the Eclipse "Activities" API. It allows you to hide contributions based on ID.

A few links:

Nick Veys