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