1

I want to add an action to the "Source" menus in Eclipse (there's one in the main menu, one when you press alt+shift+S in the Editor, one when you right click the editor and select source).

The code closest to working is this one (it's only shown in the submenu of the popup, not in the other two):

<extension point="org.eclipse.ui.menus">
    <menuContribution allPopups="true"
      locationURI="popup:org.eclipse.jdt.ui.source.menu?after=additions">
        <command commandId="org.acme.command" style="push" />
    </menuContribution>
</extension>

The Eclipse Menu Spy claims the URL of the actions is something like that: ''locationURI="menu:null?after=AddGetterSetter"'', but of course this does not work either.

Someone was suggesting it might be due to the use of action sets, but this answer is four years old, and even though there are still actions used in the JDT plug-ins, they must have evolved since then (they are even deprecated).

Nonetheless, I tried the approach there, something like:

<extension point="org.eclipse.ui.actionSets">
  <actionSet label="Java Coding" visible="true" id="org.eclipse.jdt.ui.CodingActionSet2">
     <menu label="&amp;Source" path="edit" id="org.eclipse.jdt.ui.source.menu">
     </menu>
     <action class="org.acme.Action"
        id="org.acme.action"
        label="Hello World"
        menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup">
     </action>
  </actionSet>
</extension>

It did not work. So how do you add actions to the "Source" menu in the current Eclipse version?

Community
  • 1
  • 1
Stefan S.
  • 3,950
  • 5
  • 25
  • 77
  • The JDT is still using the same action sets so the answer you reference is still relevant. – greg-449 May 05 '15 at 15:15
  • @greg-449 So it's been four years and you still can't add anything to Eclipse menu's? That's not really surprising, only sad. – Stefan S. May 05 '15 at 15:20
  • That is not what I said. The action set code you show adds to the Source menu on the menu bar not the right click menu. – greg-449 May 05 '15 at 15:26
  • @greg-449 It does not anymore, at least for Eclipse 4.4.2. That's why I'm asking for help. – Stefan S. May 05 '15 at 15:32
  • Works for me I just tested it. Have you written the `org.acme.Action` class? The menu won't show up if that does not exist – greg-449 May 05 '15 at 15:32

0 Answers0