RCP开发中,点位符的巧妙运用

step1:我们可以在继承自ActionBarAdvisor的ApplicationActionBarAdvisor类中填充menubar和toolbar方法中,加入一些点位符。

eg:
@Override
	protected final void fillMenuBar(final IMenuManager menuBar) {
		// Add File menu to menu bar
		// File menu
		MenuManager fileMenu = new MenuManager("&File",
				IWorkbenchActionConstants.M_FILE);
		fileMenu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));//点位符
		fileMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
		fileMenu.add(preferencesAction);
		fileMenu.add(new Separator());
		fileMenu.add(exitAction);
		fileMenu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
		menuBar.add(fileMenu);
	}

		@Override
	protected final void fillCoolBar(final ICoolBarManager coolBar) {
		coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_APP));
		// Application created group
		IToolBarManager appToolBar = new ToolBarManager(coolBar.getStyle());
		appToolBar.add(new Separator(IWorkbenchActionConstants.NEW_GROUP));//点位符
		appToolBar.add(dbTestAction);
		/*
		 * Add an Enter Password action to coolbar if user hasn't stored
		 * password in Preferences.
		 */
		if (!KomoPlugin.getDefault().getPreferenceStore().getBoolean(
				PreferenceConstants.DB_STORE_PW)) {
			appToolBar.add(dbPasswordAction);
		}
		coolBar.add(new ToolBarContributionItem(appToolBar));
	}


 

step2:然后我们可以扩展org.eclipse.ui.actionSets扩展点中对menuBarPath,toolBarPath进行配置

eg:
	 <action
               label="%menu.restart.label"
               icon="icons/restart.gif"
               tooltip="%menu.restart.label"
               class="com.sysdeo.eclipse.tomcat.actions.RestartActionDelegate"
               menubarPath="file/fileStart"//放到文件菜单下的fileStart组中了
               toolbarPath="Normal/additions"//Normal是toolBar的标准标识符
               id="com.sysdeo.eclipse.tomcat.restart">
      </action>


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值