Eclipse Riena Tutorial - All In One - With Eclipse Galileo SR2

Tihomir R. Todorov

Version 0.3.1
Copyright © 2010 - 2011 Tihomir R. Todorov
01.14.2011
Revision HistoryCommentDateName
tutorial.eclipse.riena.all-in-one-galileo_0.3.1.v20110114-1852Refactoring + Chapter 6 added.01.14.2011Tihomir R. Todorov
tutorial.eclipse.riena.all-in-one-galileo_0.3.0.v20101206-0107Chapter 5 added.12.06.2010Tihomir R. Todorov
tutorial.eclipse.riena.all-in-one-galileo_0.2.0.v20101130-0127Chapter 4 added.11.30.2010Tihomir R. Todorov
tutorial.eclipse.riena.all-in-one-galileo_0.1.0.v20101128-1542Chapter 3 added.11.28.2010Tihomir R. Todorov
tutorial.eclipse.riena.all-in-one-galileo_0.0.2.v20101127-2030Chapter 2 refactoring.11.27.2010Tihomir R. Todorov
tutorial.eclipse.riena.all-in-one-galileo_0.0.1.v20101115-1633Article created.11.15.2010Tihomir R. Todorov

Contents

1 Eclipse Riena
2 Getting Started
2.1 What is The Riena Project?
2.2 Download and install Java JDK SE
2.3 Download and install Maven 3
2.4 Download and install Eclipse
2.5 Download and install M2Eclipse
2.6 Setting up your Eclipse
2.7 Setting up Riena 1.1.0.0 target
3 Creating your first Riena Plug-In from scratch
3.1 Creating a Riena Plug-In
3.2 Setting up your Riena Plug-In
3.3 Start your Riena Plug-In
4 Creating your first Riena Product/Application
4.1 Creating your product configuration
4.2 Creating a plugin-based Product
4.3 Creating a feature-based Product
4.4 Launch your product
4.5 Creating a standalone Application
5 Building a Riena Application with Maven
5.1 Building a Riena Application with Maven based on Manifest-first
5.2 Building a Riena Application with Maven using third-party jar-files
5.2.1 Using a plugin like container
5.2.2 Using pom-first
6 Important Message
x Coming soon ...
Your Feedback / Your Question
Riena Forum
Riena Chat
References

1 Eclipse Riena

This tutorial describes how to develop Riena Applications like the Pro's from scratch (without fancy wizards and templates) using Tycho's and Maven 3's power. It is based on Eclipse 3.5.2 (Eclipse Galileo) and Microsoft Windows XP Professional SP 3.

2 Getting Started

You are 6 steps away from starting to write Riena applications like the Pro's:

This title will lead you through these steps.

2.1 What is The Riena Project?

To know more about The Riena Project you can read here.

2.2 Download and install Java JDK SE

To know how you can set up your java development environment visit the java tutorial Set up your Java Development Environment.

2.3 Download and install Maven 3

To know how you can set up your system to build with Maven visit the maven tutorial Setting up your Maven Development Environment.

2.4 Download and install Eclipse

Download "Eclipse for RCP/Plug-in Developers" from the website Eclipse Downloads and unzip the distribution archive, i.e. eclipse-rcp-galileo-SR2-win32.zip to the directory you wish to install Eclipse 3.5.2. These instructions assume you chose C:\Portable\eclipse-rcp-galileo-sr2-win32-riena.

2.5 Download and install M2Eclipse

This point is not important but useful.

// TODO

2.6 Setting up your Eclipse

To verify that your setting are OK visit the eclipse tutorial Setting up your Eclipse.

2.7 Setting up Riena 1.1.0.0 target

To set up the Riena Target Platform we need to download the following three componets from the website "Galileo - http://download.eclipse.org/releases/galileo":

The eclipse tutorial Setting up your Target Platform describes how you can do it.

3 Creating your first Riena Plug-In from scratch

The following gives a quick guide on how to create a simple Riena Plug-In from scrath.

3.1 Creating a Riena Plug-In

In Eclipse select File->New->Project.... From the list select "Plug-In Project". Press "Next >".

Give your plugin the name "de.family_todorov.riena.app01.plugin" and press "Next >".

Make the following settings. Press "Next >".

Do not use a template. Press "Finish".

