Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Mapping from editorContribution to menuContribution(Can not merge it to one menu.)
Mapping from editorContribution to menuContribution [message #1053504] Mon, 06 May 2013 10:36
Leonid Ripeynih is currently offline Leonid RipeynihFriend
Messages: 150
Registered: February 2012
Senior Member
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?
Previous Topic:Launching DOJO based Static Web Page from RCP App
Next Topic:Notification for XML Validation Builder
Goto Forum:
  


Current Time: Wed Apr 24 22:29:47 GMT 2024

Powered by FUDForum. Page generated in 0.02392 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top