如何动态填充 Eclipse 弹出菜单?
如何在 Eclipse 中动态填充 popupMenu 的操作。
我尝试了以下教程: http://wiki.eclipse.org/Menu_Contributions/Populated_a_dynamic_submenu 没有太多成功。
这是我的plugin.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.popupMenus">
<viewerContribution
id="org.eclipse.ui.articles.action.contribution.popup.navigator"
targetID="org.eclipse.ui.views.ResourceNavigator">
<menu
id="org.eclipse.ui.articles.action.contribution.navigator.subMenu"
label="Apply command"
path="additions">
<dynamic class="helloworld.DynamicMenu"
id="org.eclipse.ui.views.problems.groupBy.items"></dynamic>
</menu>
</viewerContribution>
</extension>
</plugin>
问题是,没有任何反应。 DynamicMenu 中的 getContributionItems 不会被调用,并且我没有收到任何错误。 Eclipse 确实警告我,尽管动态不是菜单的合法子项。
我正在运行 eclipse 3.7 并构建针对同一版本的扩展。
How do you dynamically populate the actions of a popupMenu in Eclipse.
I tried the following tutorial : http://wiki.eclipse.org/Menu_Contributions/Populating_a_dynamic_submenu without much success.
Here is my plugin.xml file
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.popupMenus">
<viewerContribution
id="org.eclipse.ui.articles.action.contribution.popup.navigator"
targetID="org.eclipse.ui.views.ResourceNavigator">
<menu
id="org.eclipse.ui.articles.action.contribution.navigator.subMenu"
label="Apply command"
path="additions">
<dynamic class="helloworld.DynamicMenu"
id="org.eclipse.ui.views.problems.groupBy.items"></dynamic>
</menu>
</viewerContribution>
</extension>
</plugin>
The problem is, nothing happens. getContributionItems from DynamicMenu doesn't get called and I don't get any error. Eclipse does warn me though that dynamic is not a legal child of menu.
I am running eclipse 3.7 and building extensions targeting the same version.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所指的教程使用 org.eclipse.ui.menus 扩展点而不是 org.eclipse.ui.popupMenus。前者是后者的替代,应该是首选。
The tutorial that you are referring to uses org.eclipse.ui.menus extension point rather than org.eclipse.ui.popupMenus. The former is replacement for the latter and should be preferred.