1

I have written a simple Eclipse plug-in and wanted to extend the Refactor (alt+shit+T) menu with a new item that would invoke my code.

Unfortunately, after having spent hours researching the possible solutions, I have failed.

I tried some solutions suggested online, but none worked, maybe because I'm using the latest Eclipse Luna and from what I understand the refactoring menu is (was?) defined as something called action sets, and it's apparently deprecated now.

I was able to extend the top-level popup menu using the new commands API, but that's not what I want.

I would just love to see a working example of plugin.xml that adds a custom item to the Refactor popup menu.

Just for the reference, this doesn't work:

<extension point="org.eclipse.ui.menus">
  <menuContribution locationURI="menu:org.eclipse.jdt.ui.refactoring.menu?after=typeGroup">
    <command
      commandId="mycommandid"
      label="mycommandlabel">
    </command>
  </menuContribution>
</extension>
<extension point="org.eclipse.ui.commands">
  <command
    id="mycommandid"
    name="mycommandname">
  </command>
</extension>
<extension point="org.eclipse.ui.handlers">
  <handler
    class="MyHandlerClass"
    commandId="mycommandid">
  </handler>
</extension>
siledh
  • 3,268
  • 2
  • 16
  • 29

1 Answers1

-1

Try this

<extension
         point="org.eclipse.ui.popupMenus">
      <objectContribution
            id="org.forsp.StringHelper.contribution1"
            nameFilter="*.*"
            objectClass="org.eclipse.ui.IEditorInput">
         <menu
               id="org.forsp.StringHelper.menu1"
               label="Menu"
               path="additions">
            <separator
                  name="group1">
            </separator>
         </menu>
         <action
               class="org.forsp.stringhelper.popup.actions.NewAction"
               enablesFor="1"
               id="org.forsp.StringHelper.newAction"
               label="New Action"
               menubarPath="org.forsp.StringHelper.menu1/group1">
         </action>
      </objectContribution>
   </extension>