如何在Eclipse中扩展源菜单? (或:它的位置是什么?) [英] How to extend the source menu in Eclipse? (or: What is its locationURI?)

查看:222
本文介绍了如何在Eclipse中扩展源菜单? (或:它的位置是什么?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个eclipse插件,并尝试在Eclipse 3.7中扩展源菜单(mainMenubar / Source - 在java编辑器中编辑时可见)。



由于旧的扩展点不推荐,文档说依赖于 org.eclipse.ui.menus -extension点。这是一个完整的秘密,我在哪里获得可靠的locationURI,但我终于设法找到一些似乎合理的URI与插件间谍(遵循一个建议 here )。
因此,以下应该是/ / / / / / / / / / / / / / / / / / / / / / / / / / < extension
point =org.eclipse.ui.menus>
< menuContribution
locationURI =menu:org.eclipse.jdt.ui.source.menu>
< command
commandId =some.command.id
label =某些标签
style =push>
< / command>
< / menuContribution>
< / extension>

不幸的是,当运行我的开发IDE的插件时,不会显示任何命令,也没有错误消息。什么也没有发生当我将locationURI设置为menu:help时,新的命令出现在帮助菜单中,所以问题似乎是locationURI。

解决方案

我遇到同样的问题。我终于弄清楚,使用(推荐)扩展点 org.eclipse.ui.menus 扩展源菜单是不可能的。



原因是在旧样式 actionSet (像Source菜单)中定义的菜单是在处理 org.eclipse.ui.menus -extensions。这样一来,这些扩展只能帮助已经存在的菜单。



所以坚持使用旧的API(由VonC建议)可能是最好的选择,直到 jdt 插件迁移到新的方法...


I am developing an eclipse plugin and trying to extend the source menu (mainMenubar/Source - visible when editing in the java-editor) in Eclipse 3.7.

The documentation says to rely on the org.eclipse.ui.menus-extension point since the older extension points are deprecated. It is a complete secret to me where to obtain reliable locationURIs, but I finally managed to find some plausible URI with the Plugin Spy (following an advice here). So the following should be the extension snippet for the plugin.xml:

<extension
 point="org.eclipse.ui.menus">
 <menuContribution
     locationURI="menu:org.eclipse.jdt.ui.source.menu">
  <command
    commandId="some.command.id"
        label="Some label"
        style="push">
  </command>
 </menuContribution>
</extension>

Unfortunately, when running the plugin for my development IDE no command appears, and also no error message. Just nothing happens. When I set the locationURI to "menu:help", the new command appears in the help menu, so the problem seems to be really the locationURI.

解决方案

I ran into the same problem. I finally figured out that extending the Source menu using the (recommended) extension point org.eclipse.ui.menus is not possible.

The reason is that a menu defined in an old style actionSet (like the Source menu) is created after the processing of org.eclipse.ui.menus-extensions. The way it is, these extensions can only contribute to already existing menus.

So sticking to the old API (as suggested by VonC) is probably the best option until the jdt plugin is migrated to the new approach...

这篇关于如何在Eclipse中扩展源菜单? (或:它的位置是什么?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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