Home Tutorials Training Consulting Products Books Company Donate Contact us

vogella commercial offerings

Training Events

How to extend the Eclipse 4 application model. This tutorial explains how to extend the Eclipse 4 application model and how to define a new renderer for new model elements. It also covers how to create custom editor implementations for these new model elements.

1. Application model extensibility

1.1. The application model structure

The application model of an Eclipse RCP application is based on an Eclipse Modeling Framework (EMF) model defined by the Eclipse platform. This structure defines, for example, that an MPart can be stored in an MPartSashContainer.

The Eclipse platform uses generated Java classes based on this EMF model. These classes are instantiated based on the Application.e4xmi file of the application including formation from model fragments, processors and other sources which modify the model, e.g., mode add-ons.

The Eclipse platform registers listeners on the attributes of these objects, so that it can react immediately if a model property changes.

1.2. Using extensions

The underlying structure of the application model can be extended by customers using standard EMF functionality. As the renderer framework is responsible for handling the model elements, you have to define a renderer which is responsible for the new model elements.

1.3. Adding an editor for a custom model elements

The org.eclipse.e4.tools.emf.ui plug-in defines the org.eclipse.e4.tools.emf.ui.editors extension point, which allows registering editors for new model elements.

2. Prerequisites

The following description assumes that you already have experience with Eclipse EMF, Eclipse 4 and the rendering framework of Eclipse 4.

3. Exercise: Extend the Eclipse application model

In this exercise you extend the structure of the Eclipse application model with an additional model element.

3.1. Creating a plug-in and add the dependencies

Create a new simple plug-in called com.vogella.e4.appmodel.extensions.

Wizard to create a simple plug-in

Add a dependency in your new plug-in to the following plug-ins via its MANIFEST.MF file.

  • org.eclipse.e4.ui.model.workbench

  • org.eclipse.e4.core.contexts

3.2. Create new model

Create a folder called model and create a new EMF model called _UiExtensions.ecore via File  New  Other…​  Eclipse Modeling Framework  EMF Model.

Create the EMF model
To create the EMF model

Press the Finish button.

Check the properties for this plug-in via the Properties view.

3.3. Define relationships to the Eclipse application model

Right-click on the model and select Load Resource…​.


Click on the button Browse Registered Packages and select the *UiModel/application model from the org.eclipse.e4.ui.model.workbench plug-in.

Define connections to an existing model
Define connections to an existing model

3.4. Define your custom model extension

Create a new EClass model element via right-mouse click. Via the Properties view, add Part as ESuper Types to it.


Use BrowserPart as value for the Name attribute.

Right-click on the model element and add an EAttribute called uri with type of EString to it.


The finished model should look like the following.


3.5. Create the Genmodel

Right-click your .ecore file and select File  New  Other…​  EMF Generator model.

Follow the wizard similar to the following screenshots.


3.6. Generate the Java classes

Use your genmodel to create the Java code. Right-click on it and select Generate Model Code.

applicationmodel generatecode10

3.7. Make generated classes available

Export all package via the Runtime tab on the MANIFEST.MF file.

Please note that the first time you run the model generation, the plugin.xml file is created. Also the org.eclipse.emf.ecore.generated_package extension point is added to it. This extension point declares your custom model. It is only added if the plugin.xml file needs to get created. If you later adjust settings of your model, i.e., your package setting, you have to adjust the extension point manually.

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>



   <extension point="org.eclipse.emf.ecore.generated_package">


Note down the uri from the extension point. You need to define this in your Application.e4xmi later.

4. Exercise: Create renderer for new model element

Define a new simple plug-in called com.vogella.e4.appmodel.renderer.

Add the following plug-ins as dependencies to your new plug-in.

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

  • com.vogella.e4.appmodel.extensions

  • org.eclipse.jface

  • org.eclipse.e4.ui.model.workbench

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

  • org.eclipse.e4.core.contexts

Create the following new class called BrowserPartRenderer. This class is used as renderer for your new BrowserPart.

Create the following factory to assign a renderer to your new model element.

package com.vogella.e4.appmodel.renderer;

import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.workbench.renderers.swt.WorkbenchRendererFactory;

import extensions.BrowserPart;

public class MyRendererFactory extends WorkbenchRendererFactory {

    private BrowserPartRenderer browserPartRenderer;

    public AbstractPartRenderer getRenderer(MUIElement uiElement, Object parent) {

        if (uiElement instanceof BrowserPart) {
            if (browserPartRenderer == null) {
                browserPartRenderer = new BrowserPartRenderer();
            return browserPartRenderer;

        return super.getRenderer(uiElement, parent);


5. Exercise: Use model extensions

5.1. Exercise: Create the application

Create a new Eclipse RCP application called com.vogella.e4.appmodel.app.

Add a dependency to the following plug-ins:

  • com.vogella.e4.appmodel.extension

  • com.vogella.e4.appmodel.renderer

You have to manually adjust the application model, as the default editors don’t support your new model elements. It is possible to develop custom components in the editor to handle your extensions but that is beyond this description.

Add your model name space to the Application.e4xmi file. Please note that xmlns:extension="https://www.vogella.com/ui/e4/extension defines the UI of your model extension. By this you can use extension:modelelement in the file referring to your custom model elements.

<?xml version="1.0" encoding="UTF-8"?>
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmi:id="_7VkpUKo8EeO_NLPjBpVjeQ" elementId="org.eclipse.e4.ide.application"
... more stuff...

Afterwards add your new part implementation to a part, the snippet to add it listed below.

<children xsi:type="extensions:BrowserPart"

5.2. Register your factory via an extension point

As a last step add the property rendererFactoryUri to your product in plugin.xml. Add a link to your new factory: platform:/plugin/com.vogella.e4.renderer.maps/com.vogella.e4.renderer.maps.MyRendererFactory

<?xml version="1.0" encoding="UTF-8"?>



5.3. Run your application

Run your application. The result should display the webpage to which you pointed via the uri parameter.


7. vogella training and consulting support

Copyright © 2012-2019 vogella GmbH. Free use of the software examples is granted under the terms of the Eclipse Public License 2.0. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.