In June 2012 a very important thing happened in the Eclipse world: e4 platform replaced the great and long lasting 3.x version , which started in 2004 with the release of 3.0 version. During these eight years great progress have been made. In fact Eclipse has become matchless both as an IDE and as a platform. Not to mention moreover that it is completely Open Source and with a particularly “commercially friendly” (EPL) license!

e4 platform is kind of a revolution with respect of the previous version. To begin with it is completely EMF (Eclipse Modeling Framework) -based, it got rid of the heavy burden of the 3.x workbench class hierarchy (Application*) and pervasively exploits the Injection mechanism. These are of course just some of the main aspects: in fact here we aim to get in touch with this new platform.

Just a note before we start: despite the changes with this new platform, it is backward-compatible, that is, you can import and manage 3.x projects, thanks to the Compatibility Layer, which implements the old 3.x workbench mechanisms with the new e4 paradigms. For those who want to keep working with the old platform, there is a latest 3.x maintenance release version (3.8) here http://download.eclipse.org/eclipse/downloads/eclipse3x.html

IDE Setup

At page http://www.eclipse.org/downloads you can find several different e4 packages. Just download and launch this

At the beginning you’ll notice a few graphical innovation with the splash screen and with the renewed look and feel.
Note: it’s always advisable to use a brand new workspace (since a workspace used with other versions of Eclipse may lead to inconsistent behaviours).

SplashKepler

Let’s now install the Tools that will allow us to create an e4 application, using the following update site:

http://download.vogella.com/kepler/e4tools

from which we’ll install the following features:

* CSS spy for e4 / e4 CSS Spy (Incubation)
* e4 core tools / e4 Tools (Incubation)

First Application

Thanks to the Tools just installed we are now able to do File -> New -> Other… -> e4 Application Project.

Let’s press Next, input a project name, e.g. it.rcpvision.e4training.application and press again Next, Next, select “Create sample content (parts, menu etc. )” check box, then Finish.
Now, instead of going on with 3.x way (with a click on hyperlink “Launch an Eclipse Application”) we’ll act in a different way: note, in fact, that the new project includes a Product (es. it.rcpvision.e4training.application.product).
Launch this product, right-clicking it and selecting Run As/Debug As -> Eclipse Application. Here we have our first running e4 application.

Verify that the wizard created an application with a Part (in 3.x we would have used terms like View or Editor: now this distinction has become obsolete!), some Menu items, linked to Commands, implemented by Handlers (these concepts are instead still valid, although differently and easily made).
If we look at the generated code we’ll see that there disappeared all the 3.x workbench classes. In fact we just have classes

for the generated sample Handlers and the Part.

But what to do if we want to add a new Part where we can put our graphical components? We just have to edit file Application.e4xmi, which represents the EMF model of our application.

Let’s expand Windows node down, till we get the Part Stack object selected

and on the right side, where the details of selected object are shown, press the Add… button after having verified that the nearby combo is showing item “Part”. We are in fact adding a new Part to the selected Part Stack object.

insert a text for Label of this Part, e.g. Orders

and save. Now, launching the application we will see the new created Part (please note that we did not created a correspondent Java class)

In order to put some widget into this Part let’s get back to its detail panel and click the Class URI hyperlink

set a package (e.g. it.rcpvision.e4training.application.parts) and a class name, e.g. Orders, then Finish.

note that the created class does not extend a class, nor implements any interface: it’s a plain Java class with some Annotation.

package it.rcpvision.e4training.application.parts;

import javax.inject.Inject;
import org.eclipse.e4.ui.di.Focus;

public class Orders {

	@Inject
	public Orders() {
	}

	@Focus
	public void onFocus() {
	}

}

Now add the following method

	@PostConstruct
	public void createPartControl(Composite parent) {

	}

Indeed the method name can be different; the important things are the Annotation @PostConstruct and the Composite parameter). Now you can in fact open this class with WindowBuilder

and start populating it with components like you learned in our previous tutorials (see for example WindowBuilder: advanced databinding with CDO).

and in the end you can launch the application and see the first results.

Special credits to Lars Vogel, for his great tutorials, his precious advices and his latest e4 book (details below)!

For Eclipse e4 development or consulting, send an email to   info@rcp-vision.com

For Eclipse e4 training   visit our training page

Credits

Lars Vogel
e4 Application Development: The complete guide to e4 RCP development
Building Eclipse RCP applications based on e4

Jonas Helming
Eclipse 4 (e4) Tutorial Part 1 ÔÇô The e4 Application Model

Tom Schindl
Eclipse / e4

 How to contribute to an Eclipse e4 application