farkas
farkas

Reputation: 307

Eclipse RCP: How to add a new element to a default Java dropdown menu in the toolbar(New Java Class)

I'm making an RCP application. I need to change the 'New Java Class' dropdown menu:

Dropdown menu

to have an extra element (it is used to create a new custom application).

Also I need to change the default 'New Java Class' button to this new custom application element.

I couldn't find the required IDs to extend this dropdown menu in the plugin.xml. My current solution is to create a completely new menuContribution in the toolbar and somehow hide the old one. But I think it should be possible to add a new command to the already existing one.

Upvotes: 1

Views: 430

Answers (1)

greg-449
greg-449

Reputation: 111142

That drop down menu is implemented by the org.eclipse.jdt.internal.ui.wizards.NewTypeDropDownAction class.

The code reads through the list of New Wizards declared using the org.eclipse.ui.newWizards extension point. Only new wizards which declare the class using a child element which itself includes a parameter child element with a value of javatype are used.

This is the 'Interface' wizard declaration using this format:

<wizard
    name="%NewJavaInterface.label"
    icon="$nl$/icons/full/etool16/newint_wiz.png"
    category="org.eclipse.jdt.ui.java"
    id="org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard">
  <class class="org.eclipse.jdt.internal.ui.wizards.NewInterfaceCreationWizard">
     <parameter name="javatype" value="true"/>
  </class>
  <description>
     %NewJavaInterface.description
  </description>
   <keywordReference id="org.eclipse.jdt.ui.wizards.java"/>
</wizard>

The

  <class class="org.eclipse.jdt.internal.ui.wizards.NewInterfaceCreationWizard">
     <parameter name="javatype" value="true"/>
  </class>

section is the part that the drop down is looking for.

This format doesn't actually seem to be documented in the Eclipse help.

Upvotes: 1

Related Questions