开发者

adding a command to another plugin?

I'm working on a project, where we have two plugins. I have a command which i definied in the "side - plugin". I want to add it to a menu of the main plugin at runtime. The main plug开发者_JAVA百科in should not know about the side plugin. Can someone please point me in the right direction?

Thanks Patrick


You can use org.eclipse.ui.menus to contribute commands to the main menu or main toolbar. In your side plugin, after you define the command add another extension:

<extension point="org.eclipse.ui.menus">
  <menuContribution locationURI="menu:file?after=additions">
     <command commandId="z.ex.cmd.commands.sampleCommand"
           id="z.ex.cmd.menus.sampleCommand"/>
  </menuContribution>
</extension>

This will contribute a command to the File menu. All you need to know is the ID of the menu you want to contribute to (as defined in your main plugin), and an insertion point (or additions if it doesn't matter).


Contributions take only command ids. So when contributing menu/toolbar items, you can use the ids of the commands that are defined in other plugins. For this, you neither have to know about the other plugin nor set dependency on that plugin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