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。



  • 相关阅读:
    Package manager has died异常PackageInfo 引发 Crash
    Android Bitmap变迁与原理解析(4.x-8.x)
    Rxjava2不能再发射Null了
    [转]C语言的int最值问题,以及原码反码及补码
    自定义gradle插件
    ReentrantLock(重入锁)的使用
    HashSet、TreeSet和LinkedHashSet分别基于HashMap、TreeMap和LinkedHashMap
    Java类加载双亲委托模式优点
    为什么HTTPS比HTTP安全,以及两者的优缺点
    android4.4之后的HttpUrlConnection的实现是基于okhttp
  • 原文地址:https://www.cnblogs.com/anrainie/p/2383867.html
Copyright © 2011-2022 走看看