Running Eclipse RCP applications in the e4 compatiblity layer

Eclipse 4.x allow to run Eclipse RCP applications and Eclipse plug-ins which are created based on Eclipse 3.x.

This is valuable as it allows you to reuse your existing code base and evaluate advantages as the live model and CSS based styling. Unfortunately concepts like dependency for views do not work with the compatibility layer.

To run your Eclipse 3.x RCP application on e4 you only have to add a few plug-ins to your product.

org.eclipse.e4.ui.workbench.addons.swt
org.eclipse.equinox.ds
org.eclipse.equinox.event
org.eclipse.equinox.util
org.eclipse.platform
org.eclipse.ui.forms
org.eclipse.ui.intro

After this change you should be able to start your existing application based on e4.

Related bugs:

Quick access should not be hard-coded
[Compatibility] All views now have view menus
Compatibility Layer – Getting services via getViewSite().getServices()
Compatibility Layer – Using @Inject in plugin.xml based contribution

I hope this help. I also updated my Eclipse 4.2 Tutorial.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Eclipse. Bookmark the permalink.

9 Responses to Running Eclipse RCP applications in the e4 compatiblity layer

  1. Daniel says:

    Hm… I gave it a try with 4.1.1 and our RCP based platform – the result was, as expected, not very useful:

    I still got that stupid Exceptions:
    org.osgi.framework.BundleException: Der Activator org.eclipse.ui.internal.forms.FormsPlugin für Bundle org.eclipse.ui.forms ist ungültig
    […]
    Caused by: java.lang.ClassNotFoundException: org.eclipse.ui.plugin.AbstractUIPlugin
    […]

    Oh – and yes: I checked and re-checked… All necesarry plugins are available (the app is running on 3.7 using the available product) and I added the ones you pointed out (except for the last two, they were already in use by the app since I like forms very much and I played a little bit around with Intros a while ago).

    This is kind of pity since I would like to switch, but until know I don’t see how…

    Greetings,
    Daniel

  2. Lars Vogel says:

    You should try the Eclipse 4.2m2 build. This should work.

  3. Daniel says:

    Thumps up!

    There are still many issues, but at least it fires up.

    I still get ominous NullPointerExceptions like

    !ENTRY org.eclipse.e4.ui.workbench 4 0 2011-10-11 16:03:08.214
    !MESSAGE Unable to create class ‘org.eclipse.ui.internal.StandardTrim’ from bundle ‘1153’
    !STACK 0
    org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:838)
    at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:110)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:317)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:252)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:177)
    […]

    Caused by: java.lang.NullPointerException
    at org.eclipse.ui.internal.StandardTrim.createStatusLine(StandardTrim.java:81)
    at org.eclipse.ui.internal.StandardTrim.createWidget(StandardTrim.java:39)

    causing (at least I think and hope that must be the reason) the app to have a funny look

    (if you want, see it here http://imageshack.us/photo/my-images/846/eclipsesdk40005errorsta.png/ )

    Thank you anyway Lars – no matter if you directly address any advises or via your tutorials, you are a great help to everyone stugling with Eclipse RCP!!!

    Daniel

  4. Lars Vogel says:

    @Daniel: This might be a bug. Can you please open one for the e4 UI component?

    And thanks for the feedback. :-)

  5. Daniel says:

    Oh shame on me! I don’t know what exactly caused it, but I simply needed to clean my platforms workspace location et voila…

    http://imageshack.us/photo/my-images/819/eclipsesdk40006.png/

    There is only a minor glitch: When the app is freshly started, the buttons for the editor area are a little out of bounds.
    And I can’t access the prefereces under “General > Appearance” for some reason unknown to me. All I get is another NPE

    !ENTRY org.eclipse.jface 4 2 2011-10-11 16:39:01.415
    !MESSAGE Beim Aufrufen des Codes aus dem Plug-in “org.eclipse.jface” sind Fehler aufgetreten.
    !STACK 0
    java.lang.NullPointerException
    at org.eclipse.ui.internal.dialogs.ViewsPreferencePage.createContents(ViewsPreferencePage.java:69)
    at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.java:232)
    at org.eclipse.jface.preference.PreferenceDialog.createPageControl(PreferenceDialog.java:1501)
    at org.eclipse.jface.preference.PreferenceDialog$14.run(PreferenceDialog.java:1258)

    Maybe this one is a REAL bug and not caused by my stupidity…

    Daniel

  6. Daniel says:

    Additonally to your Plugins I think a slightly modified version of the org.eclipse.platform’s LegacyIDE.e4xmi is advisable (the name “Eclispe SDK 4.0″ might not be everyones darling) – the changes within the plugin.xml for the procuct are easiely done…

    […]

    Daniel

  7. Tom Schindl says:

    Well I just wanted to stated that DI can be used in 3.x as well using the e4 bridge! See https://github.com/tomsontom/iconview for code examples

  8. Daniel says:

    Hi Tom, I think I remember your blog post about that. I’ve no intention of using the DI stuff in my old plugins – I don’t want to re-create them, although sometimes I’ve the feeling, that it would be not that bad of an idea…
    I think, if I realy find the moment to get into that part of e4, than I can make the switch complete (port the current plugin based platform and its plugins to e4, create new ones directly using e4 and its DI) – I guess no one in my company will argue with me about that.

    What I’m currently more interested in is porting the application to RAP. In general this is not really that complicated – I already had the platform up and running and integrated one of my plugins. But handling the differences between RCP and RAP in the meaning of file-upload/-download and single-sourcing was another matter that I couldn’t solve that easiely. Also exporting the result into a .war file for our (slightly outdated) Glassfish 2.1 server was not easiely done at the time of my fist tests.

  9. Lars Vogel says:

    @Daniel: if something works find in Eclipse 3.x and not in Eclipse 4.x please open a bug. This actually helps the development team.

Comments are closed.