插件开发或RCP中如何通过actions扩展点配置工具栏按钮(插入到指定的ToolBarManger中)

 在插件或RCP开发中,我们通常使用org.eclipse.ui.actions扩展点配置菜单和工具按钮。
eg:
   <extension
         point="org.eclipse.ui.actionSets">
      <actionSet
            id="test.actionSet"
            label="Sample Action Set"
            visible="true">
         <action
               class="test.actions.SampleAction"
               icon="icons/sample.gif"
               id="test.actions.SampleAction"
               label="&amp;Sample Action"
               menubarPath="sampleMenu/sampleGroup"
               toolbarPath="start/additions"//重点看这里,start是在代码中指定的ToolBarManager的id,additions是插入点
               tooltip="Hello, Eclipse world">
         </action>
      </actionSet>
   </extension>
  
  
   我们这次主要看看toolBarPath。这个路径是以工具(id)开头,以"/"分隔的路径。
   在RCP开发中,我们可能会先定义一些ToolBarManager,同时在ToolBarManger中添加一些插入点(InsertPoint)。
   然后在actionSets扩展点中配置toolbarPath(形如toolbarMangerId/insertpointId)。
  
   我们在RCP中可能会定义成这个样子:
   IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
        toolbar.add(openViewAction);
        toolbar.add(messagePopupAction);
        //ToolBar中定义一个插入点,GroupMarker与Separator的区别在于,后者分加一条分隔线,前者不会
        toolbar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        coolBar.add(new ToolBarContributionItem(toolbar,"start"));//将ToolBarManager加到CoolBar中,并以"start"进行标志
  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值