Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

Developing your first Eclipse RCP application

Crafting a rich client application is easier than ever, thanks to Eclipse V3.1

Sandy Minocha, Software Engineer, IBM Rational
Sandy Minocha works for the IBM Rational ISV Enablement team, which engages with key Rational tools business partners, providing technical guidance and support as they integrate into the Rational suite of products. The team also performs technical validations of partner plug-ins for the Ready for IBM Rational software partner program.

Summary:  The objective of the Eclipse Rich Client Platform (RCP) is to enable Eclipse to be used in a wide range of end-user applications that are not integrated development environments (IDEs). With the release of Eclipse V3.1, it is easy to create RCP applications. This tutorial will guide you step by step in building your very own RCP application.

Date:  27 Jun 2006
Level:  Intermediate PDF:  A4 and Letter (739 KB | 28 pages)Get Adobe® Reader®

Activity:  109592 views
Comments:  

The basics

Step 1: Create minimal Hello World RCP application

  1. Click Ctrl+N to open the New wizard.
  2. Select Plug-in Project and click Next.
  3. Enter com.ibm.plte in the Project name text field and click Next.
  4. Answer Yes to the question "Would you like to create a rich client application?" Click Next.
  5. Select Hello RCP template and click Finish.
  6. The Open Associated Perspective dialog box may pop up. Click Yes.

Your workbench should look similar to the following:


Figure 1. Plug-in com.ibm.plte's plugin.xml in the PDE perspective
Plug-in com.ibm.plte's plugin.xml in the PDE perspective.

The Hello RCP template is very powerful and performs many tasks behind the scenes. The template generates a plug-in project, and adds two extension points and six Java classes. Each extension point and Java class is described below.


Table 2. Description of artifacts generated by Hello RCP template
org.eclipse.core.runtime.applicationsThis extension point tells the Eclipse runtime the name of your main program and the class that implements IPlatformRunnable and the run() method. In the Hello World RCP application, the program name is com.ibm.plte.application, and the class is com.ibm.plte.Application.

Note that since the Eclipse IDE is an RCP application, it also defines this extension point. In the Eclipse IDE, the application name is org.eclipse.ui.ide.workbench, and the class is org.eclipse.ui.internal.ide.IDEApplication.
org.eclipse.ui.perspectives
Perspective.java
A perspective is a set of visible views, editors, and menus that include positions and sizes. In an RCP application, you must define at least one perspective and make it the default. Perspectives are created by implementing IPerspectiveFactory using the class name referred to by this extension point. The important part of this interface is the createInitialLayout() method, where you position and open any views or editors you'd like the user to start with. So far in this example, there are no views or editors, so the method is empty.
PltePlugin.javaThis class is referred to as the plug-in class. An optional singleton class can be used to store global information for the plug-in. It is also a convenient place to put static utility functions used by other classes in the plug-in.
Application.javaApplication.java is a class that acts as the RCP application's main routine. It is similar to a Java class with main(). It is the controller for the application. This class is responsible for creating a workbench and attaching ApplicationWorkbenchAdvisor.java to it.

The workbench is declared and maintained as part of the RCP framework. There is only one workbench, but it can have more than one visible top-level workbench window. For example, in the Eclipse IDE, when you first start Eclipse, you will see one workbench window, but if you select Window > New Window, a second window pops up. So now there are two workbench windows, but only one workbench.
ApplicationWorkbenchWindow.java
ApplicationWorkbenchAdvisor.java
ApplicationActionBarAdvisor.java
There are three advisor classes used to configure all aspects of the workbench, such as the title, menu bars, and so on. These are the most important classes for an RCP developer to understand. You extend the base version of the class -- for example, WorkbenchAdvisor -- in the RCP application and override one or more of the methods to set whatever options you want. See product documentation for details.

Step 2: Run minimal Hello World RCP application

