如何在弹出菜单中添加项目? [英] How to add items in popup menu?

查看:108
本文介绍了如何在弹出菜单中添加项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



对于一个实例,



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



如何在eclipse插件开发中实现? >

Regards
Mathan

解决方案

这样做应该做遵循 , org.eclipse.ui.menus - 扩展点与 menuContribution ,其 locationURI -attribute指向 弹出窗口: org.eclipse.ui.popup.any?after = addedions

警告,作为 Prashant Bhate 在评论中提到,该软件包 org.eclipse.ui.popupMenus 已被弃用。

看到问题 objectContribution 和命令更多。


In eclipse plugin development, I want to add one item (eg: Mystyle ) in popup menu.

For an instance,

Project Explorer --> Right Click --> New --> MyStyle

How can I achieve this in eclipse plugin development?

Regards Mathan

解决方案

Something like this should do it (following 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>

See 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

See also org.eclipse.ui.popupMenus, org.eclipse.ui.menus-extension point with a menuContribution that has its locationURI-attribute pointing to popup:org.eclipse.ui.popup.any?after=additions.
Warning, as Prashant Bhate mentions in the comment, that package org.eclipse.ui.popupMenus is deprecated.
See question Missing link between objectContribution and command for more.

这篇关于如何在弹出菜单中添加项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