1

i have shown different menu on the top like FILE, EDIT now i need to show the sub menu item like FIle->Edit->

i could not do this one can anybody please give me certain idea or give me the site name so i could do this one.

Dinup Kandel
  • 2,457
  • 4
  • 21
  • 38

1 Answers1

3

Use org.eclipse.ui.menus extension point. Remember, menu can have commands and menu can have menu too. This self-containment allows you to implement sub-menus.

Sample Plugin.xml

   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="eDoc.menuContribution1">
         <menu
               label="Top">
            <command
                  commandId="eDoc.command1"
                  label="Command 1"
                  style="push">
            </command>
            <command
                  commandId="eDoc.command2"
                  label="Command 2"
                  style="push">
            </command>
            <menu
                  label="Sub Menu">
               <command
                     commandId="eDoc.command3"
                     label="Sub Menu Command 1"
                     style="push">
               </command>
            </menu>
         </menu>
      </menuContribution>
   </extension>

Checkout this eclipse-rcp tutorial for more details: http://www.vogella.de/articles/EclipseRCP/article.html

Favonius
  • 13,959
  • 3
  • 55
  • 95
  • thanks a lot for the answer. but still i have difficulty to open a view when the cascaded menu item is clicked.could you please help me on this? – Dinup Kandel Apr 27 '11 at 06:41
  • @user642391: Sure. But I will need a some code to look at. Specifically, how you are trying to handle the menu item selection and your current way of accessing/opening the view. – Favonius Apr 27 '11 at 08:49
  • 1
    @user642391 Favonius' answer is correct (with regards to how you formulated your question), so you should accept it (and upvote it). As for the other part of your question, which you posted in the comments rather then in the question itself, you should check out this tutorial by Lars Vogel: http://www.vogella.de/articles/EclipseRCP/article.html#commands_menu. To programmatically show the view, see this: http://stackoverflow.com/questions/171824/programmatically-showing-a-view-from-an-eclipse-plug-in – Sandman Apr 27 '11 at 14:51
  • i am using a menulistener class to show the view as public class MenuListener implements IWorkbenchWindowActionDelegate { @Override public void run(IAction action) { IWorkbenchPage wbp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { if (action.getId().toString().equals("mnuListMem")) { wbp.showView("MemberRecordView"); } else if (action.getId().toString().equals("mnuAddMem")) { wbp.showView("MemberRegistration"); } – Dinup Kandel Apr 28 '11 at 04:28