1

I am developing a plugin for Eclipse Luna using the SDK version 4.4.2. I would like to add a command to all instances of the Source menu (on the menu bar, in the context-menu, and in the popup resulting from Alt-Shift-S. The following code successfully adds the item to the context-menu:

 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
    <extension point="org.eclipse.ui.commands">
        <command id="org.foobar.runMyCommand"
             name="Run My Command...">
         </command>
     </extension>

     <extension point="org.eclipse.ui.menus">
        <menuContribution locationURI="popup:org.eclipse.jdt.ui.source.menu?endof=codeGroup">
            <command commandId="org.foobar.runMyCommand" label="Run My Command...">
            </command>
        </menuContribution>
     </extension>

     <extension point="org.eclipse.ui.handlers">
         <handler commandId="org.foobar.runMyCommand"
             class="org.foobar.MyPlugin">
         </handler>
     </extension>
 </plugin>

The item is, however, missing from both the Source-menu from the menu-bar and the Source-popup which one gets with Alt-Shift-S. How does one add this item to the remaining two menus?

user2615350
  • 263
  • 2
  • 13

1 Answers1

0

You can either use org.eclipse.popupmenus by creating an object contribution, then an action where the id of the source menu is passed to the menubarPath property of the action.

You can also refer to this:

Trying to put new "Generate" option under Source menu in Eclipse

If you want to avoid org.eclipse.popupmenus which is a depreciated extension in new Luna update.

Community
  • 1
  • 1
John Smith
  • 777
  • 2
  • 14
  • 37
  • Thanks for your answer. The solution in the link you gave is almost identical to my own. The only substantive differences are that it has an additional id attribute on the command element and that the handlers extension appears before the menus extension. I tried applying both to see whether they made a difference and there was none.Can you show me a specific example of the use of org.eclipse.popupmenus? – user2615350 Apr 10 '15 at 18:57