Question

I would like to add a context menu to the Eclipse standard Outline View. Just adding a menuContribution with url

popup:org.eclipse.ui.views.ContentOutline

did not work, so I guess I need to create the context menu first. Here, I read that the menu has to be created in the view's createPartControl() method. But when adding a context menu to another view like the Outline View, where do I put this code?

Était-ce utile?

La solution

To create a context menu for a view use something like:

MenuManager contextMenu = new MenuManager();

Control control = viewer.getControl();
Menu menu = contextMenu.createContextMenu(control);
control.setMenu(menu);

getSite().registerContextMenu("menu id", contextMenu, viewer);

where viewer is the outline tree viewer.

The final registerContextMenu call means that you can contribute to this menu using the menu id you specify.

Autres conseils

This menuContribution locationURI worked for me:

popup:org.eclipse.jdt.ui.outline

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top