如何在eclipse上右键单击new-> MyNewMenu添加弹出菜单?

时间:2015-01-30 13:15:41

标签: java eclipse plugins

我尝试创建一个eclipse插件......但是如何在新上下文中添加一个新的弹出菜单?

例如我右键单击项目并将我的菜单放在New-> MyNewMenu

使用此

在菜单File-New I' m上添加新项目
<extension
     point="org.eclipse.ui.menus">
  <menuContribution
        locationURI="menu:new?after=additions">
     <menu
           id="Test1.menus.sampleMenu"

但如果我尝试弹出:menu:new?after =在locationURI上添加这不起作用...

当我使用RCP eclipse的Spy插件知道弹出ID被返回时

menu:null?after=additions

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

要获取文件中的内容&gt;新菜单必须使用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>
相关问题