Search code examples
eclipseeclipse-pluginidecontextmenuproject-explorer

Add item above "Project" in eclipse project explorer contextmenu


I am working on an eclipse based customized IDE for our development environment.
In my new perspective I have included a "Project Explorer" and in that I am able to add commands in the context menu, but when I include a new Wizard (A project Wizard) in the "new" type it is shown beneath the "Project" wizard

The CARD file should be above "Project..."

and I'd want it to be above it.

"Plugin-in Project" comes before "Project..."

The plugin.xml for this snippet is attached

<extension point="org.eclipse.ui.navigator.navigatorContent">
      <commonWizard
              type="new"
              wizardId="dev.xxx.wizard.XXXProject">
              <enablement></enablement>
      </commonWizard>
</extension>

It is being shown when I access New from Toolbar or MenuBar (after I added it as a shortcut in layout, in an implementation of IPerspectiveFactory

enter image description here

but for some reason it is not showing up under "Project Explorer". But its working fine under "Navigator View"

enter image description here


Solution

  • Use the org.eclipse.ui.perspectiveExtensions extension point to define a newWizardShortcut entry for your new project wizard.

    Something like:

    <extension
         point="org.eclipse.ui.perspectiveExtensions">
      <perspectiveExtension
            targetID="org.eclipse.jdt.ui.JavaPerspective">
         <newWizardShortcut
               id="org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard">
         </newWizardShortcut>
      </perspectiveExtension>
    

    You might have to do a 'reset perspective' to get the change picked up.

    You can also set up these shortcuts in the 'Window > Customize Perspective' dialog in the 'Shortcuts' tab.