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?

有帮助吗?

解决方案

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.

其他提示

This menuContribution locationURI worked for me:

popup:org.eclipse.jdt.ui.outline

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top