zoukankan      html  css  js  c++  java
  • RCP学习:增加菜单项

    1、增加菜单项,需要扩展org.eclipse.ui.actionSets,该扩展点的说明如下:

    This extension point is used to add menus, menu items and toolbar buttons to the common areas in the Workbench window. These contributions are collectively known as an action set and appear within the Workbench window by the user customizing a perspective.

    本扩展点是用来在工作台窗口的“常用区域”中添加菜单、菜单项以及工具条按钮。这些增加的项被称为“action set”,他们会出现在用户定义的工作台窗口位置。

    2、actionSets下创建actionSet,设置actionSet的ID。

    3、actionSet下创建menu,menu的id需要唯一,label为展示的字符串。menu下可以创建separate和groupMaker

    4、actionSet下创建action,注意action的menubarPath决定了该action在menu中的位置,action的toolbarPath决定该action在toolbar中位置(格式:menu_id/separator_name)。

    5、创建子菜单,和创建menu的流程一致,但子菜单的path应该为父菜单_id/separate_name。需要添加到子菜单的action的path属性则不需要写父菜单的separate。

        <extension
    point="org.eclipse.ui.actionSets">
    <actionSet
    label="tool"
    visible
    ="true"
    id
    ="com.anrainie.ide.workbench.actionSet">
    <menu
    id="toolmenu"
    label
    ="%Tool.title"
    >
    <separator
    name="slot1">
    </separator>
    <separator
    name="slot2">
    </separator>
    </menu>

    <menu
    id="exportdoc"
    label
    ="%Tool.exportDocumentTool"
    path
    ="toolmenu/slot1">
    <separator
    name="slot3">
    </separator>
    </menu>
    <action
    class="com.anrainie.ide.workbench.actions.ExportTrdAction"
    icon
    ="icons/trd.gif"
    id
    ="com.anrainie.ide.workbench.actions.ExportTrdAction"
    label
    ="%Tool.exportDocumentTool.Trd"
    menubarPath
    ="toolmenu/exportdoc/slot3"
    tooltip
    ="%Tool.exportDocumentTool.Trd">
    </action>
    <action
    class="com.anrainie.ide.workbench.actions.ExportTwfAction"
    icon
    ="icons/twf.gif"
    id
    ="com.anrainie.ide.workbench.actions.ExportTwfAction"
    label
    ="%Tool.exportDocumentTool.Twf"
    menubarPath
    ="toolmenu/exportdoc/slot3"
    tooltip
    ="%Tool.exportDocumentTool.Trd">
    </action>
    <action
    class="com.anrainie.ide.workbench.actions.ExportBcdAction"
    icon
    ="icons/bcd.gif"
    id
    ="com.anrainie.ide.workbench.actions.ExportBcdAction"
    label
    ="%Tool.exportDocumentTool.Bcd"
    menubarPath
    ="toolmenu/exportdoc/slot3"
    style
    ="push"
    tooltip
    ="%Tool.exportDocumentTool.Bcd">
    </action>
    <action
    class="com.anrainie.ide.workbench.actions.ExportTcdAction"
    icon
    ="icons/tcd.gif"
    id
    ="com.anrainie.ide.workbench.actions.ExportTcdAction"
    label
    ="%Tool.exportDocumentTool.Tcd"
    menubarPath
    ="toolmenu/exportdoc/slot3"
    style
    ="push"
    tooltip
    ="%Tool.exportDocumentTool.Bcd">
    </action>

    </actionSet>

    这是一份相对完整的,包含多级菜单的actionSet。



  • 相关阅读:
    第一次设计作业
    项目选题报告(团队)
    第二次结队作业
    团队第一次作业
    原型设计(结对第一次)
    第二次作业——个人项目实战
    对于软件工程专业的思考
    电场与磁场
    透明层上的层或数字不透明
    Visiual Studio2012 CLR20r3问题
  • 原文地址:https://www.cnblogs.com/anrainie/p/2383867.html
Copyright © 2011-2022 走看看