有前同事问到,想在新建向导中添加一个右键菜单,可能是这样:

这种需求通过org.eclipse.ui.perspectiveExtensions扩展点就能办到。eg:
step1:实现org.eclipse.ui.newWizards向导
<extension
point="org.eclipse.ui.newWizards">
<category
id="CreateType"
name="Sample Wizards">
</category>
<wizard
category="CreateType"
class="createtype.wizards.SampleNewWizard"
icon="icons/sample.gif"
id="createtype.wizards.SampleNewWizard11"
name="我的新建向导菜单">
</wizard>
</extension>step2:扩展org.eclipse.ui.perspectiveExtensions。
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.jdt.ui.JavaPerspective">
<newWizardShortcut
id="createtype.wizards.SampleNewWizard11">
</newWizardShortcut>
</perspectiveExtension>
</extension>
说明:targetID为java透视图的id
<newWizardShortcut id="createtype.wizards.SampleNewWizard11"> </newWizardShortcut>里面的id为我们要添加到new新建菜单下的新建向导的id
小bug为:run或debug时,并没有显示出来。清除一下缓存(Run Configurations--->Clear Workspace Data),就显示出来了。不知道这是不是pde的一个bug。


本文介绍了如何使用Eclipse UI的`org.eclipse.ui.perspectiveExtensions`扩展点在新建向导中添加一个右键菜单。通过实现`org.eclipse.ui.newWizards`向导并扩展`org.eclipse.ui.perspectiveExtensions`,可以为特定透视图添加定制的右键菜单选项。同时,文中提及了运行或调试时未显示新建菜单项的小bug及解决办法。
1863

被折叠的 条评论
为什么被折叠?



