简体   繁体   English

如何在Eclipse插件的菜单上创建子菜单?

[英]How to create submenus on a menu in an Eclipse plugin?

I want to to create a submenu in my Eclipse plugin. 我想在Eclipse插件中创建一个子菜单。

Below is my plugin.xml: 以下是我的plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
   <?eclipse version="3.4"?>
      <plugin>
       <extension
               point="org.eclipse.ui.commands">
           <category
              name="Sample Category"
              id="com.atos.ssc.portal.plugin.commands.category">
           </category>
           <command
              name="Run CC Portal"
              categoryId="com.atos.ssc.portal.plugin.commands.category"
              id="com.atos.ssc.portal.plugin.commands.sampleCommand">
           </command>
           <command
              name="CC Home"
              categoryId="com.atos.ssc.portal.plugin.commands.category"
              id="com.atos.ssc.portal.plugin.commands.ccHomeCommand">
            </command>
            <command
               name="SSC ClearCase Details Information"
               categoryId="com.atos.ssc.portal.plugin.commands.category"
               id="com.atos.ssc.portal.plugin.commands.ccUserInfoComand">
             </command>
             <command
               name="SSC ClearCase 8 Details Information"
                    categoryId="com.atos.ssc.portal.plugin.commands.category"
                    id="com.atos.ssc.portal.plugin.commands.ccUser8InfoComand">
              </command>
         </extension>
         <extension
            point="org.eclipse.ui.handlers">
           <handler
                commandId="com.atos.ssc.portal.plugin.commands.sampleCommand"
                class="com.atos.ssc.portal.plugin.handlers.SampleHandler">
           </handler>
           <handler
                 commandId="com.atos.ssc.portal.plugin.commands.ccHomeCommand"
                 class="com.atos.ssc.portal.plugin.handlers.CCHomeHandler">
           </handler>
           <handler
                commandId="com.atos.ssc.portal.plugin.commands.ccUserInfoComand"
        class="com.atos.ssc.portal.plugin.handlers.SSCClearCaseDetailInfoHandler">
           </handler>
          <handler
             commandId="com.atos.ssc.portal.plugin.commands.ccUser8InfoComand"
        class="com.atos.ssc.portal.plugin.handlers.SSCClearCase8DetailInfoHandler">
         </handler>
   </extension>
   <extension
     point="org.eclipse.ui.bindings">
     <key
        commandId="com.atos.ssc.portal.plugin.commands.sampleCommand"
        contextId="org.eclipse.ui.contexts.window"
        sequence="M1+6"
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
  </key>
  <key
        commandId="com.atos.ssc.portal.plugin.commands.ccHomeCommand"
        contextId="org.eclipse.ui.contexts.window"
        sequence="M1+6"
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
  </key>
  <key
        commandId="com.atos.ssc.portal.plugin.commands.ccUserInfoComand"
        contextId="org.eclipse.ui.contexts.window"
        sequence="M1+6"
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
  </key>
  <key
        commandId="com.atos.ssc.portal.plugin.commands.ccUser8InfoComand"
        contextId="org.eclipse.ui.contexts.window"
        sequence="M1+6"
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
  </key>
   </extension>
   <extension
     point="org.eclipse.ui.menus">
  <menuContribution
         allPopups="true"
        locationURI="menu:org.eclipse.ui.main.menu?after=additions">
     <menu
           label="SSC CC Portal"
           mnemonic="S"
           id="com.atos.ssc.portal.plugin.menus.sampleMenu">
        <command
              commandId="com.atos.ssc.portal.plugin.commands.sampleCommand"
              style="push">
        </command>
     </menu>
  </menuContribution>      
    <menuContribution
        locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
     <toolbar
           id="com.atos.ssc.portal.plugin.toolbars.sampleToolbar">
        <command
              commandId="com.atos.ssc.portal.plugin.commands.sampleCommand"
              icon="icons/sample.gif"
              tooltip="Run CC Portal"
              id="com.atos.ssc.portal.plugin.toolbars.sampleCommand">
        </command>
     </toolbar>
  </menuContribution>
 </extension>
</plugin>

With This I am able to create menus as below in particular order as 通过此功能,我可以按以下特定顺序创建菜单,如下所示:

Run CC Portal 运行CC Portal

CC Home CC主页

Clearcase Detail Information 明箱详细信息

Clearcase Detail 8 Information Clearcase详细信息8信息

How ever I want CC Home, SSC ClearCase Detail Information and SSC Clearcase 8 Detail Information under Run CC Portal menu.. Kindly help..I an new to eclipse plugin. 我要如何在“运行CC Portal”菜单下找到CC Home,SSC ClearCase详细信息和SSC Clearcase 8详细信息。。请帮助。我是eclipse插件的新手。

You need to have commands under the menu item: 您需要在菜单项下具有命令:

   <menuContribution
        allPopups="true"
        locationURI="menu:org.eclipse.ui.main.menu?after=additions">
        <menu label="Run CC Portal">
        <command
              commandId="com.atos.ssc.portal.plugin.commands.ccHomeCommand"
              style="push">
        </command>
        <command
              commandId="com.atos.ssc.portal.plugin.commands.ccUserInfoComand"
              style="push">
        </command>
        <command
              commandId="com.atos.ssc.portal.plugin.commands.ccUser8InfoComand"
              style="push">
        </command>
     </menu>
  </menuContribution>      

Also see here for contributing to the toolbar 另请参阅此处对工具栏的贡献

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM