Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

Eclipse RCP Blog


Yet another blog for Eclipse RCP topics, like good Eclipse RCP architecture, software architecture control, ...

Eclipse RCP 3.x with Compatibility Layer

Today I want to show a step-by-step tutorial how to build a simple Eclipse RCP 3.x application based on Eclipse Mars.

Motivation

  • There exists many Eclipse RCP 3.x applications, which cannot be moved to the latest Eclipse RCP version.

  • There are a few descriptions in the internet what must be done to use the Compatibility Layer, but no step-by-step tutorial

Background

Prerequisite

Tutorial

To create a simple feature-based Eclipse RCP 3.x application we need for plug-ins:

  • One plug-in with UI logic (here only an example table): io.rage5474.rcp.example.ui.plugin

  • One feature plug-in with represents the feature for the UI plug-in(s): io.rage5474.rcp.example.ui.feature

  • One target platform plug-in, which contains only the taegt platform file: io.rage5474.rcp.example.tp

  • One product plug-in, which contains the product configuration: io.rage5474.rcp.example.product

So let us start.

Create sample plug-in

First we create the plug-in io.rage5474.rcp.example.ui.plugin with our simple application logic. Therefore we use the integrated plug-in generator. Go to File → New → Other and select Plug-in Project from the folder Plug-in Development.

comp layer tut 1.png

After clicking Next you have to add your plug-in name, here io.rage5474.rcp.example.ui.plugin.

comp layer tut 2.png

After clicking Next we have to select the option Would you like to create a rich client application? to Yes.

comp layer tut 3.png

Again a click on Next leads us to the plug-in generator. Select here RCP 3.x application with a view

comp layer tut 4.png

and Finish the dialog. In the end you should have a new plug-in in your workspace, that looks similar to this one:

comp layer tut 5.png

Cool, first step was successful. Let us go on.

Create sample feature

As I think it is better to work with feature (groups of plug-ins) instead of working only with plug-ins, we have to create a feature plug-in, that contains in the end only one plug-in. We name the feature plug-in io.rage5474.rcp.example.ui.feature.

So start again with File → New → Other and select Feature Project from the folder Plug-in Development. Enter the feature name io.rage5474.rcp.example.ui.feature and click Finish.

comp layer tut 6.png

Now you should have a second plug-in in your workspace. Open the file feature.xml (simply be double-click), which is located in io.rage5474.rcp.example.ui.feature. Go to the tab Included Plug-ins on the bottom of the editor and click Add. A new window should come up. Select the plug-in with the name io.rage5474.rcp.example.ui.plugin and click OK.

comp layer tut 7.png

Save the feature.xml file (CTRL-S).

So step 2 was also successful!

Create target platform plug-in

Now we must create our target-platform (contains all Eclipse RCP plug-ins we need to get our application running!). I decided to use here Eclipse Mars as target platform. So we put the target platform file in a separate plug-in. We start again with File → New → Other and select Project from the folder General. Enter the corresponding plug-in name, here io.rage5474.rcp.example.tp and click Finish.

comp layer tut 8.png

Now we add a Target Definition file to this project. Go to File → New → Other and select Target Definition from the folder Plug-in Development and click Next.

comp layer tut 9.png

Now select the our target platform plug-in io.rage5474.rcp.example.tp, add mars.target as File name and select the option Nothing from the section Initialize the target definition with: and click Finish.

comp layer tut 10.png

Now we have our third plug-in. At the moment our Target Definition file is empty. So open it with a double-click on the file mars.target and click the Add button to add a Software Site to this Target Definition.

comp layer tut 11.png

Select Software Site and click Next.

comp layer tut 12.png

Enter following URL in the field Work with and hit enter: http://download.eclipse.org/releases/mars . Search and select following three features:

  • Eclipse RCP

  • Equinox p2, minimal support for RCP applications

  • Eclipse Platform Launcher Executables

comp layer tut 13.png

Use the search field to find the right feature fast. Tip: Disable Group by Category.

comp layer tut 14.png

Click on Finish and click Set as Target Platform. After a while the target platform should be available.

Create sample product

So we almost finished. We only need the possibility to start our application, therefore we need a product file. We separate this again in a new plug-in. We start again with File → New → Other and select Project from the folder General and enter the plug-ins name io.rage5474.rcp.example.product and click Finish.

comp layer tut 15.png

Now we have to add a Product Configuration file to that plug-in. We create this with File → New → Other and select Product Configuration from the folder Plug-in Development and click Next.

comp layer tut 16.png

Select the right plug-in (io.rage5474.rcp.example.product) and enter a product configuration file name, here example.product and click Finish.

comp layer tut 17.png

Now we have to configure our product. Open the product file (example.product) by double clicking. Click on new and select the plug-in io.rage5474.rcp.example.ui.plugin in the field Defining Plug-in and enter a Product ID, e.g. rcp_product. Before clicking Finish switch the toogle button from plug-ins to features.

comp layer tut 18.png

Now switch to the tab Contents and add following feature by clicking on the Add button:

  • org.eclipse.rcp

  • org.eclipse.emf.common

  • org.eclipse.emf.ecore

  • io.rage5474.rcp.example.ui.feature

comp layer tut 19.png

Now we have to modify the run configuration. Switch to the tab Configuration and select Add Recommended.

comp layer tut 20.png

Save your product definition file (CTRL-S) and switch back to the tab Overview and click the link Synchronize from the section Test.

Launch example application

Now we can give it a try. Click the link Launch an Eclipse Application again from the section Testing. The result should look similar to this:

comp layer tut 21.png

Source Code

The full example source code can also be found here: https://github.com/rage5474/rcp.3.x.comp.layer.example .


Discussions

comments powered by Disqus