Sponsors


Blog powered by TypePad

« When Broken: Fix it | Main | Flat Spot Shifting »

March 24, 2005

Painfree RCP in 3.1M5

This is the blog-workout sequel to my carefree "Eating the Eclipse 3.1M5 RCP Donut" post.  Presented here are four simple recipes for using the new 3.1M5 capabilities to create, configure, and export a Rich Client Platform (RCP) application out of one or more plug-ins.  It can all be done graphically and completely avoids messing with plugin.xml or hand-editing a .properties file.  Thanks, Eclipse RCP team for giving us this exquisite feature!

Getting Started
If you already have a working plugin, you might skip right to "Recipe 2: Creating a .properties file" below.  However, it's useful and easy to first experiment by creating a new plugin that automatically gives you some out-of-the-box RCP framework code, separately from any previously existing plug-ins you might have.  Later, you can integrate your plug-ins when you've moved up a little on the learning curve.

Recipe 1: Creating a plug-in with RCP Framework Code

  1. Right click in the Package Explorer and select "New > Project..."
  2. Select "Plug-in Project" and press "Next >"
  3. Enter your Project name (for this recipe, I'll call it "Temp") and press "Next >"
  4. Look for the new group "Rich Client Application" at the bottom of Plug-in Content wizard panel.  Where it asks "Would you like to create a rich client application?" choose "Yes."
  5. In the "Templates" wizard page, choose "RCP application with a view".
  6. Press "Finish".

This generates framework code for a Rich Client App with a simple view you can easily modify.  To do this, go to the generated "View.java" class in the *.rcp" package and rewrite the createPartControl() with your own SWT or JFace implementation.  Test your plug-in as an RCP application by selecting  "Run as > Eclipse Application".  When I did this, I saved this runtime configuration separately as "Temp".  To save a runtime configuration, select Run... and enter your your runtime name (see the Eclipse IDE Help for more info on this).

Recipe 2: Creating a .properties file

  1. Right click on the plugin you want to use as the basis for your RCP application in the Package Explorer.  Select "New > Product Configuration."  This is new for 3.1M5!
  2. Enter your File name (must end with ".product").
  3. To create an bare-minimal RCP app, in the "Initialize the file content" section, choose "Create a configuration file with basic settings"
  4. Press "Finish".

This will bring up the .properties "Overview" page which you'll recognize as similar to the plugin.xml overview.  The next recipe will cover configuring your RCP application.  To be brief, I've omitted any discussion on branding.

Recipe 3: Configuring your RCP Application .properties

  1. Click on the .properties file to bring up the Overview page (showing the Overview tab).
  2. Select a "Product ID:" by clicking "New...". 
  3. In the "Product Definition" dialog, choose a "Defining Plug-in:" by clicking "Browse..." and choosing the core plug-in for your RCP app.  To continue my example, I selected "Temp (1.0.0)".
  4. Enter a "Product ID:".  Continuing my example, I entered "temp_product_1".
  5. In the "Product Application" section, select the .application configuration that will serve as the entry point for running your RCP app.  For the running example, I picked my previously saved "Temp.application".
  6. Press "Finish".
  7. Click on the "product configuration" link to add the plug-ins that will make up your RCP app. This will take you to the "configuration" tab.
    Click "Add" and select your plugin.  Repeat until all the plug-ins you want bundled have been added.
    Click "Add Required Plug-ins".  This will resolve your plug-in's dependencies and any plug-ins that are also needed to host and run your RCP app.
  8. Save.

You should notice that your Overview page has been populated with the Product ID, Application, and Product name with "plug-ins" selected by default (note here that you would choose "features" if you were working with features and not plug-ins).  At this point, you can test your RCP app by clicking the "Launch the product" link in the Overview page's Testing section.  Make sure it runs before cooking the next, final recipe.

Recipe 4: Exporting your RCP Application

Now that you've created a .properties file, configured your RCP application, and tested it, you're ready to export this thing.  In case you the flow of things didn't sink all the way in yet, here's one last recipe:

  1. Click the "Synchronize" link in the .properties Overview page.  To make sure all .properties file references to dependent plug-ins are current.
  2. Enter an "Archive:" name for your RCP app.  By default, .zip is the file type.
  3. Click the "Export" link in the .properties Overview page.  This will zip up everything that is necessary to run your RCP application.

To run your RCP app, just unzip the contents of the zip anywhere you like and click on "eclipse.exe".  Viola!  Branding your app is even easier.  Just click the "branding" tab on the .properties Overview tab and intuitively step through it.  On a final note, distributing RCP apps can be done rather quickly as well.  For info on this, you might want try downloading and dissecting Ed Burnette's example in SourceForge.

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/t/trackback/277049/2121422

Listed below are links to weblogs that reference Painfree RCP in 3.1M5:

Comments

Post a comment

If you have a TypeKey or TypePad account, please Sign In