The new project opens in the Manifest editor and looks pretty much like the SuperView project we created earlier. Click the Extensions tab and expand both entries. What makes this an RCP application rather than an Eclipse plug-in is that we’re creating an extension to org.eclipse.core.runtime.applications
. This is the class that will be executed when the platform is started. In effect, our plug-in becomes the main application program. We’re also creating a new perspective.
Expand the HelloRCP project down to the individual .java files under hellorcp
and open Application.java
. This file defines a class that implements IApplication
, which in turn implements both a start and a stop method.
Run the project by selecting Launch an Eclipse application from the Testing section of the Manifest editor Overview tab. The result (Figure 7.14) isn’t very exciting, but it does illustrate that we’ve fired off an independent application window. The code that implements the window is in ApplicationWorkbenchWindowAdvisor.java
.
Figure 7.14: HelloRCP application window.
7.6.1 Making It a Product
Ultimately of course, we want to create a stand-alone product that doesn’t require Eclipse to run. Right-click the HelloRCP project entry and select New→Product Configuration. All you have to do is give it a File name. Call it “Hello.”
A new file shows up under the project called Hello.product
and that file is opened in the Product Configuration editor. Give the product a name, say “Hello RCP.” Click the New… button to create a new product ID. The default values are fine, so just click Finish.
In the Configuration tab click Add… and select HelloRCP from the Plug-in Selection list. Then click Add Required Plug-ins. The Configuration tab should now look like Figure 7.15.
Figure 7.15: Product Configuration editor, Configuration tab.
Go back to the Overview tab, save the file, and click Synchronize to get this configuration in sync with the plug-in. At this point it’s a good idea to test the application one more time by clicking Launch an Eclipse application. If the Hello RCP window came up correctly, then we’re ready to export the finished product.
Click on Eclipse Product export wizard. Select a relevant name for Root directory. I called it “HelloApp.” We’ll store the final application in a Destination Directory. Click Browse…, which starts in your workspace. I chose to just put it in HelloRCP. Click Finish and the final application will be built.
Go to the root directory you just created and you’ll see that the executable is called eclipse. You’ve just created a stand-alone rich client application.
A much more extensive and interesting example of a rich client application is available from the Eclipse CVS repository. Go to the CVS Repository Exploring perspective and add a new repository. The details are:
Host: dev.eclipse.org
Repository Path: /cvsroot/eclipse
User: anonymous
Password: (leave blank)
Connection Type: pserver
After connecting, expand the HEAD branch to find a very large number of projects. Scroll down to find org.eclipse.ui.examples.rcp.browser
. Check out that project. Note, incidentally, that there are quite a few ui.examples
projects. Later on, you might want to investigate some of the others.
Back in the Plug-in Development perspective, right-click the new project entry in Package Explorer and select PDE Tools→Open Manifest. In the Testing section of the manifest Overview page, click Launch an Eclipse application to bring up the browser window of Figure 7.16.
Figure 7.16: Rich Client Platform browser application.
This project already has a Browser.product
file that you can turn into a stand-alone application, as we did above with HelloRCP.
7.6.2 Embedded Rich Client Platform (eRCP)
The RCP is aimed at developing platform-independent desktop applications. So what does that have to do with embedded development, you may ask? The answer is another Eclipse project called the embedded Rich Client Platform (eRCP). This project aims to bring the power of rich client applications to embedded and mobile devices.
To explain how eRCP differs from RCP, it’s necessary to delve a little deeper into the architecture of Eclipse. Referring back to Figure 1.1, the Eclipse workbench is built on top of two hierarchical graphical toolkits. The lower level toolkit is called the Standard Widget Toolkit (SWT), a Java-defined layer sitting on top of platform-dependent GUI components. Every platform on which Eclipse runs has its own native SWT layer, but the Java side of that layer is constant.
The JFace toolkit is built on top of the SWT and is a high-level GUI layer that addresses the needs of Eclipse itself. JFace provides components that create views and support events, control tasks using progress components, and manage UI resources such as fonts. Of course, the GUI requirements of Eclipse are common to many applications, which makes JFace useful outside the Eclipse environment.
eRCP implements a subset of the SWT called, not surprisingly, the embedded Standard Widget Toolkit (eSWT) that provides a set of controls, panels, and other widgets commonly used as building blocks of user interfaces in embedded devices Additionally, eSWT introduces a new component, mobile extensions, primarily targeted at the needs of mobile devices such as PDAs and smart phones.
The design of SWT emphasizes portability among operating systems by keeping the native code layer as small and simple as possible. That’s fine in desktop environments where there’s ample processor horsepower to compensate for the performance hit of platform-independent code. But in mobile devices, performance is a critical issue. So eSWT sacrifices portability to put more of the functionality in the native layer.
eSWT consists of three elements:
• Core
• Expanded
• Mobile extensions
Figure 7.17 illustrates where eSWT fits in the scheme of things.
Figure 7.17: eSWT UI toolkit architecture.
eRCP then is a collection of runtime libraries supporting a range of platforms that includes:
• Windows Mobile 2003/5/6
• WindowsCE 5.0 Professional
• Nokia series 80: Includes emulator
• Windows desktop: For testing
Unfortunately, there’s no Linux runtime, so in order to play around with eRCP, you’ll need a Windows Eclipse installation. Download the latest version of the Windows desktop runtime from the eRCP Download Page at http://www.eclipse.org/ercp/downloads-page.html. This is a zip file that creates its own directory. I suggest unzipping it in your Eclipse directory.
The eRCP package includes three fairly simple demos that are started from batch files. Try them out. Unfortunately, the demos don’t appear to include source code. There is an example[9] with source code in your EclipseSamples/
directory in the form of a JAR file that you’ll need to import into Eclipse.
Click File→Import…, expand Plug-in Development and select Plug-ins and Fragments. This brings up the dialog in Figure 7.18. In the Import from section, uncheck The target platform and browse to your EclipseSamples/
directory. In Import As, select Projects with source folders and click Next. Only one plug-in will be found. Select that and Add it to the Plug-ins and Fragments to import list. Click Finish.
9
This particular example comes from a paper describing the embedded Rich Client Platform posted at IBM’s Developer Works, at http://www-128.ibm.com/developerworks/opensource/library/os-ecl-rcp/. Check it out.