试图把新的“生成”选项在Eclipse的“源”菜单下 [英] Trying to put new "Generate" option under Source menu in Eclipse
问题描述
当您右键单击Java文件时,我正在尝试在源菜单下添加一个新的生成...选项。在这一点上,我只是想让菜单选项显示出来,但我还没有成功。
I'm trying to add a new "Generate..." option under the Source menu when you right-click on a Java file. At this point, I'm just trying to get the menu option to show up but I haven't had success yet.
我的plugin.xml有什么问题吗文件下面你可以看到?
Is there something wrong with my plugin.xml file below as far as you can see?
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.popupMenus">
<objectContribution
id="GenerateBuilderPlugin.contribution1"
objectClass="org.eclipse.core.resources.IFile">
<action
class="generatebuilderplugin.popup.actions.GenerateBuilder"
enablesFor="1"
id="GenerateBuilderPlugin.newAction"
label="Generate Builder..."
menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup">
</action>
</objectContribution>
</extension>
</plugin>
推荐答案
我最后以Hello,World Command 模板并根据我的需要进行调整。
I ended up going with the "Hello, World Command" template and adjusting for my needs.
以下是在源菜单上成功显示新的生成...选项的更新的plugin.xml。一个只是基本上需要设置一个命令和一个执行实际工作的处理程序类。我建议您按照Hello,World Command插件模板和您的需要进行调整。
Below is the updated plugin.xml that successfully displays the a new "Generate..." option on the Source menu. One just basically needs to setup a command and a handler class that does the actual work. I'd recommend just following the "Hello, World Command" plugin template and tweaking for your needs.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.commands">
<command
name="Generate Builder..."
id="GenerateBuilderProject.commands.GenerateBuilder">
</command>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler
commandId="GenerateBuilderProject.commands.GenerateBuilder"
class="generatebuilderproject.handlers.GenerateBuilderHandler">
</handler>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.jdt.ui.source.menu?after=generateGroup">
<command
commandId="GenerateBuilderProject.commands.GenerateBuilder"
id="GenerateBuilder.menus.GenerateBuilder">
</command>
</menuContribution>
</extension>
</plugin>
这篇关于试图把新的“生成”选项在Eclipse的“源”菜单下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!