gpt4 book ai didi

eclipse - 如何在弹出菜单中添加项目?

转载 作者:行者123 更新时间:2023-12-02 11:44:55 25 4
gpt4 key购买 nike

在 eclipse 插件开发中,我想在弹出菜单中添加一项(例如: Mystyle )。

举个例子,

项目资源管理器 --> 右键单击​​ --> 新建 --> MyStyle

如何在 eclipse 插件开发中实现这一点?

问候马森

最佳答案

类似这样的事情应该可以做到(在this thread之后):

   <extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI=
"popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=additions">
<command
commandId="myplugin.command.mycommand"
icon="icons/etool16/mycommand.png"
label="Run mycommand"
mnemonic="M1+P"
tooltip="Do something with this project">
</command>
</menuContribution>
</extension>

参见Menucontribution

Defines an ordered set of additions to the command UI structure. The defined elements will be added into the command UI structure at the location specified by the locationURI element.

This should be the starting point for all contributions into menus, toolbars or trim, wherever they occur in the UI.

  • locationURI - A URI specification that defines the insertion point at which the contained additions will be added.
    The format for the URI is comprised of three basic parts:
    • Scheme: One of "menu", "popup" or "toolbar.
      Indicates the type of the manager used to handle the contributions
    • Id: This is either the id of an existing menu, a view id or the id of the editor 'type'
    • Query: The query format is <placement>=<id> where: <placement> is either "before" or "after" and <id> is the id of an existing menu item

Show Readme Action

另请参阅 org.eclipse.ui.popupMenus , org.eclipse.ui.menus -带有 menuContribution 的扩展点有它的 locationURI -指向的属性popup:org.eclipse.ui.popup.any?after=additions
警告,如Prashant Bhate评论中提到,那个包 org.eclipse.ui.popupMenus已弃用。
查看问题Missing link between objectContribution and command了解更多。

关于eclipse - 如何在弹出菜单中添加项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1342532/

25 4 0