【问题标题】:How to use Eclipse 3.x views in E4?如何在 E4 中使用 Eclipse 3.x 视图?
【发布时间】:2015-05-07 05:45:18
【问题描述】:

我有 Eclipse 3.x 开发经验,现在想开发一个 E4 应用程序。因此,我测试了一个简单的示例,以便开始使用新事物。

我一步一步关注this tutorial,但它导致了同样的错误。但是,他没有收到这些错误。

我正在使用 Eclipse Luna (4.4.2) 并安装了 E4 Tools (0.17)。 我创建了一个新的 Eclipse 4 应用程序,并使用 Import 3x -> View as CompatibilityView 将 Common Resource Navigator (Project Explorer) 作为 Shared Part 添加到 Application.e4xmi。然后我添加了一个引用共享部分的 Placeholder。我已将所有必要的插件添加到产品的依赖项中。我还添加了兼容性插件。

但是,当我启动应用程序时,我会在 InjectorImpl#internalMake()#331 收到一个 InjectionException,这就是:

if (unresolved(actualArgs) != -1) continue;

调试unresolved() 让我进入以下几点(InjectorImpl#489):

Creatable creatableAnnotation = desiredClass.getAnnotation(Creatable.class);

desiredClass 是类org.eclipse.ui.internal.ViewReference。 然后该函数返回 1 导致继续大写和异常。堆栈跟踪如下(full here):

!ENTRY org.eclipse.e4.ui.workbench 4 0 2015-05-06 13:00:05.899
!MESSAGE Unable to create class 'org.eclipse.ui.internal.e4.compatibility.CompatibilityView' from bundle '96'
!STACK 0
org.eclipse.e4.core.di.InjectionException: Could not find satisfiable constructor in org.eclipse.ui.internal.e4.compatibility.CompatibilityView
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:346)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
...

【问题讨论】:

  • 这看起来像here 的讨论,它说您只能通过初始化所有 3.x 兼容模式来使用它。 3.x 视图需要很多纯粹的 e4 应用程序中没有的东西。
  • 我确实读过这个。 Eclipse 工作人员 (P. Webster) 的唯一回答是 是的,您需要整个 4.2 Workbench(以及它的所有服务)才能正确实例化 3.x IViewPart。 好吧,我添加了一个依赖项org.eclipse.ui.workbench 及其依赖项。线程中的人无法解决此问题,因此未发表评论。
  • 是的,但这不会初始化任何东西。据我所知,唯一的方法是使用传统的 3.x RCP
  • 我找到的所有教程都在做我所做的并且对他们有用。我安装的 E4 工具是针对 Eclipse 4.3 SDK 构建的。但是没有最近的。 tutorial of Lars Vogel (vogella) 也已经过时了。
  • Lars 提到的兼容层是在你使用 3.x RCP 时初始化的,这在 4.4 中没有改变。

标签: java eclipse e4 eclipse-pde


【解决方案1】:

为了解决这个问题,我不得不关注this awesome tutorial。正如@greg-449 已经提到的,您必须使用 3.x RCP 并在其上放置 e4 感知 产品。然后将初始化兼容层。因此,您必须执行以下操作(本教程对此进行了详细描述):

  1. 为 Eclipse 3.5 或更新版本创建一个 Ecliplse 插件
  2. 勾选将为 UI 做出贡献
  3. 使用 Hello World RCP 生成所需的扩展点
  4. Ctrl+N -> Eclipse 4 -> 模型 -> 新应用程序模型
  5. 添加扩展点
  6. Ctrl+N -> 插件开发 -> 产品配置

其余部分在链接教程中进行了描述。 不要忘记将 -clearPersistedState 添加到产品的启动选项中。因此,您将看到您的应用程序模型的增量。如果您要使用基于功能的产品,您应该创建一个引用您的 RCP 插件的功能插件并将其添加为产品的依赖项。因此,您不必按照教程中的说明更改运行配置。

【讨论】:

    【解决方案2】:

    从我搜索到今天的内容,您不能在纯 e4 应用程序 (org.eclipse.e4.ui.workbench.swt.E4Application) 中使用现有的 Eclipse UI 插件,例如 org.eclipse.debug.ui、org.eclipse.ui.console 等。因此,如果您需要使用现有的 UI 组件,您必须创建一个 3.x 应用程序(实现 IApplication、引用 ApplicationWorkbenchAdvisor、PlatformUI 等)。因此,从今天开始,如果您想使用现有的 UI 插件,您必须创建一个 3.x RCP,它在具有新的 4.x 运行时的兼容层上运行。这很简单,但在任何地方都很难写清楚,我不得不花一些时间弄清楚。令人沮丧的 Eclipse RCP 介绍。

    【讨论】:

      猜你喜欢
      • 2016-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-12
      • 1970-01-01
      • 2019-09-14
      • 2015-12-19
      • 1970-01-01
      相关资源
      最近更新 更多