developing your first eclipse rcp application...org.eclipse.ui.ide plug-in and the extensions...

25
Developing your first Eclipse RCP application Crafting a rich client application is easier than ever, thanks to Eclipse V3.1 Skill Level: Intermediate Sandy Minocha ([email protected]) Software Engineer IBM Rational 27 Jun 2006 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. Section 1. Before you start This tutorial is for developers who would like to learn how to use the Eclipse Rich Client Platform (RCP). Eclipse has evolved to become a platform that can host a wide range of applications serving a wide variety of end users. Consider RCP as an integration platform with the same raw function as Eclipse, but one with a smaller overall footprint and a more flexible user interface. RCP opens the door to achieving desktop applications written in the Java™ programming language. About this tutorial This tutorial builds an application using the Eclipse RCP. The example application is divided into four sections, each building on the previous one. You start by creating a basic RCP application with the help of one of the Eclipse-supplied RCP templates. Next, you add some actions, a preference page, a view, and Help to the basic RCP application. This is followed by branding and turning the basic RCP application into a product. The final step takes you through packaging and deploying the RCP product outside of Eclipse. Developing your first Eclipse RCP application © Copyright IBM Corporation 1994, 2008. All rights reserved. Page 1 of 25

Upload: others

Post on 17-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Developing your first Eclipse RCP applicationCrafting a rich client application is easier than ever, thanks toEclipse V3.1

Skill Level: Intermediate

Sandy Minocha ([email protected])Software EngineerIBM Rational

27 Jun 2006

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

Section 1. Before you start

This tutorial is for developers who would like to learn how to use the Eclipse RichClient Platform (RCP). Eclipse has evolved to become a platform that can host awide range of applications serving a wide variety of end users. Consider RCP as anintegration platform with the same raw function as Eclipse, but one with a smalleroverall footprint and a more flexible user interface. RCP opens the door to achievingdesktop applications written in the Java™ programming language.

About this tutorial

This tutorial builds an application using the Eclipse RCP. The example application isdivided into four sections, each building on the previous one. You start by creating abasic RCP application with the help of one of the Eclipse-supplied RCP templates.Next, you add some actions, a preference page, a view, and Help to the basic RCPapplication. This is followed by branding and turning the basic RCP application into aproduct. The final step takes you through packaging and deploying the RCP productoutside of Eclipse.

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 1 of 25

Page 2: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Prerequisites

This tutorial assumes basic programming knowledge. Knowledge of the Javaprogramming language and Eclipse is a plus, but not required.

System requirements

The following tools are needed to follow along:

EclipseEclipse is the platform upon which RCP resides. Download Eclipse V3.1.x fromEclipse.org.

Java technologyEclipse and all its plug-ins need Java technology. Download Java technologyfrom Sun Microsystems or from IBM.

Be sure to read the installation section for helpful step-by-step instructions.

Section 2. What is the Rich Client Platform?

Originally, the Eclipse platform was designed to serve as an open tools platform.However, starting with Eclipse V3.0, it was re-architected so that its componentscould be used to build just about any client application. The minimal set of plug-insneeded to build a rich client application is collectively known as the Rich ClientPlatform (RCP). These rich applications are still based on a dynamic plug-in model,and the GUI is built using the same toolkits and extension points. However, the keydifference is that the workbench is under fine-grain control of the plug-in developerwith RCP applications. Note that the Eclipse IDE is itself an RCP application.

What RCP requires

To build an RCP application with a GUI, you need the following plug-ins and theirprerequisites: org.eclipse.ui and org.eclipse.core.runtime. As of Eclipse V3.1.1, thecombined disk footprint for the RCP, including the above plug-ins, startup.jar and theeclipse.exe executable, is about 6.6 MB. Now, RCP applications are free to use anyAPI deemed necessary, and they can require any plug-ins above the bare minimum,such as Help UI and Update Manager.

The workspace resource model provided by the org.eclipse.core.resources plug-in isnot considered part of the RCP. While this is the underlying data model for theEclipse IDE, the RCP makes no assumptions about the underlying data model of the

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 2 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 3: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

