문제

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