Search code examples
eclipseeclipse-plugineclipse-rcpeclipse-pde

Not able to extend the Help menu


I want to add from an eclipse plugin a Request Support button to the Help menu.

I tried first from a *.e4xmi file and now I tried from the plugin.xml but still can't make a button to appear under the Help menu.

I got the menu URI with the help of Eclipse Spy Plug-in.
The content of 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>

What am I missing?

SOLUTION from greg's answer:

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

Solution

  • This is what 'Check for Updates' uses:

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

    Which is adding after the 'additions' location.

    The code which creates the help menu defines a lot of locations:

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

    (from org.eclipse.ui.internal.ide.WorkbenchActionBuilder)

    All the addSeparatorOrGroupMarker, new Separator and new GroupMaker calls define ids to can add after.