如何在E4中使用Eclipse 3.x视图?

时间:2015-05-07 05:45:18

标签: java eclipse e4 eclipse-pde

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

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

我正在使用Eclipse Luna(4.4.2)并安装了E4 Tools (0.17)。 我已经创建了一个新的Eclipse 4应用程序,并使用Import 3x添加到Application.e4xmi公共资源导航器(Project Explorer)作为共享部件 - >以兼容性视图查看。然后我添加了一个引用共享部分的占位符。我已将所有必要的插件添加到产品的依赖项中。我还添加了兼容性插件。

但是,当我启动该应用程序时,我在InjectionException获得了InjectorImpl#internalMake()#331,这只是:

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

调试unresolved()让我转到以下几点(InjectorImpl#489):

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

desiredClassorg.eclipse.ui.internal.ViewReference类。 然后函数返回1,导致继续大写和异常。 stacktrace是以下(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)
...

2 个答案:

答案 0 :(得分:2)

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

  1. Eclipse 3.5或更新
  2. 创建一个Ecliplse-Plugin
  3. 勾选将为用户界面做出贡献
  4. 使用 Hello World RCP生成所需的扩展点
  5. Ctrl + N - > Eclipse 4 - >型号 - >新应用模型
  6. 添加扩展点
  7. Ctrl + N - >插件开发 - >产品配置
  8. 其余内容在链接教程中进行了描述。 忘记将 -clearPersistedState 添加到产品的启动选项中。因此,您将看到应用程序模型的增量。如果您要使用基于功能的产品,则应创建一个引用RCP插件的功能插件,并将其作为依赖项添加到产品中。因此,您不必像教程中所述更改运行配置。

答案 1 :(得分:-2)

从我搜索到今天,你不能在纯e4应用程序(org.eclipse.debug.ui)中使用现有的Eclipse UI插件,如org.eclipse.ui.consoleorg.eclipse.e4.ui.workbench.swt.E4Application等。因此,如果您需要使用现有的UI组件,则必须创建3.x应用程序(实现IApplication,引用ApplicationWorkbenchAdvisorPlatformUI等)。因此,截至今天,如果要使用现有的UI插件,则必须创建一个3.x RCP,它在兼容层上运行新的4.x运行时。这很简单但很难在任何地方写清楚,我不得不花一些时间搞清楚。不鼓励Eclipse RCP的介绍。