【问题标题】:Removing a popup menu contributed from another plugin删除从另一个插件贡献的弹出菜单
【发布时间】:2011-06-09 14:44:26
【问题描述】:

我在尝试从上下文菜单中删除对添加插入点的一些插件贡献时遇到了一些问题。在大多数情况下,我使用活动并且这很有效,因为大多数贡献都是通过操作完成的。但在其他一些情况下,贡献是弹出菜单贡献,我无法成功禁用这些条目。一个例子是 Source->Format 菜单的贡献。贡献由插件 org.eclipse.wst.sse.ui 通过以下方式完成:

  <menuContribution
       locationURI="popup:org.eclipse.ui.popup.any?after=additions">
    <menu
          id="sourceMenuId"
          label="%Source">
        <command
              commandId="org.eclipse.wst.sse.ui.format"
              id="sourceFormat"
              style="push">
           <!-- Check to make sure that the handler is enabled before making visible -->
            <visibleWhen checkEnabled="true" />
        </command>
    </menu>
 </menuContribution>

我一直在尝试使用模式 org.eclipse.wst.sse.ui/sourceFormat 和 org.eclipse.wst.sse.ui/.*。它们都在 Ecipe HELIOS 中工作,但在 RAD(Rational Application Developer 8.0.2)中不工作。 有没有其他方法可以禁用此弹出菜单贡献?请问这个问题和Eclipse版本有关吗?

【问题讨论】:

    标签: popup contextmenu rad


    【解决方案1】:

    我遇到了类似的问题(例如:Eclipse 相关的右键单击菜单条目出现在我的视图中),我可以使用以下代码修复它。

    解决方案是我的应用程序中缺少的声明 getSite().setSelectionProvider(viewer);。这导致与视图无关的选择条目潜入并激活菜单条目。希望它可以帮助遇到同样问题的人。

    private void hookContextMenu() {
        MenuManager menuMgr = new MenuManager("#PopupMenu");  //$NON-NLS-1$
        ....
    
        Menu menu = menuMgr.createContextMenu(viewer.getControl());
        viewer.getControl().setMenu(menu);
        getSite().registerContextMenu(menuMgr, viewer);
    
        getSite().setSelectionProvider(viewer);
    }
    

    【讨论】:

      猜你喜欢
      • 2011-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 2012-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多