Showing posts with label new menu contribution to eclipse workbench. Show all posts
Showing posts with label new menu contribution to eclipse workbench. Show all posts

Friday, September 19, 2014

How to contribute a new menu to the workbench ?

Eclipse exposed a mechansim to contribute a new menu through "org.eclipse.ui.menus" extension and locationURI.
Requried extension: org.eclipse.ui.menus
LocationURI:  menu:org.eclipse.ui.main.menu

Example:
Below example will contribute a new "Cloud" menu to the eclipse workbench, and this will contain a "Upload" menu item.

 <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="menu:org.eclipse.ui.main.menu">
         <menu
               id="com.kk.menus.cloud"
               label="Cloud">
             <command
                  commandId="com.kk.command.upload"
                  style="push">
            </command>
          </menu>
      </menuContribution>
</extension>

Command contribution to upload action:

<extension
         point="org.eclipse.ui.commands">
  <command
            id="com.kk.command.upload"
            name="Upload">
      </command>
</extension>

Handler contribution to upload action:

  <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="com.kk.menus.handlers.UploadHandler"
            commandId="com.kk.command.upload">
      </handler>
   </extension>