You have created now a project with the following structure.

Done!

3.2 Setting up your Riena Plug-In

Open the file "MANIFEST.MF" by double-clicking on it and select the "Dependencies" tab. Remove the both required plug-ins "org.eclipse.ui" and "org.eclipse.core.runtime". Press the "Add..." button. Search for the plug-in "org.eclipse.riena.client". Select it and press "OK".

This exports all other dependencies which are required for building Riena applications.

Open the file "MANIFEST.MF" by double-clicking on it and select the "Extensions" tab. Press the "Add..." button.

Search for the extension "org.eclipse.core.runtime.applications". Select it and press "Finish".

Create a new run-application by right-clicking on your extension point and by selecting New->run.

Enter the class to "de.family_todorov.riena.app01.plugin.applications.SWTApp01FromScratch". Press the hyperlink "class*:" to create this class and select "org.eclipse.riena.navigation.ui.swt.application.SwtApplication" as Superclass. Press "Finish".



Implement the following coding.

    package de.family_todorov.riena.app01.plugin.applications;

    import org.eclipse.riena.navigation.IApplicationNode;
    import org.eclipse.riena.navigation.ui.swt.application.SwtApplication;
    import org.osgi.framework.Bundle;

    import de.family_todorov.riena.app01.plugin.internal.Activator;

    public class SWTApp01FromScratch extends SwtApplication {

       @Override
       protected Bundle getBundle() {
         return Activator.getDefault().getBundle();
       }

       @Override
       protected IApplicationNode createModel() {
         IApplicationNode applicationNode = super.createModel();
         applicationNode.setLabel("Sample SWT App 01 Plugin");
         return applicationNode;
      }
    }
      

3.3 Start your Riena Plug-In

There are two aternatives to start your Riena application.

The result should look like the following:

Congratulations, you have created your first Eclipse Riena Plug-In.

4 Creating your first Riena Product/Application

This chapter describes how you can create a product like stand-alone riena application outside the Eclipse IDE.

4.1 Creating your product configuration

Create a new General Project using File->New->Project... and from the list select General->Project then click "Next >".

Give your project the name "de.family_todorov.riena.app01.product" and press "Finish".

Right-click on the project "de.family_todorov.riena.app01.product" and select New->Product Configuration.

Name your product configuration "de.family_todorov.riena.app01.product.product". Select "Create a configuration file with basis settings" and then press "Finish".

Open the file "de.family_todorov.riena.app01.product.product" and select the "Overview" tab. Maintain the ID: "de.family_todorov.riena.app01.product" and name "Riena Product" for your product.

Press "New..." in the "Product Definition" part and select the application of your plugin "de.family_todorov.riena.app01.plugin.application" then click "Finish".


A product can either be based on plugins or features. Chapter 4.1 describes how you can create a plugin-based product and chapter 4.2 describes a quick intro on how to create a feature-based product.

4.2 Creating a plugin-based Product

Press the plug-ins radio button and then click the link "product configuration".

In "Dependencies" tab click "Add...", select the plugin "de.family_todorov.riena.app01.plugin", press "Add Required Plug-ins" then CTRL+S (save).

Now you are done! Go to the chapter 4.4 Launch your product to start your application.

4.3 Creating a feature-based Product

We will build a feature-based product so we will create two feature projects. The first feature project will contain our application-defining plug-in and the second feature project will contain all other plug-ins that are required from our plug-in i.e. the second feature plays the role of the target platform.

Let's create the features!

File->New->Project.... From the list select Plug-in Development->Feature Project then press "Next >".

See the screanshots below for how i created my first feature.

The feature contains a feature.xml, which is used to define which plug-ins constitutes the feature.

Analog to the first feature we should create a second feature with the following data:

When asked for plug-ins to include in the feature we should reference all plug-ins that are need for our plug-in. The screanshot below shows a sample-list for Riena 1.1.0.0 Target Platform.

We need to create now the product definition that constitute our product. This will include the feature projects that we created previously.

Open the file "de.family_todorov.riena.app01.product.product" and select the "Overview" tab. Press this time the feature radio button and then click the link "product configuration".

In "Dependencies" tab click "Add..." then select the features "de.family_todorov.riena.app01.feature" and de.family_todorov.riena.app01.featureTargetPlatform. Save the changes with CTRL+S.