application being built. The data model could be files in the local file system, aremote database, or anything else. If it makes sense for the application,org.eclipse.core.resources can be included and used as the application's datamodel, but this is not required.

The org.eclipse.ui.ide plug-in is layered on top of the generic workbench(org.eclipse.ui) and defines the application for the Eclipse IDE, on top of which sitthe other IDE components, such as the Java Development Tools (JDT), Plug-inDevelopment Environment (PDE), Debugger, and Team support. The IDEinstantiates the generic workbench, configuring it with IDE-specific menu and toolbaritems, and adding IDE-specific views, preference pages, and other extensions. TheIDE uses the workspace resource model as its underlying data model. Theorg.eclipse.ui.ide plug-in and the extensions defined within it are not designed to bereused in other RCP applications.

The Eclipse runtime defines the plug-ins (org.eclipse.osgi andorg.eclipse.core.runtime) on which all other plug-ins depend. The Open ServicesGateway Initiative (OSGi) framework refers to plug-ins as bundles. Bundles togetherwith the OSGi framework specify and implement the process for Java class-loading,prerequisite management, and the bundle's life cycle. The Eclipse core runtime isresponsible for finding and executing the main Eclipse application and formaintaining a registry of plug-ins, their extensions, and extension points. In addition,the runtime also provides an assortment of utilities, such as logging, debug traceoptions, a preference store, and a concurrency infrastructure.

Section 3. Hello World RCP application overview

Upon completion of the Hello World RCP application, you will end up with twoplug-ins and three features.

Table 1. Description of Hello World RCP application plug-ins and featurescom.ibm.plte plug-in Defines the RCP application

Defines feature and product branding information

com.ibm.plte.ui plug-in Defines several Eclipse functions, includingaction, preference, view, and Help

com.ibm.plte feature Defines the Hello World RCP application plug-insDefines the two included features below

com.ibm.plte.help feature Defines the dependencies on Help plug-ins (eighttotal)

org.eclipse.rcp feature Defines the dependencies on RCP plug-ins

You will create the Hello World RCP application in Eclipse SDK V3.1.1. When youopen the Eclipse workbench, you will already have com.ibm.plte.help feature addedto your workspace.

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 3 of 25

Page 4: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

This tutorial is divided into four sections:

1. Create a minimal Hello World RCP application

• org.eclipse.core.runtime.applications

2. Add several Eclipse functions to the Hello World RCP application

• org.eclipse.ui.actionSets

• org.eclipse.help.toc

• org.eclipse.ui.preferencePages

• org.eclipse.ui.views

3. Create a Hello World RCP product

• Feature branding

• org.eclipse.core.runtime.product

4. Deploy and run Hello World RCP product outside of Eclipse

Note that if the intent is to build Eclipse tools that will be integrated into an EclipseIDE-based product, you do not create an RCP application or an RCP product. AnEclipse IDE-based product will already have defined an application and a product.However, you must still provide feature branding for your Eclipse tools.

Section 4. 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 clientapplication?" Click Next.

5. Select Hello RCP template and click Finish.

6. The Open Associated Perspective dialog box may pop up. Click Yes.

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 4 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 5: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Your workbench should look similar to the following:

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

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

Table 2. Description of artifacts generated by Hello RCP templateorg.eclipse.core.runtime.applications

org.eclipse.ui.perspectivesPerspective.java

PltePlugin.java

Application.java

ApplicationWorkbenchWindow.javaApplicationWorkbenchAdvisor.javaApplicationActionBarAdvisor.java

Step 2: Run minimal Hello World RCP application

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

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 5 of 25

Page 6: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Figure 2. 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 (nomenus, actions, views, preference pages, Help books, etc.). You will add thesefunctions as you continue.

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

Menus and actions can be added in two ways. Here, we add them to the RCPapplication 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

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 6 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 7: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

• 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 thesemenus and actions are defined, look at ApplicationActionBarAdvisor.java in thecom.ibm.plte.help feature project. Note that using the actions framework, you cancontribute your own actions. You will do this using extension points later.

