【问题标题】:How to make my plugin contributes adding a menu-item into an existing sub-menu from an existing menu in Eclipse platform?如何使我的插件有助于从 Eclipse 平台中的现有菜单将菜单项添加到现有子菜单中?
【发布时间】:2018-10-19 21:26:03
【问题描述】:

目前我在一个 Eclipse 插件项目中工作,我创建了一个可以通过单击主菜单显示的视图 Window->Show view->Other...,然后点击 Other 类别中的我的视图。

目前我正在我的plugin.xml 文件中尝试这个:

<extension
     point="org.eclipse.ui.menus">
  <menuContribution
        locationURI="menu:window?after=additions">

     <menu 
           id="com.kwantec.helloworld.menus.sampleMenu"
           label="Sample Menu"
           mnemonic="M">
        <command
              commandId="com.kwantec.helloworld.commands.sampleCommand"
              id="com.kwantec.helloworld.menus.sampleCommand"
              mnemonic="S">
        </command>
     </menu>
  </menuContribution>
</extension>

..这会导致新的子菜单 Sample Menu 出现在 Eclipse 的现有 Window 菜单中。然后我可以通过点击Window-&gt;Sample Menu-&gt;Sample Command 打开我的视图。 但是现在,我需要的是直接将 Sample Command 添加到 sub-menu Show Viewmenu-items 中,从 Eclipse 的现有 Window 菜单中。 类似于Window-&gt;Show View-&gt;Sample Command

我花了几天时间研究 Eclipse 平台文档,但没有取得重大进展。 有人知道怎么做吗?

提前致谢。

【问题讨论】:

    标签: java plugins eclipse-plugin eclipse-rcp menuitem


    【解决方案1】:

    直接在“窗口 > 显示视图”中显示的视图称为“视图快捷方式”。您可以使用 org.eclipse.ui.perspectiveExtensions 扩展点为特定视角添加这些。

    类似:

    <extension point="org.eclipse.ui.perspectiveExtensions"> 
        <perspectiveExtension 
            targetID="org.eclipse.ui.resourcePerspective"> 
            <viewShortcut id="your.view.id"/> 
        </perspectiveExtension> 
    </extension> 
    

    Heer targetID 定义了您正在更新的透视图,viewShortcutid 是您的视图 ID。

    您可能需要重置透视图以显示添加内容(窗口 > 透视图 > 重置透视图)。

    【讨论】:

    • 非常感谢 greg-449 !!这正是我一直在寻找的。效果很好!
    猜你喜欢
    • 1970-01-01
    • 2012-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-06
    • 2020-03-04
    相关资源
    最近更新 更多