Free tutorials for Java, Eclipse and Web programming



Eclipse RCP - Tutorial (Eclipse 3.5)

Lars Vogel

Version 3.7

27.01.2010

Revision History
Revision 0.1-0.703.09.2007Lars Vogel
Eclipse RCP with Eclipse 3.3
Revision 0.810.07.2008Lars Vogel
Updated to Eclipse 3.4
Revision 0.903.11.2008Lars Vogel
Re-worked the command contribution to toolbars.
Revision 1.006.01.2009Lars Vogel
Re-worked the product configuration part
Revision 1.104.03.2009Lars Vogel
Added example for field assist
Revision 1.229.03.2009Lars Vogel
General rework
Revision 1.330.03.2009Lars Vogel
Moved several commmands related content to own Article, placed Actions into the appendix
Revision 1.3.104.04.2009Lars Vogel
Fixed screenshot problem
Revision 1.420.04.2009Lars Vogel
Reworked Dialog Examples
Revision 1.522.04.2009Lars Vogel
Reworked Wizard Examples, removed unnecessary method
Revision 1.630.04.2009Lars Vogel
Updated the progress example with commands
Revision 1.702.05.2009Lars Vogel
How to add view to perspective via extension point, moved Eclipse Forms to own article
Revision 1.824.05.2009Lars Vogel
Perspective now based on standard command
Revision 1.930.05.2009Lars Vogel
Combined part of commands in RCP and Eclipse Commands Article
Revision 2.010.06.2009Lars Vogel
Update to Eclipse 3.5 (Galileo), removed actions
Revision 2.124.06.2009Lars Vogel
Added ElementListSelectionDialog to dialog section
Revision 2.225.06.2009Lars Vogel
Moved preferences to own article http://www.vogella.de/articles/EclipsePreferences/article.html
Revision 2.328.06.2009Lars Vogel
Added command for showing the about dialog
Revision 2.401.07.2009Lars Vogel
How to install Eclipse RCP via the update manager
Revision 2.518.07.2009Lars Vogel
Fixed Tray example
Revision 2.625.07.2009Lars Vogel
Added plugin.xml for command example
Revision 2.728.07.2009Lars Vogel
moved how to create plugins from jars to own article http://www.vogella.de/articles/EclipseJarToPlugin/article.html
Revision 2.812.08.2009Lars Vogel
Launch configuration screenshots adjusted
Revision 2.913.08.2009Lars Vogel
Perspective screenshots adjusted
Revision 2.915.08.2009Lars Vogel
Moved how to add error log view to my blog
Revision 3.116.08.2009Lars Vogel
Product configuration updated
Revision 3.217.08.2009Lars Vogel
Moved internationalization to http://www.vogella.de/articles/EclipseInternationalization/article.html
Revision 3.308.09.2009Lars Vogel
Added plug-in required to update Java IDE to RCP IDE
Revision 3.410.10.2009Lars Vogel
Fixed bug in getStatusLine from editor
Revision 3.530.11.2009Lars Vogel
Improve TitleAreaDialog example
Revision 3.608.01.2010Lars Vogel
Fixed screenshot
Revision 3.727.01.2010Lars Vogel
Added screenshot to system tray and commented code

Eclipse RCP

This article describes how to develop applications using the Eclipse Rich Client Platform (RCP) architecture.

The article covers among others the creating of RCP applications, using commands, views, editors, dialogs and creating and deploying a Eclipse product.

This article is based on Eclipse 3.5 (Eclipse Galileo).


Table of Contents

1. Eclipse RCP
1.1. Overview
1.2. Eclipse RCP Architecture - Plugins, Extensions and Extension-Points
1.3. Main components of an Eclipse RCP application
1.4. Application versus Product
1.5. Important files
2. Installation
3. Create your first RCP application
3.1. Create a RCP application
3.2. Start your RCP application
4. Startup process of an RCP application
5. Run configuration
5.1. Overview
5.2. Check your runtime configuration
5.3. Important Parameters
6. Commands
6.1. Overview
6.2. Defining commands
6.3. Using commands in menus
7. System Tray
8. Views
8.1. Overview
8.2. Create a view
8.3. Add the view to your perspective.
8.4. Result
8.5. Add view to perspective via code
9. Working with Editors, View Interaction and Model Updates
9.1. Overview
9.2. Create project
9.3. Create and prepare the domain model
9.4. Content and Label provider
9.5. Use the domain model in the view
9.6. Editor area
9.7. Editor Input
9.8. Adding the editor
9.9. Creating a command for calling the editor
9.10. Calling the editor
10. Dialog
10.1. Overview
10.2. Using standard dialogs
10.3. Selection
10.4. User defined dialogs
11. Field Assist
12. Wizards
12.1. Overview
12.2. Example
13. Adding a status line
13.1. Setup Status line
13.2. Shared Status Line
14. Perspectives
14.1. Adding a perspective to your application
14.2. Select the perspective
15. Products and Branding
15.1. Product Configuration
15.2. Create a project
15.3. Create your product configuration
15.4. Maintain the overview tab
15.5. Dependencies
15.6. Launch your product
15.7. Splash Screen
15.8. Branding your product
15.9. Customizing the start icon and launcher arguments
15.10. Done
16. Deploy your product
17. Tips and Tricks
17.1. Save users layout
17.2. Plugin ID in application
17.3. Finding unused dependencies
18. Next steps
19. Thank you
20. Questions and Discussion
21. Links and Literature
21.1. Source Code
21.2. Eclipse Resources
21.3. Other Resources

