Frage

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?

War es hilfreich?

Lösung

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.

Andere Tipps

This menuContribution locationURI worked for me:

popup:org.eclipse.jdt.ui.outline

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top