Steps to take:

1. Replace the com.ibm.plte plug-in'scom.ibm.plte.ApplicationActionBarAdvisor.java with a file having the samename from the com.ibm.plte.help feature project.

2. Ensure that you closed the RCP application you launched previously. Goback to the overview page of the com.ibm.plte (plugin.xml) editor and clickLaunch an Eclipse application from the Testing section. Your RCPapplication should have several menus.Figure 3. RCP application with some menus

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 7 of 25

Page 8: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

3. Click Window > Open Perspective > Other. In the Select Perspectivedialog box, you will see one perspective labeled Plte Perspective(default). This is the perspective you created using the Hello RCPtemplate.

4. Click Window > Show View > Other. You should see an empty ShowView dialog box. This is because you have not added any views to theRCP application yet. We do this in the next section.

5. Click Window > Preferences. You should see an empty Preferencesdialog box. This is because you have not added any preferences to theRCP application yet. We do this in the next section.

6. Click Help > About. The About dialog box will be empty, except for threebuttons. The About dialog box gives information about the set of featuresand plug-ins installed in your RCP application. Since you have not addedany features yet, the dialog box is empty.

7. Click Plug-in Details. The dialog box will show the complete list ofplug-ins that are part of this RCP application. We will see the 10 RCPplug-ins, plus the single plug-in we created.

8. Click on com.ibm.plte plug-in in this dialog box and notice that the MoreInfo button is disabled. More Info provides additional information aboutthe plug-in. If you want to provide additional information about yourplug-in(s), you need to add it in an about.html file. We do this in the nextstep.Figure 4. Plug-ins included in the Hello World RCP application

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 8 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 9: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

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

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

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 thecom.ibm.plte plug-in.

2. Ensure that you closed the RCP application launched previously. Go backto the overview page of the com.ibm.plte (plugin.xml) editor and clickLaunch 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

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 9 of 25

Page 10: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Section 5. Add Eclipse functions to the Hello World RCPapplication

At this point, the Hello World RCP application is bare-bones, with the exception of afew menus, actions, and an about.html file. In this section, you contribute fourEclipse functions: menu/action, preference page, view, and a Help book. You willtake the simple route and use PDE templates to generate these.

Step 1: Add a menu/action, preference page, view, and a Helpbook

1. Click Ctrl+N to open the new wizard.

2. Select Plug-in Project and click Next.

3. Enter com.ibm.plte.ui in the Project name text field and click Next.

4. Click Next.

5. Select Custom plug-in wizard and click Next.

6. Click Deselect All and click "Hello World" Action Set, Help Table ofContents, Preference Page and View. Click Finish.

Step 2: Run Hello World RCP application with the four Eclipse

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 10 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 11: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

functions

Up to this point, you have been using the Launch an Eclipse application link fromthe overview page of the com.ibm.plte (plugin.xml) editor to launch the Hello WorldRCP application. In this step, you will use the Run dialog box to launch the RCPapplication because the RCP application requires additional plug-in dependenciesfor Help.

Steps to take:

1. Ensure that you closed the RCP application launched previously. SelectRun > Run to open the Run dialog box.

2. Select Eclipse Application > Eclipse Application configuration.

3. Switch to the Plug-ins tab.

4. Select the com.ibm.plte.ui plug-in. Select Add Required Plug-ins andadd the following plug-ins under the External Plug-ins section:

• org.apache.ant

• org.apache.lucene

• org.eclipse.help.appserver

• org.eclipse.help.base

• org.eclipse.help.ui

• org.eclipse.help.webapp

• org.eclipse.tomcat

• org.eclipse.ui.forms

5. Click Run. Your application should come up with an additional SampleMenu.Figure 6. Hello World RCP application with Help menu

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 11 of 25

Page 12: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

6. Click Window > Show View > Other. Select Sample View under theSample Category folder. You indirectly added the Help folder as a resultof adding the dependent Help plug-ins. Click OK to open the SampleView.Figure 7. Hello World RCP application with a view

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 12 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 13: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

