by March 3, 2009 0 comments

Most developers would be familiar with the Eclipse IDE, which is a powerful
development environment for building JEE and Web applications. Eclipse is
available as an integrated development environment for Java, Java EE developers
and also for C/C++ developers as a separate package that includes the IDE along
with the necessary tools and support for frameworks that any developer would
need. Again here is a package dedicated for RCP/Plug-in developers, who want to
create either Eclipse Plug-ins or Rich Client Applications. This distribution
includes the complete SDK, developer tools, XML editors, and the Eclipse
Communication Framework. The Eclipse Rich Client Platform (RCP) empower the
developers to create applications that will be based on Eclipse framework and
will be re-using functionalities and coding patterns which are inherent to
Eclipse. The important characteristic of Eclipse is that it’s based on a Plug-in
architecture. Plug-ins themselves are the smallest deployable and installable
software components of Eclipse. The whole Eclipse IDE itself is built as a
number of plug-ins that are dependent on each other. The minimal set of plug-ins
required to build a rich client application is collectively known as the Rich
Client Platform (RCP).

Direct Hit!

Applies To: Java Developers
Integrated IDE support for rich client apps development
Primary Link:

Eclipse RCP IDE

Getting Started
To start developing plug-ins for Eclipse or for creating Rich Client
applications, one must download Eclipse for RCP/Plug-in Developers form the
Eclipse website. The only prerequisite before installing Eclipse RCP is that
Java SE6 must be installed before Eclipse RCP installation. To build an RCP
application in Eclipse, it requires a main program, perspective and a Workbench
Advisor. The RCP application extends the class org.eclipse.core.runtime
.application, and this represents the main program for the application. While
the perspective is extended from org.eclipse .ui.perspective class. The
Workbench Advisor is the component which controls the appearance of the
application. We used the latest Eclipse Ganymede for this article but the same
procedure can also be used for earlier versions of Eclipse like Europa. Once the
Eclipse RCP installation is done, you can start creating your first RCP
application. Start Eclipse RCP and assign directory to be used as the Workbench.
Now in Eclipse, select File > New Project and from the list, select the option
‘Plug-in Project’ and click on ‘Next’. On the new Plug-in Project window, name
the project as ‘DemoRcpApp’ and after clicking Next on the following screen
select the ‘Yes’ option for Rich Client Application question. After clicking
‘Next’ button, select the ‘Hello RCP’ as the template for the project and click
on ‘Next’. For the Hello RCP Project window, check the option for ‘Add branding’
and click on ‘Finish’. As a result, a complete project structure will be
created. Now when you click on the ‘Launch an Eclipse Application’ link from the
Overview page, the DemoRcpApp is displayed after a initial splash screen. The
splash screen appears as we have opted for adding branding to the application.

Adding commands and menu to app
Here, we will add a menu to the blank application and a command that will
close the application. And for that, the application would require two more
extensions, one each for command and other for the menu. For adding the
extensions, open the Extensions tab of the plugins.xml view. When you click on
the ‘Add’ button, a New Extension wizard opens where you have to select the
org.eclipse.ui.commands plugin as the Extension Point and click on ‘Finish’.
You’ll notice that a new extension is added to the Extensions list. Right click
on the newly added extension, select New > command, and set the ID as
mand, give name as ‘Exit’ and most important of all, set the defaultHandler as
demorcpapp.handler. ExitHandler. When you click on the defaultHandler link, a
New Java Class window opens which will create the Handler class for the
application. For this Handler class, set the superclass as
org.eclipse.core.comma nds.AbstractHandler. From the Package Explorer view,
expand the DemoRcpApp project and open the class. We’ll
override the execute() which will perform the action of closing the application.
Change the execute method as follows:

To create a Rich
Client application, you should ensure that the option highlighted in the
above visual is selected as Yes.

public Object execute(ExecutionEvent event) throws
ExecutionException {
return null;

When the
DemoRcpApp project is created by wizard, the overview of plugins.xml is
displayed and the app can be tested by clicking on Launch hyperlink.

Now we’ll add a menu where we will use this command. Following the previous
steps again, add the org.eclipse.ui.menus as a new Extension Point. Right-click
on this menu extension in the Extensions list, and select New > menuContribution.
Set the locationURI as menu:org.eclipse.ui. and then again right-click
on menuContribution and select New > menu and label the menu as ‘File’ and give
id as “mymenu”. Now we can add command to the menu file by right-clicking on the
menu File and selecting New > Command. Pass the command Id as exit.command and
give label as ‘Exit’.

To add extensions,
select the Extensions tab of the plugins.xml file from the project tree and
add Exit command to the File menu.

Running the RCP app
To execute the application, right click on the plugin.xml under the
DemoRcpApp project in the Package Explorer pane and select Run As > Eclipse
Application. The blank application which appeared earlier will now be having a
File menu in the toolbar strip. And when you click on ‘File’, another sub-menu
appears as ‘Exit’, and clicking on Exit option closes the application.This was
how we can start using Eclipse for Rich Client application building using most
of the in-built features of Eclipse framework itself.

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.

Your data will be safe!Your e-mail address will not be published. Also other data will not be shared with third person.