Teamcenter菜单栏开发

 菜单分为主菜单,上下文菜单,视图菜单

 主菜单扩展:

<extension point="org.eclipse.ui.menus">

      <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">

        <menu label="测试菜单" id="ceshi">

            <command

                  icon="icon/alignmiddle.png"

                  commandId="com.service.handlers.handleone">

             </command>

        </menu>

        </menuContribution>

        <menuContribution locationURI="menu:ceshi">

<menu label="菜单一">

        icon="icon/alignmiddle.png"

        commandId="com.service.handlers.handleone">

</command>

        icon="icon/alignmiddle.png"

        commandId="com.service.handlers.handleone">

</command>

</menu>

</menuContribution>

<menuContribution locationURI="menu:ceshi">

<menu label="菜单二">

<command

        icon="icon/alignmiddle.png"

        commandId="com.service.handlers.handleone">

</command>

<command

        icon="icon/alignmiddle.png"

        commandId="com.service.handlers.handleone">

</command>

</menu>

</menuContribution>

  </extension>


上下文菜单扩展:


<extension

        point="org.eclipse.ui.menus">

      <menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">

        <menu label="上下文菜单" id="shang">

              <command

          icon="icon/alignmiddle.png"

              commandId="com.service.handlers.handleone">

        </command>

          <command

          icon="icon/alignmiddle.png"

              commandId="com.service.handlers.handleone">

        </command>

        <command

          icon="icon/alignmiddle.png"

              commandId="com.service.handlers.handleone">

        </command>

        </menu>

        </menuContribution>

  </extension>

效果如下:


整个的plugin.xml文件内容如下:


<?xml version="1.0" encoding="UTF-8"?>

<?eclipse version="3.4"?>

<plugin>

  <extension

        point="org.eclipse.ui.commands">

          <command

            icon="icon/alignmiddle.png"

      id="com.service.handlers.handleone"

      name="子菜单一"/>

  </extension>

  <extension

        point="org.eclipse.ui.handlers">

        <handler

            class="com.service.handlers.handleone"

            commandId="com.service.handlers.handleone">

        </handler>

  </extension>


  <extension

        point="org.eclipse.ui.menus">

      <menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">

        <menu label="上下文菜单" id="shang">

              <command

          icon="icon/alignmiddle.png"

              commandId="com.service.handlers.handleone">

        </command>

          <command

          icon="icon/alignmiddle.png"

              commandId="com.service.handlers.handleone">

        </command>

        <command

          icon="icon/alignmiddle.png"

              commandId="com.service.handlers.handleone">

        </command>

        </menu>

        </menuContribution>

  </extension>


    <extension

        point="org.eclipse.ui.menus">

      <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">

        <menu label="测试菜单" id="ceshi">

            <command

                  icon="icon/alignmiddle.png"

                  commandId="com.service.handlers.handleone">

</command>

        </menu>

        </menuContribution>


        <menuContribution locationURI="menu:ceshi">

<menu label="菜单一">

<command

        icon="icon/alignmiddle.png"

        commandId="com.service.handlers.handleone">

</command>

<command

        icon="icon/alignmiddle.png"

        commandId="com.service.handlers.handleone">

</command>

</menu>

</menuContribution>

<menuContribution locationURI="menu:ceshi">

<menu label="菜单二">

<command

        icon="icon/alignmiddle.png"

        commandId="com.service.handlers.handleone">

</command>

<command

        icon="icon/alignmiddle.png"

        commandId="com.service.handlers.handleone">

</command>

</menu>

</menuContribution>

  </extension>

</plugin>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容