7. Click Window > Preferences to open the preferences dialog box. Checkto see a Sample Preferences preference page in the dialog box. Youindirectly added the Help preference pages because of adding thedependent Help plug-ins.Figure 8. Hello World RCP application's preference dialog box

8. Click Sample Menu > Sample Action. An information dialog box opens.

9. Click Help > Help Contents. The Help browser will open and display the

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 13 of 25

Page 14: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Help book Test TOC.Figure 9. Hello World RCP application Help content

Step 3: Enable Hello World RCP application toolbar

Actions can be added to the menu bar or the toolbar. To display actions in thetoolbar, you first need to enable the toolbar in the RCP application. By default whenan RCP application is generated using the Hello RCP template, it does not enablethe toolbar. Enable the toolbar by completing the following:

1. Open com.ibm.plte.ApplicationWorkbenchWindowAdvisor.java from thecom.ibm.plte project.

2. Modify the configurer.setShowCoolBar(false); toconfigurer.setShowCoolBar(true); and save the file.

3. Ensure that you closed the RCP application launched previously. Go backto the overview page of the com.ibm.plte editor. Click Launch an Eclipseapplication from the Testing section. You will now see the toolbar with asingle action. Clicking this will result in the same message dialog boxappearing by clicking Sample Action from the Sample Menu.Figure 10. Hello World RCP application with toolbar

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 14 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 15: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Step 4: Deploying the same four functions in the Eclipse IDE

The four functions created above are not exclusive to RCP applications. They canalso be part of an Eclipse tool. This is the benefit of the Eclipse framework: You getto reuse the Eclipse components. In this step, add the same four features to theEclipse IDE:

1. Ensure that you closed the RCP application launched previously. ClickRun > Run to open the Run dialog box.

2. Create a new Eclipse Application configuration.

3. Click Run. Another Eclipse IDE workbench will open. Verify that the samefour functions added above appear in this runtime workbench.

Section 6. Create an RCP product

Part 3: Create a Hello World RCP product

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 15 of 25

Page 16: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

In Eclipse terms, a product is everything that goes with your application, including allthe other plug-ins it depends on, features, a command to run the application (calledthe native launcher), and any branding (icons, etc.) that make your applicationdistinctive.

There are two types of branding in Eclipse: feature- and product-level. No extensionpoints exist for defining feature branding. The process involves placingfeature-branding files in a plug-in, then defining this plug-in in the feature definition(feature.xml). If the feature ID is identical to the plug-in ID, it is not necessary todefine the plug-in in the feature definition. In this section, you will brand a featurecalled com.ibm.plte. Note that this feature has the same ID as plug-in com.ibm.plte.

Product branding is done using the org.eclipse.core.runtime.product extension point.Eclipse provides a Product Configuration editor to help create the product extensionpoint. One of the attributes you must set with this extension point is the productname. You will define the product name to be com.ibm.plte.product. Note thatalthough the RCP was introduced in Eclipse V3.0, the Product Configuration functiondid not appear until Eclipse V3.1. You could still create an RCP product in V3.0 bymanually defining the product extension point, but it is much more complicated.

Note that since the Eclipse IDE is an RCP application, it also defines this productextension point. The product name the Eclipse IDE defines is org.eclipse.sdk.ide.

To brand the Hello World RCP application, this tutorial provides a number ofbranding-specific files. The table below shows a mapping of the branding files to thebranded RCP application.

Table 3. Description of sample branding files used to customize Hello WorldRCP applicationicons/jdg2eAbout.gif

icons/jdg2eProd.gif

splash.bmp

about.iniabout.propertiesicons/jdg2eFeat.gif

Step 1: Brand a feature and create a Hello World RCP product

Steps to take:

1. From the com.ibm.plte.help feature project, move the following folder/filesover to the com.ibm.plte plug-in project:

• icons folder

• splash.bmp

• about.ini

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 16 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 17: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

• about.properties

2. Right-click on the com.ibm.plte project and select New > ProductConfiguration to open the New Product Configuration dialog box.

3. Enter plte.product in the File name text field.

