How to use Eclipse 3.x views in E4?

浪子不回头ぞ 提交于 2020-01-02 09:59:47

问题


I am experienced with Eclipse 3.x development and now want to develop an E4 application. Therefor I tested a simple example in order to get started with the new things.

I was following this tutorial step by step but it results in the same error. However, he is not getting those errors.

I'm using Eclipse Luna (4.4.2) and installed the E4 Tools (0.17). I've created a new Eclipse 4 Application and added to the Application.e4xmi the Common Resource Navigator (Project Explorer) as Shared Part using Import 3x -> View as CompatibilityView. I then added a Placeholder which references the shared part. I have added all necessary plugins to the product's dependencies. I also have added the compatibility plugins.

However, when I start the application I get an InjectionException at InjectorImpl#internalMake()#331 which simply is:

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

Debugging unresolved() let me to the following point (InjectorImpl#489):

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

Where the desiredClass is class org.eclipse.ui.internal.ViewReference. Then the function returns 1 which leads to continue in the upper case and the exception. The stacktrace is the following (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)
...

回答1:


To solve this problem, I had to follow this awesome tutorial. As @greg-449 already mentioned you've to use an 3.x RCP and put an e4 aware product on top of it. Then the compatibility layer will be initialized. Thus, you have to do the following (the tutorial describes it in detail):

  1. create an Ecliplse-Plugin which for Eclipse 3.5 or newer
  2. Tick Will make contributions to the UI
  3. Use the Hello World RCP to generate the required extension points
  4. Ctrl+N -> Eclipse 4 -> Model -> New Application Model
  5. Add an extension point
  6. Ctrl+N -> Plug-in Development -> Product Configuration

The rest is described in the linked tutorial. Do not forget to add -clearPersistedState to the Launching options of the product. So you will see your deltas of your application model. If you are going to use a feature based product you should create a feature plugin which references your RCP plugin and add it as dependency to the product. Thus, you don't have to change the run configuration as described in the tutorial.




回答2:


From what I have searched till today, you cannot use existing Eclipse UI plugins like org.eclipse.debug.ui, org.eclipse.ui.console, etc in a pure e4 application (org.eclipse.e4.ui.workbench.swt.E4Application). So if you need to use existing UI components you have to create a 3.x application (implements IApplication, references ApplicationWorkbenchAdvisor, PlatformUI etc). So as of today if you want to use existing UI plugins you have to create a 3.x RCP which runs over the compatibility layer with the new 4.x runtime. This is so simple but hardly written clearly anywhere and I had to spend some time figuring it out. Discouraging introduction to Eclipse RCP.



来源:https://stackoverflow.com/questions/30092827/how-to-use-eclipse-3-x-views-in-e4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!