1. Eclipse RCP

1.1. Overview

Eclipse RCP allows developers to use the Eclipse architecture to design flexible and extensible stand-alone applications re-using a lot of already existing functionality and coding patterns inherent in Eclipse.

For an brief introduction into Eclipse, the concepts and terminology (perspective, views, editors) please see Eclipse Java IDE - Tutorial .

Eclipse is build upon a plugin architecture. This allows Eclipse to get easily extended. See Eclipse plugin Tutorial for a guide on how-to extend the Eclipse IDE. Eclipse RCP provides the same modular concept for stand-alone applications.

To create an Eclipse RCP application you would create a plugin which contains the application. This application can use the existing hooks of Eclipse (called Extension Points) to define functionality and / or the user interface and / or provide its own extension points to get extended by other plugins.

1.2.  Eclipse RCP Architecture - Plugins, Extensions and Extension-Points

The most important architectural characteristics of Eclipse is the Plugin architecture. The Eclipse IDE is build as a number of plugins which are dependent on each other.

Plugins are the smallest deployable and installable software components of Eclipse.

Each plugin can define extension-points which define possibilities for functionality contributions ( code and non-code ) by other plugins. Non-code functionality contributions are for example the provision of help content.

A plugin can use extensions, e.g. provide functionality to these extension points. In general an extension point can be used several times (either by the same plugin or by other plugins). See Eclipse Extension Points and Extensions - Tutorial for details.

The basis for this architecture is the runtime environment Equinox of Eclipse which is the reference implementation of OSGI. See OSGi development - Tutorial for details. The Plugin concept of Eclipse is the same as the bundle concept of OSGI. Generally speaking a OSGI bundle equals a Plugin and vice-versa.

The used extensions and the provided extension-points are described in the file plugin.xml. This file is a XML file which can be edited via the PDE (Plugin Development Environment) which provides a nice user interface for editing this file.

Eclipse RCP provides and uses the same framework as the Eclipse Workbench hence allowing the programmer to divide the application functionality into several plugins, to use existing extension points and to provide additional extension points. This concept of Eclipse allows every programmer to structure his RCP application into several independent components and to easily declare extensions to existing extensions points.

1.3.  Main components of an Eclipse RCP application

An Eclipse RCP application requires:

  • Main program - A RCP main application class implements the interface IApplication. Eclipse expects that the application class is defined via the extension point org.eclipse.core.runtime.application.

  • A Perspective - The perspective is extended from org.eclipse.ui.perspective

  • Workbench Advisor- invisible technical component which controls the appearance of the application (menus, toolbars, perspectives, etc)

All plugins must provide a so-called manifest named "plugin.xml".

The minimal required plugins to create and run an Eclipse RCP application are the two plugins "org.eclipse.core.runtime" and "org.eclipse.ui"

1.4. Application versus Product

To run an Eclipse RCP program you have to define an application . The application can be seen as the main() method of a standard Java program. If this application shuts down the complete program is terminated.

In Eclipse terms a product is everything that goes with your application, e.g. icons, splash screen, external jars, other plugins, etc.

1.5. Important files

The plugin configuration is contained in the two files:

  • MANIFEST.MF - the OSGi bundle manifest is stored in MANIFEST.MF

  • plugin.xml - additional Eclipse specific (non standard OSGi) configuration, e.g. the extension points

The PDE provides an editor for editing the "MANIFEST.MF" and "plugin.xml".

In addition to these files you have the .project file. The .project contains the description of your project. It contains a XML tag "natures" where the nature of the project is described. A plugin project has the nature "org.eclipse.pde.PluginNature" and a java project has the nature "org.eclipse.jdt.core.javanature". These tags will also steer some behavior of the development environment, e.g. a project with PluginNature will update the java class path if you change the dependency information in a plugin project.

Tip

The .* file may be hidden by a filter. In the package explorer select the drop-down menu and then Filter to remove the filter for .* resources.