Now you are done! Go to the chapter 4.4 Launch your product to start your application.

4.4 Launch your product

On the "Overview" tab press "Synchronize" and then press "Launch an Eclipse application".

If you receive the error "Dependent plug-in could not be loaded" or "Application could not be found" then you may have to adjust your launch configuration. Open the launch configuration using Run->Run Configurations..., from the list select Eclipse Application->de.family_todorov.riena.app01.product.product and then press the "Plug-ins" tab. Press "Add Required Plug-ins" then press "Validate Plug-ins" to verify that there can not be found problems.


Done!

4.5 Creating a standalone Application

Open the product configuration file and select the tab "Overview". Click on the "Eclipse Product export wizard" to export your product.

Give a directory for your destination (in my case C:\Temp\Riena App 01) and press "Finish".

This should create a directory "eclipse" in the specified place with includes a file "eclipse.exe" which starts your application. Double click on it to start your application.

The better alternative is if you use Maven to build your application voll automatically or that is to say:
Build it in One Click

5 Building a Riena Application with Maven

Today i am going to show how we can build a simple Riena Application with Maven 3 and Tycho. I used Tycho 0.10.0 and Eclipse 3.5.2.

Maven is a great tool to managed your dependencies automatically. It's very helpful when we developed a real complex application. But Maven can more and more... For more information on how you can use Maven, see the Maven HOME page.

5.1 Building a Riena Application with Maven based on Manifest-first

To eliminate conflicts make sure that your product based only on feature, i.e. you should remove all plugins from Chapter 4.2.

Create a new General Project using File->New->Project... and from the list select General->Project then click "Next >".

Give your project the name "de.family_todorov.maven_projects" and press "Finish".

Open the Navigator using Window->Show View->Other...->General->Navigator.Press "OK".

In Navigator you should see the following tree structure:

Click on "de.family_todorov.maven_projects/de.family_todorov.riena.app01" and create four new folders with the names

using File->New->Folder.

From the corresponding projects into the corresponding folders copy the following folders and files:

        -de.family_todorov.riena.app01.feature        -de.family_todorov.riena.app01.featureTargetPlatform
              |-build.properties                            |-build.properties
              |-feature.xml                                 |-feature.xml
      
        -de.family_todorov.riena.app01.plugin
              |-META-INF
              |    |-MANIFEST.MF
              |- src
              |    |-de
              |        |-family_todorov
              |            |+...
              |
              |-build.properties
              |-plugin.xml
      
        -de.family_todorov.riena.app01.product
              |-de.family_todorov.riena.app01.product.product
      

After this you should delete the projects from the hard disk.

Create a directory main/java/ in de.family_todorov.riena.app01.plugin/src and move de/ into main/java/.

Click on "de.family_todorov.riena.app01" and use the following maven command in the eclipse to generate the pom-files.

The result in the Console should look like the following:

Tycho can not create the pom-file for the product. Maybe there is a bug or something else. No matter, this is no problem. We can create it manual .

Just create a file pom.xml in "de.family_todorov.riena.app01.product" and copy-paste the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>de.family_todorov.riena.app01</artifactId>
        <groupId>de.family_todorov.riena.app01</groupId>
        <version>0.0.1-SNAPSHOT</version>
      </parent>
      <groupId>de.family_todorov.riena.app01</groupId>
      <artifactId>de.family_todorov.riena.app01.product</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>eclipse-application</packaging>
    </project>
      

After this you should edit the parent pom in "de.family_todorov.riena.app01" like the following:

    <modules>
      <module>de.family_todorov.riena.app01.feature</module>
      <module>de.family_todorov.riena.app01.featureTargetPlatform</module>
      <module>de.family_todorov.riena.app01.plugin</module>
      <module>de.family_todorov.riena.app01.product</module>
    </modules>
    <build>
      <plugins>
        <plugin>
          <groupId>org.sonatype.tycho</groupId>
          <artifactId>tycho-maven-plugin</artifactId>
          <version>0.10.0</version>
          <extensions>true</extensions>
        </plugin>
        <plugin>
          <groupId>org.sonatype.tycho</groupId>
          <artifactId>maven-osgi-packaging-plugin</artifactId>
          <version>0.10.0</version>
          <configuration>
            <environments>
              <environment>
                <os>win32</os>
                <ws>win32</ws>
                <arch>x86</arch>
              </environment>
            </environments>
          </configuration>
        </plugin>
      </plugins>
    </build>
      

