Hi all!
I have a following problem. I have an EditorActionBarContributor, which makes a contribution to the Menu with the following code:
@Override
public void contributeToMenu(IMenuManager menuManager) {
super.contributeToMenu(menuManager);
IMenuManager submenuManager = new MenuManager(ModelEditorPlugin.INSTANCE.getString("_UI_Example_Menu_Label"), "[b]example.menu.id[/b]");
menuManager.insertAfter("additions", submenuManager);
submenuManager.add(new Separator("settings"));
submenuManager.add(new Separator("actions"));
submenuManager.add(new Separator("[b]additions[/b]"));
submenuManager.add(new Separator("additions-end"));
// Actually fill submenuManager with actions...
//
}
In another plugin I have some more functionality, I'd like to contribute to editor, so I've created an editorContribution to add more actions. They're defined with the following plugin.xml code:
<extension point="org.eclipse.ui.editorActions">
<editorContribution
id="example.editor.contrib"
targetID="example.editorId">
<action
id="example.editor.contrib.a1"
label="%_UI_A1_Label"
menubarPath="[b]example.menu.id[/b]/[b]additions[/b]"
class="example.actions.contrib.Action1"/>
</editorContribution>
</extension>
It works fine, and new action is contributed in exactly the same menu, created by EditorActionBarContributor.
But, as far as I know, a modern way to add actions is via Command Framrwork. I have some Handlers in project (in it's CNF part), so I decided to move that contributions to Command Framework as well. I've read this http://wiki.eclipse.org/Menus_Extension_Mapping, but I don't understand how exactly map an editorContribution to menuContribution? My current attempts are:
First (Creates a separarate entry in main menu)
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<command
commandId="example.commands.c1"
label="%_UI_Command1_Label"
style="push">
<visibleWhen checkEnabled="false">
<with variable="activePartId">
<equals value="example.editorId"/>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
Second (Nothing is visible)
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=[b]example.menu.id[/b]">
<command
commandId="example.commands.c1"
label="%_UI_Command1_Label"
style="push">
<visibleWhen checkEnabled="false">
<with variable="activePartId">
<equals value="example.editorId"/>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
Third(duplicates menu, inserts command in that menu)
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="[b]example.menu.id[/b]"
label="%_UI_Example_Menu_Label">
<visibleWhen checkEnabled="false">
<with variable="activePartId">
<equals value="example.editorId"/>
</with>
</visibleWhen>
<command
commandId="example.commands.c1"
label="%_UI_Command1_Label"
style="push">
<visibleWhen checkEnabled="false">
<with variable="activePartId">
<equals value="example.editorId"/>
</with>
</visibleWhen>
</command>
</menu>
</menuContribution>
</extension>
Non of which is working in same way like editorContribution. Am I doing something wrong, or is it a limitation of the Platform? Is there any workaround or way to fix it?