无法扩展帮助菜单

时间:2018-07-18 09:31:08

标签: eclipse eclipse-plugin eclipse-rcp eclipse-pde

我想从eclipse插件中向Request Support菜单添加一个Help按钮。

我首先从*.e4xmi文件尝试过,现在我从plugin.xml开始尝试了,但是仍然无法在Help菜单下显示按钮。

我在Eclipse Spy Plug-in的帮助下获得了菜单URI。
plugin.xml的内容:

<extension
    point="org.eclipse.ui.menus">
    <menuContribution
        allPopups="false" (tried with true and same result)
        locationURI="menu:help?after=about">
        <menu
            commandId="com.plugin.RequestSupport"
            id="requestSupport"
            label="Request Support">
        </menu>
    </menuContribution>
</extension>
<extension
    point="org.eclipse.ui.commands">
    <command
        defaultHandler="com.plugin.handlers.RequestSupportHandler"
        description="Opens up default e-mail client with preset basic informations"
        id="com.plugin.RequestSupport"
        name="Request Support">
    </command>
</extension>

我想念什么?

格雷格答案的解决方案:

<extension
    point="org.eclipse.ui.menus">
    <menuContribution
        allPopups="false" (tried with true and same result)
        locationURI="menu:help?after=about">

        <menu
            commandId="com.plugin.RequestSupport"
            id="requestSupport"
            label="Request Support">
        </menu>

        <command
            commandId="com.plugin.RequestSupport"
            id="requestSupport"
            label="Request Support"
            style="push">
        </command>
    </menuContribution>
</extension>

1 个答案:

答案 0 :(得分:1)

这是“检查更新”的用途:

<extension
     point="org.eclipse.ui.menus">
  <menuContribution
        locationURI="menu:help?after=additions">
        <command
              commandId="org.eclipse.equinox.p2.ui.sdk.update"
              mnemonic="%Update.command.mnemonic"
              id="org.eclipse.equinox.p2.ui.sdk.update"
              icon="icons/obj/iu_update_obj.png">
        </command>

在“添加”位置之后添加的位置。

创建帮助菜单的代码定义了很多位置:

private MenuManager createHelpMenu() {
    MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_help, IWorkbenchActionConstants.M_HELP);
    addSeparatorOrGroupMarker(menu, "group.intro"); //$NON-NLS-1$
    // See if a welcome or intro page is specified
    if (introAction != null) {
        menu.add(introAction);
    } else if (quickStartAction != null) {
        menu.add(quickStartAction);
    }
    menu.add(new GroupMarker("group.intro.ext")); //$NON-NLS-1$
    addSeparatorOrGroupMarker(menu, "group.main"); //$NON-NLS-1$
    menu.add(helpContentsAction);
    menu.add(helpSearchAction);
    menu.add(dynamicHelpAction);
    addSeparatorOrGroupMarker(menu, "group.assist"); //$NON-NLS-1$
    // See if a tips and tricks page is specified
    if (tipsAndTricksAction != null) {
        menu.add(tipsAndTricksAction);
    }
    // HELP_START should really be the first item, but it was after
    // quickStartAction and tipsAndTricksAction in 2.1.
    menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START));
    menu.add(new GroupMarker("group.main.ext")); //$NON-NLS-1$
    addSeparatorOrGroupMarker(menu, "group.tutorials"); //$NON-NLS-1$
    addSeparatorOrGroupMarker(menu, "group.tools"); //$NON-NLS-1$
    addSeparatorOrGroupMarker(menu, "group.updates"); //$NON-NLS-1$
    menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END));
    addSeparatorOrGroupMarker(menu, IWorkbenchActionConstants.MB_ADDITIONS);
    // about should always be at the bottom
    menu.add(new Separator("group.about")); //$NON-NLS-1$

    ActionContributionItem aboutItem = new ActionContributionItem(aboutAction);
    aboutItem.setVisible(!Util.isMac());
    menu.add(aboutItem);
    menu.add(new GroupMarker("group.about.ext")); //$NON-NLS-1$
    return menu;
}

(来自org.eclipse.ui.internal.ide.WorkbenchActionBuilder

所有addSeparatorOrGroupMarkernew Separatornew GroupMaker调用都定义了可以在其后添加的ID。