Wednesday, 23 January 2008

Eclipse RCP - Customizing the context menu in the Common Navigator

When you use the Common Navigator as a way to navigate your project, some of your book and web sources will indicate that you should include org.eclipse.ui.navigator.resources.* in you viewer's action binding. This adds all the actions of the common navigator to the context menu. You'll observe that there are quite a few. To see which action providers are included:


  1. Add the Plug-ins view: Window -> Show View -> Other -> PDE -> Plug-ins
  2. In the Plug-ins view, navigate to org.eclipse.ui.navigator.resources and double-click it, which will open the plug-in editor.
  3. Go to the "Extensions" page.
  4. Open org.eclipse.ui.navigator.navigatorContent




Now you'll see 6 Action Providers listed, org.eclispe.ui.internal.navigator.resources.actions.OpenActionProvider, ...actions.NewActionProvider etc, and selecting each will show it's id on the right hand side, e.g. org.eclipse.ui.navigtor.resources.OpenActions for the OpenActionProvider. These are the ids you should use instead of …resources.* in your own plug-in's navigator viewer action bindings to select the ones you want. Say, for example you want all of them except the New provider (because you have your own New con-text menu), your extensions view should look something like this:




Voila! No more New menu!

1 comment:

Gerald said...

Following your suggestion the New menu definitely disappears, but when I add a viewerActionBinding for my custom NewActionProvider it appears at the bottom of the context menu, not at the top where I would prefer it. I tried playing around with the navigatorContent actionProvider 'overrides', but that didn't seem to help the placement. Any ideas on how to place the replacement New menu?