Make sure the overview page of the com.ibm.plte (plugin.xml) editor is open. Click Launch an Eclipse application from the Testing section. Your minimal Hello World RCP application should look like what is shown below.


Figure 2. Minimal RCP application
Minimal RCP application

In two simple steps, you created and ran a minimal RCP application. At this point, the RCP application contains a single perspective, but no other Eclipse functions (no menus, actions, views, preference pages, Help books, etc.). You will add these functions as you continue.


Step 3: Add menus and actions to the minimal Hello World RCP application

Menus and actions can be added in two ways. Here, we add them to the RCP application programmatically. Later, you will add them via extension points.

Five menus are added:

  • File
  • Window
  • Help
  • Window/Open perspective
  • Window/Show view

And six actions are added:

  • File/Exit
  • Window/Open perspective/Other
  • Window/Show view/Other
  • Window/Preferences
  • Help/Help contents
  • Help/About

The actions you add here are pre-built actions normally included in the Eclipse IDE. However, the RCP provides them for your convenience. To understand how these menus and actions are defined, look at ApplicationActionBarAdvisor.java in the com.ibm.plte.help feature project. Note that using the actions framework, you can contribute your own actions. You will do this using extension points later.

Steps to take:

  1. Replace the com.ibm.plte plug-in's com.ibm.plte.ApplicationActionBarAdvisor.java with a file having the same name from the com.ibm.plte.help feature project.
  2. Ensure that you closed the RCP application you launched previously. Go back to the overview page of the com.ibm.plte (plugin.xml) editor and click Launch an Eclipse application from the Testing section. Your RCP application should have several menus.

    Figure 3. RCP application with some menus
    RCP application with some menus

  3. Click Window > Open Perspective > Other. In the Select Perspective dialog box, you will see one perspective labeled Plte Perspective (default). This is the perspective you created using the Hello RCP template.
  4. Click Window > Show View > Other. You should see an empty Show View dialog box. This is because you have not added any views to the RCP application yet. We do this in the next section.
  5. Click Window > Preferences. You should see an empty Preferences dialog box. This is because you have not added any preferences to the RCP application yet. We do this in the next section.
  6. Click Help > About. The About dialog box will be empty, except for three buttons. The About dialog box gives information about the set of features and plug-ins installed in your RCP application. Since you have not added any features yet, the dialog box is empty.
  7. Click Plug-in Details. The dialog box will show the complete list of plug-ins that are part of this RCP application. We will see the 10 RCP plug-ins, plus the single plug-in we created.
  8. Click on com.ibm.plte plug-in in this dialog box and notice that the More Info button is disabled. More Info provides additional information about the plug-in. If you want to provide additional information about your plug-in(s), you need to add it in an about.html file. We do this in the next step.

    Figure 4. Plug-ins included in the Hello World RCP application
    Plug-ins included in the Hello World RCP application


The one action we did not execute is Help > Help Contents. This requires a number of Help plug-ins not included in the Hello World RCP application. Therefore, this action will not run until the necessary Help plug-ins have been added. We do this in the next section.


Step 4: Add plug-in information to the minimal Hello World RCP application

Here, you provide information about a plug-in via its about.html file:

  1. Move about.html from the com.ibm.plte.help feature project to the com.ibm.plte plug-in.
  2. Ensure that you closed the RCP application launched previously. Go back to the overview page of the com.ibm.plte (plugin.xml) editor and click Launch an Eclipse application from the Testing section.
  3. Click Help > About.
  4. Click Plug-in Details.
  5. Select the com.ibm.plte plug-in. The More Info button should be enabled.
  6. Click More Info, and about.html will open in a browser.

    Figure 5. The com.ibm.plte plug-in's description
    com.ibm.plte plugin's description.

4 of 11 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source
ArticleID=128655
TutorialTitle=Developing your first Eclipse RCP application
publish-date=06272006
author1-email=minocha@ca.ibm.com
author1-email-cc=