Riena - A New Adventure In Eclipse
Creating a UI Using Riena
Now that we have installed the Riena UI Wizard, we can see some example code quickly. Here's a step by step to get to one of the Riena project templates:
- Create a new Plug-in Project, but make sure to base it on Eclipse 3.4
- Check "This plug-in will make contributions to the UI" and select Yes to create a rich client application
- You will get four different Riena options in the template list. Here we'll select Riena Mail Template

Once you click Finish you will be presented with your Riena mail project. Let's take a quick look at how the application looks, before we start to investigate the code.
To run the application, simply open the plugin.xml and chooose Launch an Eclipse Application

The following is the screen that you will be presented with - I'm sure you'll agree it's pretty slick, and different to any RCP application that you probably developed so far.
A Different User Interface
The following are the key points in the plugin definition that make Riena UIs different to standard RCP UIs.
- In the plugin manifest, you'll see that as well as including org.eclipse.ui, there is also a dependency on org.eclipse.riena.client
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.riena.client - The main class of the Riena application is created as an org.eclipse.core.runtime.applications extension in the plugin.xml
<extension
We will look at this class in more detail shortly.
id="application"
point="org.eclipse.core.runtime.applications">
<application>
<run
class="com.dzone.riena.tests.Application">
</run>
</application>
</extension> - An instance of org.eclipse.riena.navigation.ui.swt.views.SubApplicationView is created as a perspective. This will be called later from the main Application class.
Everything else is as in any standard RCP application. The views, menus and handlers are all written as normal. So, let's take a closer look at the Application class.
The class extends org.eclipse.riena.navigation.ui.swt.application.SwtApplication. The key part of this class is the overridden createModel method.
protected IApplicationNode createModel() {
ApplicationNode app = new ApplicationNode("Riena Mail"); //NON-NLS-1
ISubApplicationNode subApp = new SubApplicationNode("Your Mail"); //NON-NLS-1
app.addChild(subApp);
WorkareaManager.getInstance().registerDefinition(subApp, "rcp.mail.perspective"); //NON-NLS-1
IModuleGroupNode groupMailboxes = new ModuleGroupNode(new NavigationNodeId(Application.ID_GROUP_MBOXES));
subApp.addChild(groupMailboxes);
IModuleNode moduleAccount1 = new ModuleNode("me@this.com"); //NON-NLS-1
groupMailboxes.addChild(moduleAccount1);
moduleAccount1.setClosable(false);
.......
return app;
}The ApplicationNode is represented by the entire application's shell, while the current tab that is open is an ISubApplicationNode. The best way to illustrate this is to add a new node, which we'll name "Search".
ISubApplicationNode searchApp = new SubApplicationNode("Search"); //NON-NLS-1
app.addChild(searchApp);
As I haven't associated a perpective with the sub application, all this will do right now is contribute a tab.
Adding Content To The Search Tab
To add some simple UI content into the search tab, we can take the following short cut:
- In plugin.xml, copy the Riena Perspective and create your own perspective. Just change the name and id of this new perspective. Note, we still use the same class.
<perspective
Now we we click on our Search tab, we will see an empty view. As you would expect, the menu and toolbar items remain the same when you click into the Search tab.
class="org.eclipse.riena.navigation.ui.swt.views.SubApplicationView"
id="rcp.search.perspective"
name="Search Perspective">
</perspective> - Next we need to provide a ViewPart for the Search tab. Again, let's take the quick way out of this and copy the existing view, changing a few of the parameters.
<view
The view class itself extends ViewPart as in any standard RCP application. All we'll do in this class is define the ID as a constant and create some content for the view in the createPartControl method.
allowMultiple="true"
class="com.dzone.riena.tests.SearchView"
icon="icons/sample2.gif"
id="rcp.search.view"
name="Search">
</view> - Modify the Application class to include this new view as follows
//create a group node for the search content
First we create a group node to act as a container for our Search screen. Then we provide an IModuleNode. This will create a navigation item on the left hand side. We then add the SearchView as the submodule for this navigation node
IModuleGroupNode searchGroupNode = new ModuleGroupNode();
searchApp.addChild(searchGroupNode);
//create a module note for searching
IModuleNode searchScreen = new ModuleNode("Search Screen"); //NON-NLS-1
searchGroupNode.addChild(searchScreen);
createSubMobule("Search", searchScreen, SearchView.ID); //NON-NLS-1
I would be interested to find out if there's any way of avoiding having those nodes appear on the left hand side.
The createSubMobule method is provided along with the example, so I won't go into it here.
Here's the resulting screen. As you can see, putting together the pieces for a UI in Riena is pretty easy.
A Custom Look & Feel For Your Application
So far we have seen that a Riena UI can look dramatically different a standard RCP UI. The final UI aspect that I will go through here is how to change the Look & Feel of the application.
First, you will need to create a theme, by implementing the ILnfTheme from Riena. This allows you to add custom colors, fonts, images and settings. An easier way to do this is to extend the RienaDefaultTheme, as this will have all the necessary parts set up.
For this example we'll just change the background colour of submodules, and the coolbar
public class NewTheme extends RienaDefaultTheme {
public void addCustomColors(Map<String, ILnfResource> table) {
super.addCustomColors(table);
table.put(LnfKeyConstants.SUB_MODULE_BACKGROUND,
new ColorLnfResource(186, 193, 225));
table.put(LnfKeyConstants.COOLBAR_BACKGROUND,
new ColorLnfResource(186, 193, 225));
}
}
Next, create a class to extend RienaDefaultLnf that can instantiate this new theme
public NewLnf()
{
super();
setTheme(new NewTheme());
}
protected String getLnfId()
{
return "newLnf";
}
In the constructor of the Application, just call the LnfManager to make the change to the look and feel of the entire application
public Application()
{
super();
LnfManager.setLnf(new NewLnf());
}
We now have a complete change in our entire UI. I really like this look and feel concept in Riena, which is not that far from the Swing concept.
James is a DZone Zone Leader and has posted 231 posts at DZone. You can read more from them at their website.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
Christopher Brind replied on Tue, 2009/03/31 - 3:51am
Great stuff. Wasn't aware of Rienna, but I am definatlely putting this on my hot list. Thanks for the info.
Tom Meier replied on Tue, 2009/03/31 - 6:33am
Nice article, James. Rienna looks quite nice and looks like it's making life for us RCP developers a lot easier. However I think there's one big disadvantage to Rienna: Again we're relying on a different framework for multiple application layers such as services and UI. On the other hand an all-in-one solution such as seems to be good enough for small to mid-sized applications. I'm curious as to see whether this framework finds its place among all the other frameworks in the Java world.
Nevertheless a great article and surely looks like you spent a bit of time here :) Keep up the good work!
Tom
James Sugrue replied on Tue, 2009/03/31 - 7:05am
in response to: tmeier
Thanks Tom
I see what you mean, and it has crossed my mind that this is another approach to the same problem. But I think projects in Eclipse work closely enough, and that there could be some crossover with what Riena does and what ECF provides in remote services. I'm sure we'll see one recommended approach to remote services soon enough, at least in the Eclipse community
James
slim.ouertani replied on Tue, 2009/03/31 - 11:03am
James Sugrue replied on Tue, 2009/03/31 - 11:05am
in response to: slim.ouertani
Thanks Slim!
Should appear just at the bottom of the article : http://java.dzone.com/sites/all/files/RienaExample.zip
Denis Robert replied on Tue, 2009/03/31 - 1:32pm
Elias Volanakis replied on Tue, 2009/03/31 - 2:04pm
ekke replied on Tue, 2009/03/31 - 2:20pm
in response to: tmeier
slim.ouertani replied on Tue, 2009/03/31 - 5:40pm
in response to: jsugrue
James Sugrue replied on Wed, 2009/04/01 - 1:38am
in response to: drobert_bfm
Hi Denis
I ran this using Gailileo 3.5M6 and the latest release of Riena. All fully tested
James
James Sugrue replied on Wed, 2009/04/01 - 1:44am
in response to: slim.ouertani
Roman Porotnikov replied on Wed, 2009/04/01 - 4:55am
mogy replied on Sun, 2009/04/12 - 10:14pm
James Ervin replied on Thu, 2009/04/30 - 10:20am
James Sugrue replied on Thu, 2009/05/14 - 2:14am
in response to: jeervin
luckey replied on Tue, 2009/06/30 - 12:46am
GarryWert replied on Sat, 2009/10/03 - 3:23am