Click on "de.family_todorov.riena.app01" and use the following maven command in the eclipse to create the application.

This should create a directory "target/win32.win32.x86/eclipse" in the "de.family_todorov.riena.app01.product" with includes a file "launcher.exe" which starts your application. Double click on it to start your application.

If you want to use my own p2 resolver to downlaod the target from internet just replace the corresponding xml-files from the table below:

LocationFile
.m2settings.xml
de.family_todorov.riena.app01pom.xml
de.family_todorov.riena.app01.featurepom.xml
de.family_todorov.riena.app01.featureTargetPlatformpom.xml
de.family_todorov.riena.app01.pluginpom.xml
de.family_todorov.riena.app01.productpom.xml

5.2 Building a Riena Application with Maven using third-party jar-files

5.2.1 Using a plugin like container

Workaround is to import all third-party jar-dependencies into the conrainer plug-in.

5.2.2 Using pom-first

For example i want to import a third-party-jar file called commons-lang-2.1.jar in my plug-in project.

Hier we go ...

First of all clean your project using Run->External Tools->mvn3 clean eclipse:clean

After this we need to modify the pom-files i.e. the pom file in the plugin project and the parent pom like the following:

pom.xml of plugin project
Add the following lines between properties and build section in the pom.xml file. This is called dependency on the pom-first project.

  <dependencies>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.1</version>
    </dependency>
  </dependencies>

pom.xml of the parent project
Add the following red line in the configuration section.

  <configuration>
    <resolver>p2</resolver>
    <pomDependencies>consider</pomDependencies>
    <environments>
      <environment>
        <os>win32</os>
        <ws>win32</ws>
        <arch>x86</arch>
      </environment>
    </environments>
  </configuration>

<pomDependencies>consider</pomDependencies> tells tycho target platform resolver (p2-based in this example) to consider <dependencies/> section.

In the rule with mvn3 eclipse:eclipse you can find all dependencies automaticaly. But this rule don't work for all jar files! e.g. commons-math-1.2.jar. If you have a such problem you must bind the jar manual.

After the command mvn3 eclipse:eclipse you should see the following.

And in the file MANIFEST.MF in the section Classpath of the Tab Runtime following:

The following code sample show on how to use the dependency in your plug-in project. Important lines are 7, 21 and 23.

   1 package de.family_todorov.riena.app01.plugin.applications;
   2 
   3 import org.eclipse.riena.navigation.IApplicationNode;
   4 import org.eclipse.riena.navigation.ui.swt.application.SwtApplication;
   5 import org.osgi.framework.Bundle;
   6 
   7 import org.apache.commons.lang.math.DoubleRange;
   8    
   9 import de.family_todorov.riena.app01.plugin.internal.Activator;
  10    
  11 public class SWTApp01FromScratch extends SwtApplication {
  12    
  13   @Override
  14   protected Bundle getBundle() {
  15     return Activator.getDefault().getBundle();
  16   }
  17    
  18   @Override
  19   protected IApplicationNode createModel() {
  20     IApplicationNode applicationNode = super.createModel();
  21     DoubleRange dr = new DoubleRange(666.456);
  22     applicationNode.setLabel("Sample SWT App 01 Plugin "
  23         + dr.getMaximumInteger());
  24     return applicationNode;
  25   }
  26 }
  27  

If you start now your application the result will be like the following:

The above text describes how to create a fully completed development environment for Riena with third-part-jar files. But if you want to create an application with mvn3 install, you must make some manual steps yet.

From now on you could build your application fully automatically using mvn3 install and you can bind it in hudsan too!

6 Important Message

I found a way on how to bring the both feature Eclipse Helios 3.6.1 and Riena 2.0.0.x in a relationship that's to say to works together . From now on i will continue to write the tutorial at this link here.

x Coming soon ...

Your Feedback / Your Question

Feedback Form - send your opinion, ask a question, ...

Riena Forum

Riena Forum - create your topic, take the answer to your question, ...

Riena Chat


Registrieren Zur Anmeldung Zur Anmeldung als Gast


References