how can I add popup menu in right-click new->MyNewMenu on eclipse?

匿名 (未验证) 提交于 2019-12-03 01:45:01

问题:

I'm try to create a eclipse plugin... but how can I add a my new popup menu in the new context?

for example I right-click on the project and put my menu inside of New->MyNewMenu

to add a new item on menu File-New I'm using this

<extension      point="org.eclipse.ui.menus">   <menuContribution         locationURI="menu:new?after=additions">      <menu            id="Test1.menus.sampleMenu" 

but if I try popup:menu:new?after=additions on locationURI this not work...

when I use the Spy plugin of RCP eclipse to know the popup id is returned

menu:null?after=additions 

how can I solve this problem?

回答1:

To get something in the File > New menu you must use the org.eclipse.ui.newWizards extension point to define a New wizard. On its own this will just make the New wizard appear in the 'Other...' section.

To add to the list of new wizards shown in the main part of the New menu you must use the org.eclipse.ui.perspectiveExtensions extension point to define a newWizardShortcut for your new wizard.

An example of a new wizard and shortcut from the JDT JUnit plugin:

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


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!