4. Select the Use a launch configuration radio button and click Finish.The plte.product editor opens.

5. On the overview page of the plte.product editor, click New next to ProductID. The New Product Definition dialog box opens.

6. Select the com.ibm.plte project as the Defining Plug-in.

7. Enter the product in the Product ID text field and click Finish.

8. Enter PLTE in the Product Name text field.

9. Select the Features radio button.

10. Switch to the Configuration page.

11. Click New Feature. The New Feature wizard opens.

12. Enter com.ibm.plte-feature in the Project name text field and clickNext.

13. Modify the Feature ID to com.ibm.plte and click Next.

14. Select plug-ins com.ibm.plte and com.ibm.plte.ui, then click Finish. Thecom.ibm.plte (feature.xml) editor opens.

15. Switch to the Information page, then switch to the License Agreementpage. Modify the Optional URL text field to license.html.

16. Switch to the Included Features page of the editor and click Add.

17. Select features com.ibm.plte.help and org.eclipse.rcp, then click OK.Save feature.xml.

18. Go back to the plte.product editor and switch to the Branding page.

19. Enter plte in the Launcher Name text field.

20. Select the com.ibm.plte plug-in for the splash screen.

21. For the 16x16 window image, select com.ibm.plte/icons/jdg2eProd.gif.

22. For the About dialog box image, select com.ibm.plte/icons/jdg2eAbout.gif.

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 17 of 25

Page 18: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

23. Enter This is a sample PLTE application in the Text text field.

24. Save plte.product.

25. Move license.html from the com.ibm.plte.help feature project to thecom.ibm.plte feature project.

Step 2: Run Hello World RCP product

Steps to take:

1. Ensure that you closed the previous RCP application. Go to the overviewpage of plte.product and click Launch the product. You will see a splashscreen before the RCP application opens. Verify that the application lookslike Figure 16. Notice the top left corner of the RCP application has theimage you specified in plte.product.Figure 16. Hello World RCP application

2. Click Help > About PLTE. Originally, this Action name was labeledAbout, but it now appends the product name you defined in plte.product.Because the application now contains features, the About dialog boxprovides additional information about your application. The About dialogbox should look like the following figure. Note that due to a bug, theFeature Details button only shows the org.eclipse.rcp feature and not thecom.ibm.plte feature. Only features that have been branded will show up

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 18 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 19: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

in the Feature Details dialog box, so you will not see thecom.ibm.plte.help feature. When you export and run this RCP applicationin the next section, you will see the com.ibm.plte feature.Figure 17. Hello World RCP application's About dialog box

Section 7. Deploying outside of Eclipse

After developing an application, the goal is to deploy and run stand-aloneapplications without the user having to know anything about the Java and Eclipsecode being used underneath. For a real application, you will likely provide aself-contained executable generated by an installation program like InstallShield orNSIS. This is beyond the scope of this tutorial, so you will instead create a simplifiedversion of the Eclipse installation directory. This directory has to contain the nativelauncher program, startup.jar, config.ini, and all the plug-ins and features required bythe product.

Eclipse provides an Eclipse Product export wizard to help you build the Eclipseinstallation directory on your file system.

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 19 of 25

Page 20: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Step 1: Export Hello World RCP product to the file system

All plug-in and feature projects contain a build.properties file. This file is used byEclipse to figure out what files should be exported. Before exporting the RCPapplication, you must update this file with the additional files or folder that wereadded to the com.ibm.plte plug-in and the com.ibm.plte feature. The build.propertiesfile does not have to be updated manually. You can use the build page of theplugin.xml or feature.xml editor.

Steps to take:

1. Go to the build page of the com.ibm.plte (plugin.xml) editor. Select thefollowing files or folder to export with the com.ibm.plte plug-in and savethe file:

• about.html

• about.ini

• about.properties

• icons folder

• splash.bmp

2. Go to the build page of the com.ibm.plte (feature.xml) editor. Select thefile license.html to export with the com.ibm.plte feature and save the file.

3. Go to the overview page of the plte.product editor and click EclipseProduct export wizard to launch Export wizard.

