不可能通过使用eclipse扩展来扩展由其他插件定义的Menu: org.eclipse.ui.menus。现在是否可以在eclipse中扩展Eclipse Search Menu
我想在搜索中添加一个菜单项,但不是搜索页面。由于菜单搜索是由org.eclipse.search定义的,我不能添加它。
但我看到JDT和CDT在搜索下添加了一些菜单项。任何机构知道他们如何使其工作?
任何暗示赞赏。
不可能通过使用eclipse扩展来扩展由其他插件定义的Menu: org.eclipse.ui.menus。现在是否可以在eclipse中扩展Eclipse Search Menu
我想在搜索中添加一个菜单项,但不是搜索页面。由于菜单搜索是由org.eclipse.search定义的,我不能添加它。
但我看到JDT和CDT在搜索下添加了一些菜单项。任何机构知道他们如何使其工作?
任何暗示赞赏。
您可以使用org.eclipse.ui.actionSets扩展点
这是JDT如何做来扩展其自己的行动搜索菜单其他插件扩展菜单。为了在给定的菜单中执行操作,您必须填写menubarPath
的值。
org.eclipse.search.menu/dialogGroup
我建议要导入的JDT UI来源和看JDT plugin.xml文件:例如,JDT为Java搜索行动填补它。如果您需要经典的Eclipse SDK,然后在插件视图中右键单击org.eclipse.jdt.ui
插件并选择导入作为源。
其他地方已经说过,但为了清楚起见,'org.eclipse.ui.actionSets'已被弃用。 – StockB
2012更新八月,如reprogrammer评论,org.eclipse.ui.actionSets
被弃用:
相反,使用扩展点
org.eclipse.ui.commands
。
原来的答复(2011年8月)
的actionSet(extension point="org.eclipse.ui.actionSets"
)与Manuel Selva建议对 'menubarPath="org.eclipse.search.menu/dialogGroup"
' 行动是官方的解决办法,符合general menu contribution。
但要注意一些问题,可能仍然萦绕搜索菜单的贡献,为周围的(所谓固定)illustrated by this threadbug 15684:
(那是在2009年,希望这个问题一直以来处理)
究竟确实工作正在重新定义了整个搜索菜单中的变通方法,仍是目前JDT 3.6中使用:
<extension
point="org.eclipse.ui.actionSets">
<actionSet
label="%JavaSearchActionSet.label"
description="%JavaSearchActionSet.description"
visible="false"
id="org.eclipse.jdt.ui.SearchActionSet">
<!-- see http://bugs.eclipse.org/bugs/show_bug.cgi?id=15684 -->
<!-- Note: The menu (re-) definition has to be here due to bug: -->
<!-- =================================================================== -->
<!-- Search Menu -->
<!-- =================================================================== -->
<menu
label="%searchMenu.label"
path="navigate"
id="org.eclipse.search.menu">
<groupMarker name="internalDialogGroup"/> <!-- not to be used by clients -->
<groupMarker name="dialogGroup"/> <!-- to be used by clients -->
<separator name="fileSearchContextMenuActionsGroup"/> <!-- to be used by clients -->
<separator name="contextMenuActionsGroup"/> <!-- to be used by clients -->
<separator name="occurencesActionsGroup"/> <!-- to be used by clients -->
<separator name="extraSearchGroup"/> <!-- to be used by clients -->
</menu>
<!-- (...) -->
太好了,谢谢你的回答,但是我怎么能控制我的菜单项的可见性,比如Search下的menuitem'C++','Java'。我尝试了操作中的'可见性'元素,但它不起作用。 – jumpingstone
@VonC:现在不推荐使用扩展点org.eclipse.ui.actionSets。请参阅http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_actionSets.html – reprogrammer
@VonC:使用'org.eclipse。用于将项目添加到通过'actionSets'贡献的旧菜单的ui.menu'扩展点并不简单。看到我的意见在http://stackoverflow.com/questions/6937322/is-it-possible-to-extend-eclipse-search-menu#comment15700341_6939032和http://stackoverflow.com/questions/7941278/adding-menu- item-in-eclipse#comment15700568_7941776如果您知道如何使用新的扩展点将项目添加到旧的菜单(如JDT Refactor或Search),请更新您的答案。 – reprogrammer
只要您知道菜单或工具栏的ID,就可以使用org.eclipse.ui.menus
扩展点来扩展它们。对于搜索菜单,此ID是org.eclipse.search.menu
。如果你想添加东西到dialogGroup
然后使用org.eclipse.search.menu?after=dialogGroup
。
谢谢,我重新定义了JDT解决方案之后的搜索菜单,现在我的菜单项显示在搜索下。 – jumpingstone
@Tonny Madsen:我喜欢使用扩展点'org.eclipse.ui.menus'而不是'org.eclipse.ui.actionSets'的想法,因为后者已被弃用(http://help.eclipse.org /juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_actionSets.html)。但是,将菜单项添加到使用actionSets定义的菜单看起来有点不同,并且您建议的标准方法不适用于此目的。 – reprogrammer
在Eclipse中,一切皆有可能:-) –