我正在尝试创建一个 Eclipse 插件...但是如何在新上下文中添加新的弹出菜单?
例如,我右键单击该项目并将菜单放入 New->MyNewMenu
在菜单“文件-新建”中添加一个新项目,我正在使用这个
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:new?after=additions">
<menu
id="Test1.menus.sampleMenu"
但是如果我在 locationURI 上尝试 popup:menu:new?after=additions 这不起作用...
当我使用RCP eclipse的Spy插件时知道返回了弹出窗口id
menu:null?after=additions
如何解决这个问题?
最佳答案
要在"file">“新建”菜单中获取某些内容,您必须使用org.eclipse.ui.newWizards
扩展点来定义新建向导。就其本身而言,这只会使新建向导出现在“其他...”部分中。
要添加到“新建”菜单主要部分中显示的新向导列表中,您必须使用 org.eclipse.ui.perspectiveExtensions
扩展点为新向导定义 newWizardShortcut
。
JDT JUnit 插件的新向导和快捷方式示例:
<extension
point="org.eclipse.ui.newWizards">
<category
name="%WizardCategory.name"
parentCategory="org.eclipse.jdt.ui.java"
id="org.eclipse.jdt.junit">
</category>
<wizard
name="%TestCaseWizard.name"
icon="$nl$/icons/full/etool16/new_testcase.gif"
category="org.eclipse.jdt.ui.java/org.eclipse.jdt.junit"
id="org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard">
<class
class="org.eclipse.jdt.internal.junit.wizards.NewTestCaseCreationWizard">
</class>
<description>
%TestWizard.description
</description>
</wizard>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.jdt.ui.JavaPerspective">
<newWizardShortcut
id="org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard">
</newWizardShortcut>
</perspectiveExtension>
</extension>
关于java - 如何在 eclipse 上右键单击 new->MyNewMenu 添加弹出菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28236774/