![](/img/trans.png)
[英]How to contribute a context menu to a custom view in an eclipse plug-in project?
[英]How to contribute to a sub menu of context menu?
我試圖在viewpart的上下文菜單中定義子菜單項。
我想通過自己的插件在此子菜單中添加“連接配置文件”菜單項,希望其他插件也可以為該子菜單添加菜單項。
我的plugin.xml
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:cn.ggfan.dmp.view.explorer">
<menu
id="new"
label="New">
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="menu:new?after=additions">
<command
commandId="cn.ggfan.dmp.commands.addCP"
label="Connection Profiles"
style="push">
</command>
</menuContribution>
</extension>
它不起作用。 我的代碼有什么問題?
----------------------- 編輯 -----------------------
如果我這樣定義子菜單,它將起作用。 但我仍然不知道如何為其他插件中的“新”子菜單做出貢獻。
<menuContribution
allPopups="false"
locationURI="popup:cn.ggfan.dmp.view.explorer">
<menu
id="new"
label="new">
<command
commandId="cn.ggfan.dmp.commands.addCP"
label="Connection Profiles"
style="push">
</command>
</menu>
</menuContribution>
最后,我明白了,我的“新”子菜單應該被視為“菜單”之外的“彈出”菜單:
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:cn.ggfan.dmp.view.explorer">
<menu
id="cn.ggfan.new"
label="New">
<command
commandId="cn.ggfan.dmp.commands.addCP"
label="Connection Profile"
style="push">
</command>
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:cn.ggfan.new?after=additions">
<command
commandId="cn.ggfan.dmp.commands.addTable"
label="Table"
style="push">
</command>
</menuContribution>
</extension>
嘗試使用menu:cn.ggfan.dmp.view.explorer
而不是popup:cn.ggfan.dmp.view.explorer
。
請參閱使用菜單擴展點 -我將近6年前寫的博客條目:-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.