4. Select Directory as the Export Destination. Specify a location on the filesystem to export the RCP application and click Finish.

Step 2: Run Hello World RCP product from the file system

Steps to take:

1. Ensure that you closed the previously launched RCP application. Using acommand prompt window, go to the location where you exported theapplication. Run the plte.exe command. The same RCP application youran previously will open.

2. Click Help > About PLTE to open the About dialog box. Notice that thedialog box contains two icons above the Feature Details button. The firstrepresents the org.eclipse.rcp feature, and the second represents thecom.ibm.plte feature.Figure 18. Hello World RCP application's About dialog box

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 20 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 21: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

3. Click Feature Details to open the About Feature dialog box.

4. Select the com.ibm.plte feature. Notice that the License button isenabled. This is because you added a license.html file earlier.

5. Click License to open license.html in a browser.Figure 19. Hello World RCP application's sample license

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 21 of 25

Page 22: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

6. Locate and open the com.ibm.plte plug-in's plugin.xml. Notice that thisplug-in defines three extension points:

• org.eclipse.core.runtime.applications -- Created in Part 1 using theHello RCP template

• org.eclipse.ui.perspectives -- Created in Part 1 using the Hello RCPtemplate

• org.eclipse.core.runtime.products -- Created in Part 3 using theProduct Configuration editor

Figure 20. com.ibm.plte plug-in's plugin.xml

7. Go back to the Eclipse workbench. Click Run > Run to open the Rundialog box and select Eclipse Application > Eclipse Applicationconfiguration. Notice that this configuration contains the applicationcom.ibm.plte.application and product com.ibm.plte.product.Figure 21. Launch Configuration dialog box

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 22 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 23: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Section 8. Wrapping up

In this tutorial, we learned how to build a Java- and Eclipse-based rich clientapplication. The new tooling in Eclipse V3.1 makes it easier to build RCPapplications. In Eclipse V3.0, it was a much more manual process, but Eclipse V3.1allows you to generate applications quickly from RCP templates, and package andbrand your plug-ins with an easy-to-use UI. We also learned how to add Help toRCP applications.

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 23 of 25

Page 24: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Downloads

Description Name Size Download method

Source code os-ecl-rcpapp.zip 57KB HTTP

Information about download methods

developerWorks® ibm.com/developerWorks

Developing your first Eclipse RCP applicationPage 24 of 25 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Page 25: Developing your first Eclipse RCP application...org.eclipse.ui.ide plug-in and the extensions defined within it are not designed to be reused in other RCP applications. The Eclipse

Resources

Learn

• Check out Eclipse's Rich Client Platform information to expand your EclipseRCP skills.

• Learn more about the Eclipse Foundation and its many projects.

• Expand your Eclipse skills by visiting IBM developerWorks' Eclipse projectresources.

• Browse all of the Eclipse content on developerWorks.

• Visit the developerWorks Open source zone for extensive how-to information,tools, and project updates to help you develop with open source technologiesand use them with IBM's products.

• Stay current with developerWorks technical events and webcasts.

Get products and technologies

• Check out the latest Eclipse technology downloads at alphaWorks® .

• Download Java technology from Sun Microsystems or from IBM® .

• Download the open source, freely available, and extensible Eclipse SDK.

• Innovate your next open source development project with IBM trial software,available for download or on DVD.

Discuss

• The Eclipse newsgroups has lots of resources for people interested in usingand extending Eclipse.

• Connect with Eclipse developers and other users in the Eclipse mailing lists andnewsgroups. (You must register to read the newsgroups, but membership isfree, and the registration process is easy.)

• Get involved in the developerWorks community by participating indeveloperWorks blogs.

About the author

Sandy MinochaSandy Minocha works for the IBM Rational ISV Enablement team, which engageswith key Rational tools business partners, providing technical guidance and supportas they integrate into the Rational suite of products. The team also performstechnical validations of partner plug-ins for the Ready for IBM Rational softwarepartner program.

ibm.com/developerWorks developerWorks®

Developing your first Eclipse RCP application© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 25 of 25