【问题标题】:how do I add a RCP project to eclipse menu?如何将 RCP 项目添加到 Eclipse 菜单?
【发布时间】:2015-04-07 18:49:22
【问题描述】:

我有一个 Eclipse RCP 应用程序(已经构建)。我需要将它与 eclipse UI 本身集成。我的意思是——我想在 Eclipse 用户界面中添加一个菜单选项,并在菜单中添加一个命令,单击该命令会运行应用程序。 类似于eclipse菜单中的查找和替换选项

知道如何做到这一点吗?

我还希望将应用程序与 eclipse 捆绑在一起

【问题讨论】:

  • 因此您编写了一个安装在 Eclipse 中的 Eclipse 插件并添加菜单项来运行应用程序。哪一部分是问题?
  • 菜单项需要添加到eclipse菜单本身而不是应用程序的菜单栏
  • 是的,所以你编写了一个安装在 Eclipse 中而不是你的 RCP 中的插件。
  • 我的意思是每次打开 Eclipse 时——该菜单选项应该与其他常用菜单选项一起出现,如文件、编辑、导航等
  • 对不起,我是新手...您能解释一下如何编写一个安装后可以执行此操作的插件或任何可以帮助我的链接吗?

标签: eclipse-plugin rcp


【解决方案1】:

编写一个您安装到 Eclipse(而不是您的 RCP)的插件。

插件可以使用org.eclipse.ui.menus扩展点添加到File菜单。例如:

 <extension
     point="org.eclipse.ui.menus">
   <menuContribution
        locationURI="menu:file?after=open.ext">
     <command
           commandId="my.command.id"
           id="my.menu.id"
           style="push">
     </command>
  </menuContribution>

使用org.eclipse.ui.commands 扩展点来定义命令

<extension
   point="org.eclipse.ui.commands">
  <command
        id="my.commnd.id"
        description="Description text"
        name="Name">
  </command>

使用org.eclipse.ui.handlers 扩展点为命令定义处理程序

<extension
     point="org.eclipse.ui.handlers">
  <handler
        class="package.CommandHandler"
        commandId="my.command.id">
  </handler>

处理程序包含运行 RCP 的代码:

public class CommandHandler extends AbstractHandler
{
  public Object execute(ExecutionEvent event) throws ExecutionException
  {
    // TODO launch your RCP

    return null;
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-09
    • 1970-01-01
    • 1970-01-01
    • 2012-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    相关资源
    最近更新 更多