org.eclipse.ui.menus扩展点学习

Eclipse菜单:

menu:help?after=addtions

menu:navigate?after=open.ext2

menu:window?after=newEditor

menu:file?after=open.ext

 

org.eclipse.ui.menus属性

  1.  locationURI  ----------  标识用户界面中与该菜单项关联的命令将要出现的位置。

locationURI="[scheme]:[identifier]?[argument-list]"

locationURI属性被分解为三个清晰的部分:模式(scheme)、标识符(identifier)和参数列表(argument list)

scheme标识添加项将要添加至的UI对象的类型。它可以是以下值的其中这一:

  • menu———程序主菜单或视图下拉菜单
  • popup———视图或编辑器的上下文菜单
  • toolbar———程序主工具栏或视图中的工具栏

identifier定义了将要添加至的菜单、弹出项或工具栏的唯一标识符。一些常用的标识符包括:

  • org.eclipse.ui.main.menu———Eclipse主菜单的标识符
  • org.eclipse.ui.main.toolbar———Eclipse主工具栏的标识符
  • org.eclipse.ui.popup.any———任意上下文菜单的标识符。

agrument list。参数列表由可以是"before"或"after"的布局,一个等号(“=”),以及菜单 、弹出项或工具栏的一些项的标识符组成。标识符也可以是“additions”,表示元素应当被放置于给定菜单、弹出项或工具栏的默认位置 ("="等号后面可以接着一个acitonID,这样子就布局到这个action的后面,实现分组布局)

 

实例

   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
         <toolbar
               id="cn.com.agree.ide.afa.navigation.saveToolbar">
            <command
                  commandId="org.eclipse.ui.file.save"
                  icon="icons/save_edit.gif"
                  label="Save"
                  style="push"
                  tooltip="Save">
            </command>
            <command
                  commandId="org.eclipse.ui.file.saveAll"
                  icon="icons/saveall_edit.gif"
                  label="Save All"
                  style="push"
                  tooltip="Save All">
            </command>
         </toolbar>
      </menuContribution>
      <menuContribution
            allPopups="false"
            locationURI="toolbar:org.eclipse.ui.main.toolbar?after=cn.com.agree.ide.afa.navigation.saveToolbar">
         <toolbar
               id="cn.com.agree.ide.afa.workbench.searchToolbar">
            <command
                  commandId="org.eclipse.search.ui.openSearchDialog"
                  icon="icons/search.gif"
                  label="Search"
                  style="pulldown"
                  tooltip="Search">
            </command>
         </toolbar>
      </menuContribution>
      <menuContribution
            allPopups="true"
            locationURI="menu:org.eclipse.search.ui.openSearchDialog">
         <command
               commandId="org.eclipse.search.ui.openFileSearchPage"
               icon="icons/search.gif"
               label="File Search"
               style="push"
               tooltip="File Search">
         </command>
      </menuContribution>

 

红色代码是较好的org.eclipse.ui.menus应用实例,效果图如下

 

 

快捷键

M1--------Ctrl

M2--------Shift

M3--------Alt

 

 

org.eclipse.ui.actionSets扩展点

toolbarPath指定工具栏中此操作的位置,以'/'定界路径,第一个标记表示工具栏标识(Normal表示是缺省的工具栏),第二个标记为工具栏内的命名组(也可以是工具栏上的separator,这样就能实现和org.eclipse.ui.menus整合布局),若不存在改组,则会创建。省略该选项,action将不会出现在工具栏。

posted on 2016-07-14 11:50  huadoumi  阅读(2844)  评论(0编辑  收藏  举报

导航