是否可以扩展 Eclipse 搜索菜单

发布于 2024-11-27 23:45:32 字数 216 浏览 2 评论 0原文

现在在 Eclipse 中,无法使用 Eclipse 扩展来扩展其他插件定义的菜单: org.eclipse.ui.menus。

我想在搜索中添加一个菜单项,但不是搜索页面。由于菜单搜索是由 org.eclipse.search 定义的,我无法添加它。

但我看到 JDT 和 CDT 确实在搜索下添加了一些菜单项。有谁知道他们是如何让它发挥作用的吗?

任何提示表示赞赏。

right now in eclipse it is not possible to extend Menu defined by Other plugins by using eclipse extension:
org.eclipse.ui.menus.

I want to add one menu item in Search but not a search page. since the Menu Search is defined by org.eclipse.search, I cannot add it.

but I see JDT and CDT do add some menu item under search. does any body know how they make it work?

any hint is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

埋葬我深情 2024-12-04 23:45:32

您可以使用 org 从其他插件扩展菜单.eclipse.ui.actionSets 扩展点

这就是 JDT 使用自己的操作扩展搜索菜单的方式。为了在给定菜单中执行操作,您必须填写 menubarPath 值。例如,Java 搜索操作的 JDT 填充了以下内容:

org.eclipse.search.menu/dialogGroup

我建议导入 JDT UI 源并查看 JDT plugin.xml 文件。或者,您将需要一个经典的 Eclipse SDK,然后在插件视图中右键单击 org.eclipse.jdt.ui 插件并选择导入作为源。

You can extend menus from other plugins using org.eclipse.ui.actionSets extension point

This is how the JDT does to extend the search menu with its own action. In order to have the action in a given menu you'll have to fill the menubarPath value. For example the JDT for the Java search action filled it with:

org.eclipse.search.menu/dialogGroup

I suggest to import the JDT UI sources and to look at the JDT plugin.xml file. FOr that you will need a classic Eclipse SDK and then in the plugins view right click on the org.eclipse.jdt.ui plugin and select import as source.

憧憬巴黎街头的黎明 2024-12-04 23:45:32

只要您知道菜单或工具栏的 ID,就可以使用 org.eclipse.ui.menus 扩展点来扩展它们。对于搜索菜单,此 ID 为 org.eclipse.search.menu。如果您想向 dialogGroup 添加内容,请使用 org.eclipse.search.menu?after=dialogGroup

As long as you know the ID of the menu or toolbar, you can extend these using the org.eclipse.ui.menus extension point. For the search menu, this ID is org.eclipse.search.menu. If you want to add stuff to the dialogGroup then use org.eclipse.search.menu?after=dialogGroup.

半岛未凉 2024-12-04 23:45:32

2012 年 8 月更新,如 reprogrammer 所评论,org.eclipse.ui.actionSets 已弃用:

而是使用扩展点 org.eclipse.ui.commands


原始答案(2011 年 8 月)

actionSet (extension point="org.eclipse.ui.actionSets") 上的操作Manuel SelvamenubarPath="org.eclipse.search.menu/dialogGroup"” a> 是官方解决方案,符合 一般菜单贡献

但要注意一些可能仍然存在于搜索菜单贡献中的问题,如由此线程围绕(据说已修复)错误 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>
<!-- (...) -->

Update August 2012, as commented by reprogrammer, org.eclipse.ui.actionSets is deprecated:

Instead, use the extension point org.eclipse.ui.commands.


Original answer (August 2011)

The actionSet (extension point="org.eclipse.ui.actionSets") with an action on 'menubarPath="org.eclipse.search.menu/dialogGroup"' recommended by Manuel Selva is the official solution, in line with general menu contribution.

But beware of some issue that might still lingering for Search menu contribution, as illustrated by this thread around the (supposedly fixed) bug 15684:
(it was in 2009, hopefully the issue has been addressed since)

What actually does work is redefining the whole Search Menu as in the workaround that is still currently used in 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>
<!-- (...) -->
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文