First Eclipse e4 Application

The coding of this project is published on github.
Here we will create an Eclipse e4 application which looks like this:

Hello Duckout e4 Apllication

Hello Duckout e4 Apllication

Installation of e4
We need prepare our Eclipse before we can actually start.
In Eclipse navigate to Help -> Install New Software…

Click Add and paste the current repository. (In my case: http://download.eclipse.org/e4/downloads/drops/R-0.13-201302282200/repository/).

Add Repository

Add Repository

Ok go ahead an Install the Eclipse e4 tools.

Install Eclipse e4 Tools

Install Eclipse e4 Tools

Once the Installation is finished, Eclipse asks you to restart itself. After restarting Eclipse we are ready to create our first application.

Create the first Eclipse 4 application
Select File -> New -> Other… -> Eclipse 4 Application Project

Create your project like this:

Select Eclipse 4 Application Project

Select Eclipse 4 Application Project

New Plug-in Project

New Plug-in Project

New Plug-in Project Content

New Plug-in Project Content

New Plug-in Project

New Plug-in Project

Ok perfect. Now we’ve created our first e4 application and it wasn’t to hard, right?

Our View class with a little text in it.
Create a class called View.java in package de.duckout.helloDuckout.ui.

package de.duckout.helloDuckout.ui;

import javax.inject.Inject;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;

public class View {

private GridData gridData;

@Inject
public View(Composite parent) {
Text text = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.BORDER);
text.setText("Hello Duckout, thanks for sharing this valueable tutorial with me. This is just awesome! Just joking. Thanks for reading this tutorial!");
}
}

Adapt the View
Now double click the Applicatione4xmi. Here we can prepare the View of the application.

Package Explorer

Package Explorer

Now change your application modell like the following picture. There will be a Perpective Stack, a Perspective, a PartSashContainer, a Part Stack and a Part.

Use right click to add all these childs.

Application Modell

Application Modell

Here we still need to do some changes. Select the just created Part. There you can maintain a Label and you have to choose a Class URI. This will point to the View.java class.

Part in Application.e4xmi

Part in Application.e4xmi

Done. you just need to start the application:
Navigate to de.duckout.helloDuckout.product and click Launch an Eclipse application.

de.duckout.helloDuckout.product

de.duckout.helloDuckout.product

Thanks!
I hope this will help you creating a first e4 application. Thanks for reading this tutorial!

Posted on by Monte in Eclipse Leave a comment

Add a Comment