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。



  • 相关阅读:
    UFLDL深度学习笔记 (四)用于分类的深度网络
    UFLDL深度学习笔记 (三)无监督特征学习
    UFLDL深度学习笔记 (二)SoftMax 回归(矩阵化推导)
    UFLDL深度学习笔记 (一)反向传播与稀疏自编码
    【2016内推】计算机找工作面经
    关于最优化中的若干问题
    关于extern "C" 的用法
    浅谈多核CPU、多线程、多进程
    并发与并行
    多进程与多线程
  • 原文地址:https://www.cnblogs.com/anrainie/p/2383867.html
Copyright © 2011-2022 走看看