質問

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