RSS

Search Engine

Saturday, October 23, 2010

Getting started with the Todo application

In the following chapters we will create a basis for a Todo application with the e4 framework. We will create the e4 application from scratch to get a deeper understanding.

8.1. Create project

Create a new Plugin project "de.vogella.e4.todo", based on the Equinox runtime. Do not select "Generate an activator". Do not select a template.

Create the package "de.vogella.e4.todo".

8.2. Add dependencies

You need to add several dependencies to your MANIFEST.MF to be able to use the programming model of e4. We also add the SWT plugin which we later require.

  • org.eclipse.core.runtime

  • org.eclipse.e4.ui.workbench

  • org.eclipse.e4.ui.workbench.swt

  • org.eclipse.e4.ui.workbench.renderers.swt

  • org.eclipse.e4.ui.css.swt.theme

  • org.eclipse.e4.core.services

  • org.eclipse.e4.core.di

  • org.eclipse.e4.core.contexts

  • org.eclipse.e4.ui.services

  • javax.inject

  • javax.annotation

  • org.eclipse.equinox.ds

  • org.eclipse.equinox.event

  • org.eclipse.swt

The resulting "MANIFEST.MF" should look like the following. I have removed the version so that you should be able to copy the MANIFEST.MF.

    
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Todo
Bundle-SymbolicName: de.vogella.e4.todo
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.e4.ui.workbench,
org.eclipse.e4.ui.workbench.swt,
org.eclipse.e4.ui.workbench.renderers.swt,
org.eclipse.e4.ui.css.swt.theme,
org.eclipse.e4.core.services,
org.eclipse.e4.ui.services,
javax.inject,
javax.annotation,
org.eclipse.equinox.ds,
org.eclipse.equinox.event,
org.eclipse.swt,
org.eclipse.e4.core.di,
org.eclipse.e4.core.contexts

8.3. Create product configuration

Create a new product configuration "Todo.product". The creation of a product configuration is similar to the task for Eclipse 3.6 RCP applications. Please see Creating a product configuration

Make sure you select "org.eclipse.e4.ui.workbench.swt.E4Application" as the application.

The result should look like the following.

Switch the "Dependencies" tab on your product file and add as dependency the plugin "de.vogella.e4.todo". Press afterwards the "Add required plugins" button.

8.4. Maintain Extension points

During the product creation the extension point "org.eclipse.core.runtime.products" was autommatically added to the file "plugin.xml". Open this file and select the tab "Extensions". If the tab extension is hidden, select "Extensions" on the tab Overview. Verify that "org.eclipse.e4.ui.workbench.swt.E4Application" is selected as application.

Every e4 application must define a base model. This is done via a property of the product. Maintain the properties "applicationXMI" with the value "de.vogella.e4.todo/Application.e4xmi". This points to the initial model which we will create soon. The resulting plugin.xml should look like the following.

    



id="product"
point="org.eclipse.core.runtime.products">

application="org.eclipse.e4.ui.workbench.swt.E4Application"
name="Todo">
name="appName"
value="Todo">

name="applicationXMI"
value="de.vogella.e4.todo/Application.e4xmi">





8.5. Create the initial workbench model

Create the file "Application.e4xmi" via File -> New -> Other -> Model -> Application Model.

This will create the file "Application.e4xmi" which is a representation on an EMF model. It describes a workbench model which currently has not even a window. You can create the file directly with the content from below.

    



Open "Application.e4xmi" with the "e4 WorkbenchModel Editor". This editor allows you to modify your "Application.e4xmi" file.

Select the entry window and add a new TrimmedWindow. Maintain the width, height and Label.

Your model now describes an application with an empty window.

8.6. Run your application

This should be sufficient to run your application. Create a launch configuration based for your product and run your application. The result should look like the following.

Congratulations. You have hand-crafted your first full featured Eclipse e4 application.

0 comments:

Post a Comment