我想从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>
答案 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
)
所有addSeparatorOrGroupMarker
,new Separator
和new GroupMaker
调用都定义了可以在其后添加的ID。