开发者

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.a开发者_Python百科marsoft.sysconfig.plugin.actions.OpenConnectionAction"
             label="打开"
             menubarPath="additions">
       </action>
    </viewerContribution>
 </extension>

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.


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);

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.


Unless you're targeting Eclipse 3.3 or before, consider moving to the new extension points. See this blog entry for more information...

UPDATED_ link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