我已经查看了几个类似的问题,但我无法解决此问题,我想在Project Explorer
视图中右键单击项目或文件夹时,将子项添加到上下文菜单中。
我在plugin.xml
中添加了根元素:
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="true"
class="com.my.menu.MyMenu"
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
</menuContribution>
MyMenu
类扩展了ExtensionContributionFactory
,并且我覆盖了createContributionItems()
方法,如下所示:
@Override
public void createContributionItems(final IServiceLocator serviceLocator, final IContributionRoot additions) {
// build a command-based contribution parameters
CommandContributionItemParameter pAA = new CommandContributionItemParameter(
serviceLocator,
"Submenu_CommandAA",
"my.menu.root",
SWT.PUSH);
pAA.label = "Command AA";
// create actual contribution items and add them to the given additions reference
CommandContributionItem itemAA = new CommandContributionItem(pAA);
itemAA.setVisible(true);
additions.addContributionItem(itemAA, null);
}
然后,当我右键单击某个项目时,我收到此错误:
!MESSAGE Unable to create menu item "Submenu_CommandAA", command "my.menu.root" not defined