0
我创建了一个示例eclipse插件项目,我需要将多个项目添加到菜单和工具栏中的相同项目。我成功地将项目添加到菜单栏中的项目,但是当我尝试将项目添加到工具栏中的项目时 - 它们都不适用于我。我如何将项目添加到工具栏中的现有项目。Eclipse插件:将项目添加到工具栏
这里是我的plugin.xml代码:
<plugin>
<extension
point="org.eclipse.ui.commands">
<category
name="Sample Category"
id="com.sample.example.commands.category">
</category>
<command
name="Sample Command"
categoryId="com.sample.example.commands.category"
id="com.sample.example.commands.sampleCommand">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="com.sample.example.commands.sampleCommand"
class="com.sample.example.handlers.SampleHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="com.sample.example.commands.sampleCommand"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
label="Sample Menu"
mnemonic="M"
id="com.sample.example.menus.sampleMenu">
<command
commandId="com.sample.example.commands.sampleCommand"
mnemonic="S"
id="com.sample.example.menus.sampleCommand">
</command>
<menu
label="Sample Menu2"
mnemonic="M"
id="com.sample.example.menus.sampleMenu2">
<command
commandId="com.sample.example.commands.sampleCommand"
mnemonic="S"
id="com.sample.example.menus.sampleCommand2">
</command>
</menu>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="com.sample.example.toolbars.sampleToolbar">
<command
commandId="com.sample.example.commands.sampleCommand"
icon="icons/sample.gif"
tooltip="Say hello world"
id="com.sample.example.toolbars.sampleCommand">
</command>
</toolbar>
</menuContribution>
</extension>
</plugin>
我尝试添加以下代码到XML,而且它并没有为我工作。
<menuContribution
locationURI="menu:com.sample.example.commands.sampleCommand?after=additions">
<command
commandId="com.sample.example.commands.sampleCommand"
id="com.sample.example.commands.sampleCommand1">
</command>
</menuContribution>
你使用哪个Eclipse版本? 3.x还是4.x? – Calon 2014-12-08 12:07:45
我认为它是4.x – 2014-12-08 12:30:05