在做RCP开发中遇到个问题,搞了大半天。代码贴出来:
[color=red]
比较郁闷的是少了在视图中加第一代码,上下文菜单一直出不来[/color]
view(视图)
MenuManager menuManager = new MenuManager();
Menu menu = menuManager.createContextMenu(viewer.getControl());
MenuItem item = new MenuItem (menu, SWT.PUSH);
item.setText ("Popup");
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(menuManager, viewer);
plugin.xml
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any">
<command
commandId="com.ibm.de.eclipse.menu.command.viewCmd">
<visibleWhen>
<reference
definitionId="twoSelectedCheck">
</reference>
</visibleWhen>
</command>
</menuContribution>
[color=red]
比较郁闷的是少了在视图中加第一代码,上下文菜单一直出不来[/color]