vogella training Android Training Eclipse Training

Eclipse 4 and the Compatibility Layer - Tutorial

Building Eclipse RCP applications based on Eclipse 4

Lars Vogel

Version 5.8

10.04.2012

Revision History
Revision 0.1 14.02.2009 Lars
Vogel
created
Revision 0.2 - 5.8 16.02.2009 - 10.04.2012 Lars
Vogel
bug fixes and enhancements

Eclipse 4 and the Compatibility Layer

This tutorial gives an overview on how to use the Compatibility Layer in Eclipse 4 to run plug-ins based on the Eclipse 3.x API.


Table of Contents

1. Compatibility Layer
1.1. Running Eclipse 3.x plug-in on top of Eclipse 4
1.2. Using features
1.3. Using plug-ins
1.4. Related bugs
2. Mixing Eclipse 4.x and Eclipse 3.x
3. Thank you
4. Questions and Discussion
5. Links and Literature
5.1. Source Code

1. Compatibility Layer

1.1. Running Eclipse 3.x plug-in on top of Eclipse 4

Eclipse 4 allows to run Eclipse 3.x RCP applications and Eclipse 3.x plug-ins. You Eclipse RCP application should have an existing product configuration file for the migration.

Using the compatibility layer allows to migrate existing Eclipse 3.x plug-ins and applications to Eclipse 4 and to start evaluating advantages of Eclipse 4, e.g. the application model and CSS based styling.

The compatibility layer converts the relevant extension point information into the application model. In the "org.eclipse.platform" plug-in you find the file "LegacyIDE.e4xmi" which defines the initial window and some add-ons.

If Eclipse is started in compatibility mode, this file is read via the E4Workbench class from the org.eclipse.e4.workbench.ui.internal package. E4Workbench will then convert the relevant extension points in the application model.

Unfortunately concepts like dependency injection for Views do not work (out of the box) with the compatibility layer.

1.2. Using features

The easiest way to migrate your Eclipse RCP application to Eclipse 4.2 is to have a feature based product configuration file which includes the standard org.eclipse.rcp feature.

In Eclipse 4 this feature has been upgraded to includes most of the necessary additional plug-ins for the compatibility mode. If your product is based on this feature you can just start your Eclipse 3.x product unmodified and it will work.

You only need to add two additional plugins, "org.eclipse.emf.ecore" and "org.eclipse.emf.common".

1.3. Using plug-ins

If you product configuration file is based on plug-ins you have to add the following plug-ins to it:

  • 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 Eclipse 4.

1.4. Related bugs

Currently the compatibility layer has a few limitations. Here is a list of some relevant bugs. Please note that Eclipse 4 is moving fast, hence these bugs might already be closed by the time you are reading this.

Related bugs:

  • https://bugs.eclipse.org/bugs/show_bug.cgi?id=319991 - Quick access should not be hard-coded

  • https://bugs.eclipse.org/bugs/show_bug.cgi?id=372373 - [Compatibility] Update of org.eclipse.rcp feature

  • https://bugs.eclipse.org/bugs/show_bug.cgi?id=365799 - Incorrect features are added via "Add Required"

  • https://bugs.eclipse.org/bugs/show_bug.cgi?id=378975 - RCP templates fail to launch

2. Mixing Eclipse 4.x and Eclipse 3.x

Unfortunately it is not possible to run an application in compatibility model and extend its application model via fragments or processors. This is due to the fact that first the fragments and then the processors are processed and afterwards the compatibility layer.

You can however define your own "LegacyIDE.xmi" file and add your model components to this file. Via the "applicationXMI" parameter in your org.eclipse.core.runtime.products extension point you point to that file.

For this approach you would copy the standard "LegacyIDE.e4xmi" file and add your model components to it. This file can be found in the org.eclipse.ui.workbench plug-in.

An example for this approach can be found under Mixed Eclipse RCP application on Github .

While this approach seems to work, it is currently not official supported so be careful if you use this.

3. Thank you

Please help me to support this article:

Flattr this

4. Questions and Discussion

Before posting questions, please see the vogella FAQ. If you have questions or find an error in this article please use the www.vogella.com Google Group. I have created a short list how to create good questions which might also help you.

5. Links and Literature

5.1. Source Code

Source Code of Examples

http://wiki.eclipse.org/E4 Eclipse E4 - Wiki

Eclipse RCP

Eclipse EMF

Dependency Injection