添加命令到另一个插件?
我正在开发一个项目,其中有两个插件。我有一个在“侧面插件”中定义的命令。我想在运行时将其添加到主插件的菜单中。主插件不应该知道副插件。有人可以指出我正确的方向吗?
谢谢帕特里克
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 plugin should not know about the side plugin. Can someone please point me in the right direction?
Thanks Patrick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 org.eclipse.ui.menus 向主菜单或主工具栏提供命令。在您的侧插件中,定义命令后添加另一个扩展:
这将为文件菜单提供一个命令。您需要知道的只是您想要贡献的菜单的 ID(如主插件中所定义)和插入点(或添加项,如果不重要的话)。
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: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).
贡献仅需要命令 ID。因此,在贡献菜单/工具栏项时,您可以使用其他插件中定义的命令的 ID。为此,您既不必了解其他插件,也不必设置对该插件的依赖关系。
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.