eclipse-rcp问题:viewerContribution添加的上下文菜单不起作用 [英] eclipse-rcp problem : context menu added by viewerContribution not work
问题描述
<extension
point="org.eclipse.ui.popupMenus">
<viewerContribution
id="com.amarsoft.sysconfig.plugin.ConnectionsViewPopupContribution"
targetID="com.amarsoft.sysconfig.plugin.views.ConnectionsView">
<action
class="com.amarsoft.sysconfig.plugin.actions.OpenConnectionAction"
id="com.amarsoft.sysconfig.plugin.actions.OpenConnectionAction"
label="打开"
menubarPath="additions">
</action>
</viewerContribution>
</extension>
但是当我打开com.amarsoft.sysconfig.plugin.views.ConnectionsView视图时,右键单击,没有发生了...
but when I open the com.amarsoft.sysconfig.plugin.views.ConnectionsView view right click ,nothing happened...
我将编辑我的帖子以添加所需的任何信息,因为现在我不知道可能导致此问题的原因。
I will edit my post to add any information needed , as now I dont know what may cause this problem.
推荐答案
依次订购 org.eclipse.ui.popupMenus
或 org.eclipse。 ui.menus
(首选)以便能够创建视图上下文菜单,该视图必须在框架中注册该菜单,通常在 createPartControl(Composite)$ c中$ c>。例如:
In order for org.eclipse.ui.popupMenus
or org.eclipse.ui.menus
(preferred) to be able to contribute to a view context menu, that view must register the menu with the framework, usually in createPartControl(Composite)
. ex:
MenuManager contextManager = new MenuManager();
contextManager.setRemoveAllWhenShown(true);
Menu contextMenu = contextManager.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(contextMenu);
getSite().registerContextMenu(contextManager, viewer);
您可以创建一个示例插件并生成视图模板,它将提供一个连接示例到 TreeViewer
。如果您不使用JFace查看器,则需要提供 org.eclipse.jface.viewers.ISelectionProvider
。
You can create a sample plugin and generate the view template, and it will provide an example of hooking up to a TreeViewer
. If you don't use JFace viewers, then you need to provide an implementation of org.eclipse.jface.viewers.ISelectionProvider
.
这篇关于eclipse-rcp问题:viewerContribution添加的上下文菜单不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!