Search code examples
eclipse-plugineclipse-rcp

Change order of new file menu items Eclipse rcp


I am implementing now RCP application and I need to add custom menu item to File -> New submenu and I did that by two ways

  • By plugin.xml using

menuContribution locationURI="menu:new?after=new"

  • By Implaemanting ContributionFactory in Java code

My Problem is that I can't insert the menu item insert the additions also after the project item or after package item. I tried to get the locationURI of the inner item by the plugin menu spy but could only this result get " menu:new?after=additions" and I tried in the java code but I need to get the list of items of new file menu but I get only this useless interface IContributionRoot any solution in XML or in java code without using application adviser?

enter image description here


Solution

  • The only supported way to add to the File > New menu is by defining a 'New Wizard' using the org.eclipse.ui.newWizards extension point. Your new wizard will appear in the 'Other' part of the menu.

    You can make your wizard also appear in the top part of the menu for a particular perspective by using the org.eclipse.ui.perspectiveExtensions extension point to add a newWizardShortcut. You may need to reset the perspective or customize the perspective to get this to work.

    <extension point="org.eclipse.ui.perspectiveExtensions"> 
        <perspectiveExtension 
            targetID="org.eclipse.ui.resourcePerspective"> 
            <newWizardShortcut id="org.eclipse.jdt.ui.wizards.NewProjectCreationWizard"/> 
        </perspectiveExtension> 
    </extension>