插件开发中的点位符

本文介绍Eclipse插件开发中点位符的概念及其使用方法。通过实例展示了如何在ActionBarAdvisor中添加点位符,并在org.eclipse.ui.actionSets中配置具体的action位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

点位符,又叫插入点,是插件开中比较常见的一个概念。通常用在actionSets扩展点中。

我们可以预先在顶级的工具栏和工具栏中添加一些点位符。具体的action放置在哪,交由其它插件在org.eclipse.ui.actionSets中进行配置。

例如:

我们可以在继承自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));
 }

 然后我们可以扩展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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值