Nuxeo RCP: the developer Guide

Nuxeo SAS

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2; with Invariant Section “Commercial Support”, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at the URL: http://www.gnu.org/copyleft/fdl.html


Table of Contents

1. Introduction
1.1. Overview
1.2. Features
1.3. Advanced, experimental and custom features
1.4. A production-ready platform
2. Exploring Nuxeo RCP
2.1. Requirements
2.2. Installation from a packaged binary
2.3. (Alternative) Installation from the update site
2.4. First tour of Nuxeo RCP
2.4.1. Prepare and launch your Nuxeo EP server
2.4.2. Connect Nuxeo RCP to Nuxeo EP
3. Setting up your development environment
3.1. Requirements
3.2. Environment Setup
3.2.1. Install Eclipse and required external plug-ins
3.2.2. Install the Nuxeo RCP plug-ins
3.2.3. Enjoy
3.2.4. Launching your first Nuxeo RCP development product
3.3. Building Nuxeo RCP
3.3.1. Using the Eclipse export wizard
4. Creating a new software component for Nuxeo RCP
4.1. Creating a new plugin component
4.1.1. Creation of the plugin
4.1.2. Plugin dependencies
4.2. Document tabs
4.3. Viewers in Nuxeo
4.3.1. Adapters as providers.
4.3.2. Table/Tree columns
5. Managing internationalisation with Nuxeo RCP
5.1. Making your plugin "internationalizable"
5.1.1. Simple rules
5.1.2. Java files
5.1.3. Externalize plugin.xml
5.2. Contributing a language pack.
6. Actions in Nuxeo RCP
7. Nuxeo RCP extension points
7.1. Customize user attributes in the add/edit/view user forms
7.1.1. Different configurations
7.1.2. Contribute to the extension point
A. Commercial Support
A.1. About Us
A.2. Contact information
A.2.1. General
A.2.2. France
A.2.3. UK

Chapter 1. Introduction

Nuxeo RCP (codenamed "Apogee") is a rich client platform dedicated to ECM applications, based on the Eclipse RCP framework and the Nuxeo core document management services (Nuxeo SP).

The Nuxeo ECM stack

Figure 1.1. The Nuxeo ECM stack


1.1. Overview

Web-based (also called "thin client") ECM applications, such as Nuxeo EP, can usually provide a user interface that's good enough for most of the use cases, specially with the advent of rich web interfaces using Ajax techniques.

There are, however, business cases where a web-based application is not the best choice from a user interface standpoint:

  • When user productivity is tight to the amount and customizability of information that can be displayed on the screen (including multi-screens displays).

  • When the user interface needs to provide a high level of interaction between its various graphical components. For instance, updating data in one part of the screen needs to trigger an immediate update in another part of the UI.

  • When users need to edit content that is not well-suited for being edited in a browser, for instance, rich text or images, or not at all, for instance sound and video.

  • When users must interface the application with hardware connected to their computer, such as a scanner or audio/photo/video capture equipment.

  • When users need to take their ECM applications offline and keep on working on their document management tasks.

Nuxeo RCP is a platform dedicated to developing client applications with a rich user interface that can address these needs while still providing all the document management features of the Nuxeo ECM platform.

1.2. Features

Nuxeo RCP currently provides the following features:

  • All the document management functions of Nuxeo EP are also exposed as RCP graphical components, including: document tree navigation, document editing, search, users management, etc.

  • An XHTML editor with advanced features such as custom spellchecking.

  • An image browser similar to Picassa or iPhoto.

  • An image editor, which supports multi-views (high def., full size, medium size, thumbnail), rotate/crop/resize, pre-defined sizes, size profiles, etc.

1.3. Advanced, experimental and custom features

As it is based on the highly extensible, and industry-standard, Eclipse RCP framework, Nuxeo RCP can easily be extended to provide users with user interface components, or other functions, that fit the business needs of specific use cases, for instance:

  • Synchronous collaborative rich text editor: a text editor component that enables user to collaboratively edit a single piece of HTML content has been developed by Nuxeo and can easily be adapted to new projects.

  • Presence and instant messaging: a component, based on the Jabber protocol, has already been developed to enable workers across the world to coordinate their activities around one document or set of documents.

  • Teletext editor: a teletext editor has been developed for one of Nuxeo's customers, the Press Association.

  • Audio and video editing components could be created by encapsulating existing audio / video editing libraries into Eclipse plugins.

  • Etc.

1.4. A production-ready platform

Nuxeo RCP has been used in several mission-critical projects, including two projects for two of the leading news agencies in the World: AFP (Agence France-Presse) and PA (Press Association).

The AFP "Console NG" for multimedia news production and management

Figure 1.2. The AFP "Console NG" for multimedia news production and management


The PA Teletext Console

Figure 1.3. The PA Teletext Console


For more information about these two projects, please refer to the case studies that have been published on the Nuxeo website on http://www.nuxeo.com/.

Chapter 2. Exploring Nuxeo RCP

Nuxeo RCP is a set of rich client platform plugins that can connect to a Nuxeo EP server and browse its documents using native graphical widgets. It can be used to extend any product based on Eclipse RCP.

Nuxeo RCP can be used for different purposes:

  • As a platform, for developing specific RCP products that have to connect to a Nuxeo EP server

  • As a development tool, to help troubleshooting a Nuxeo EP instance, by installing Nuxeo RCP in your Eclipse IDE.

  • As a standalone application, to connect and browse an existing Nuxeo RCP.

In this chapter, we will install some Nuxeo RCP components in the Eclipse IDE and use them from there.

2.1. Requirements

  • Nuxeo EP 5.2 (m1 or more recent snapshot)

  • Eclipse IDE 3.3.2

  • Java 5

2.2. Installation from a packaged binary

Prebuilt versions of the software are provided by Nuxeo to ease the task of trying out Nuxeo RCP for the first time.

Just download the appropriate Nuxeo RCP package for your platform (only Windows and Linux packages are provided at the moment) from http://download.nuxeo.org/nuxeo-rcp/products/releases/, unzip them, and launch the application.

2.3. (Alternative) Installation from the update site

If you already have an Eclipse 3.3 installation and you want to try out Nuxeo RCP from it, you can alternatively download the Nuxeo RCP plugins using the Eclipse updater:

  • In Eclipse, go to Help > Software Updates > Find and Install ...

  • Select "Search for new features to install"

  • Add a new remote site name "Nuxeo RCP" using the URL http://download.nuxeo.org/nuxeo-rcp/updates/ or http://download.nuxeo.org/nuxeo-rcp/updates/snapshots for snapshots versions

2.4. First tour of Nuxeo RCP

2.4.1. Prepare and launch your Nuxeo EP server

To fully works with Nuxeo RCP, Nuxeo EP may have to be bound to its DNS address or IP address. If you have connection errors while connecting with Nuxeo RCP, try the following instructions:

  1. in $JBOSS_HOME/server/default/deploy/nuxeo.ear/config/nuxeo.properties and $JBOSS_HOME/server/default/deploy/nuxeo.ear/datasources/core-events-ds.xml replace all "localhost" by the IP adress or DNS name of the JBoss server

  2. start JBoss with the -b option: ./run.sh -b IP_adress_or_DNS_of_the_server

2.4.2. Connect Nuxeo RCP to Nuxeo EP

Nuxeo RCP provides a perspective that holds the main Nuxeo RCP views: Window > Open perspective > other ... and Select Nuxeo ECM.

Create a new connection and connect to it with the ECM Applications view.

Once connected, browse the Nuxeo EP content using the ECM Navigator.

Chapter 3. Setting up your development environment

This section explains what you need and how you should prepare your environment in order to be able to develop your own plug-ins based on Nuxeo RCP.

3.1. Requirements

  1. Eclipse 3.3 with the RCP/Plug-in Developers profile, from http://www.eclipse.org/downloads/moreinfo/rcp.php

  2. Java 5, from http://java.sun.com/j2se/1.5.0/

  3. Nuxeo ECM 5.2.M1 (or recent trunk version). Please refer to the installation guide for this product for more details.

  4. The SWT HTML composer plug-in, from http://www.eclipsian.org/swt-composer/update/. This is mandatory only if you need the HTML editing support in Nuxeo RCP. If you dont want this you need to disable the HTML editing plug-in from Nuxeo RCP. (Just remove it)

  5. A SVN client or the Subversive or Subversion plug-ins for Eclipse.

3.2. Environment Setup

3.2.1. Install Eclipse and required external plug-ins

  1. Install at least Eclipse 3.3 for RCP/Plugin developers

  2. Install the SWT HTML composer plug-in from the following update site: http://www.eclipsian.org/swt-composer/update/

  3. Optionally install ECF plugins if you need the chatroom and share editor support from eclipse update site

3.2.2. Install the Nuxeo RCP plug-ins

Set up your eclipse to build your nuxeo-rcp platform to build your own product can be done using nuxeo-rcp plugins from the update site.

  1. Install the Nuxeo RCP core plug-ins (the plug-ins that are shared with the server). For this you can use the following update site: http://download.nuxeo.org/nuxeo-rcp/updates/

  2. Be sure to select the plug-ins when using this update site as indicated in the figure below and click to "select required":

    Tip

    You can also select the source category that may be useful for debuging nuxeo-ep core plugins deployed in nuxeo-rcp.

The other way to work with nuxeo-rcp, is to checkout from source. It's useful especially for modifying the nuxeo-rcp product and contribute to the community

  1. Install the Nuxeo RCP plug-ins from SVN. Check-out the entire directory at: http://svn.nuxeo.org/nuxeo/nuxeo-rcp/trunk

  2. In nuxeo apogee core, do a "mvn clean install" to retrieve the needed nuxeo-ep plugins. It will create a new folder target where you can find the generated plugins

  3. In eclipse, import the apogee core plugins (the target folder) in Window > Preferences > Plugin Development > Target Platform

    Warning

    In some case, eclipse doesnt build anymore, complaining missing package from SWT. To resolve it, go back to Target Platform, click on "Restore Defaults", re add nuxeo apogee core generated plugins and "Apply" the changes.

  4. Then go into Eclipse and click on File > Import ..., then select General > Existing projects into Workspace. As the root directory select the Nuxeo RCP nuxeo-apogee-rcp folder (where you previously checked out Nuxeo RCP). Eclipse will automatically detect all the plug-ins, fragments and sites in the Apogee project. Click on the Finish button.

3.2.3. Enjoy

That's all. Now you should be able to begin coding your own Nuxeo RCP plug-ins.

Note

Note that the source code will someday move to http://hg.nuxeo.org/nuxeo-rcp/ using the Mercurial SCM instead of Subversion).

3.2.4. Launching your first Nuxeo RCP development product

This section is about launching the Nuxeo-RCP product that is provide in the source of nuxeo-rcp. For those who have install from the update site, you will wont be able to use the existing Nuxeo-RCP product (Create your own).

Now, you should have all your plugins compiled and you may want to try Nuxeo RCP. First you'll need to have a running Nuxeo ECM (5.2.M1 or later).

Note

if you want to use your RCP client from a remote computer, you should run your Nuxeo server with a specific IP binding

From Eclipse, you'll pop up the Debug dialog box of the Nuxeo RCP product file from the Run > open Debug dialog ... menu.

You'll create a new Eclipse application named "Nuxeo RCP" following the figures below:

In the plugin tab, click on "Validate" to make sure that your have the right configuration. If some plugins are missing, it may be because features selected in the product do not have the same version installed in your eclipse. To quickly fix it, select "Launch with: plugins selected below only", "Deselect all" and "add Required Plug-ins". To fix it permanently, remove and readd the features from the product file one by one using the product editor (that will readd the feature with the version install in your computer

Launch Nuxeo RCP by clicking on "Apply" and "Debug".

Once Nuxeo RCP is launched, you should have a connexion view called "ECM Applications" that lets you add Nuxeo ECM server and connect to them.

3.3. Building Nuxeo RCP

In this section, we're talking about building a ready-to-use Nuxeo RCP application. We'll use the classic export wizard from Eclipse. Another option would be using the custom automated build process that has been made available for Nuxeo RCP to ease automatic builds.

3.3.1. Using the Eclipse export wizard

From the menu (File > export > Plug-in development > Eclipse product), you'll find a wizard page that you'll configure as following:

If you have the Eclipse delta pack installed, you'll even be able to build products for other platforms than yours. Click in "Finish" to build your product(s).

Chapter 4. Creating a new software component for Nuxeo RCP

Adding a new software component to nuxeo RCP is finally similar to adding a classic Eclipse RCP component. However, you may have things that have been already done and you would like to reuse and the underlying application server is always different from one software to another.

This chapter will cover things that may be useful to know when starting coding for nuxeo RCP. Following the development of the "comments" component, you'll have a nice example of a nuxeo software component.

4.1. Creating a new plugin component

4.1.1. Creation of the plugin

New project -> Plugin development -> plugin project

Because it is a RCP application, you should use "Eclipse version 3.3" as target platform.

Check "no" to the question "Would you like to create a rich client application?": this option is for creating a new rich client application. We won't do that because our plugin will contribute to an existing rich client application

We won't create any template as well.

The others options are up to you.

4.1.2. Plugin dependencies

  • org.eclipse.core.runtime,

  • org.eclipse.ui,

  • org.nuxeo.ecm.rcp,

  • org.nuxeo.ecm.platform.comment.api (this is specific to the "comment" component),

  • org.nuxeo.ecm.core.api,

  • org.eclipse.ui.forms

4.2. Document tabs

Now that we have created the plug in, we are going to create a new tab to the document editor.

org.nuxeo.ecm.rcp.editors.DocumentPage classes are editor tabs classes you will have to subclass to create a new editor tabs in Nuxeo RCP.

Create a new class that subclass org.nuxeo.ecm.rcp.editors.DocumentPage. The most important part to look at is the method createPageContent. It will create the graphical widgets of the tab. You will create there your SWT/JFace widgets and forms, or other content that will be in the tab.

Once the class created, you need to reference it to the extension point "org.nuxeo.ecm.rcp.formPages".

4.3. Viewers in Nuxeo

Things have been done in the Nuxeo RCP to make easy the creation of table viewers and tree viewers.

If you are looking at DocumentCommentsPage, you'll notice that the viewer is creating by a CommentsManager. You'll have to create your own "Manager" if you want to use a treeViewer or a tableViewer. In Nuxeo, there are two classes you may reuse to create a manager: TreeViewerManager and TableViewerManager.

These ViewerManagers are another layer above JFace StructuredViewers. The methods you have to override are:

  • protected ItemAdapterFactory createAdapterFactory()

  • protected String[] getColumns()

  • protected String[] getColumnsHeader()

  • protected int getColumnSize(int columnIndex)

4.3.1. Adapters as providers.

The method createAdapterFactory() will provide a factory to ViewerManagers to create JFace label and content providers. These providers are managed underline behind adapters. So an adapter will provide pretty the same method than JFace providers that you will have to implement according to your needs.

For comments: see DocumentCommentsAdapter.

Here is how to add a new adapter to a ViewerManager :

protected ItemAdapterFactory createAdapterFactory() {
   ItemAdapterFactory factory = new ItemAdapterFactory();
   factory.registerAdapter(DocumentModel.class, new DocumentCommentsAdapter());
   return factory;
}

4.3.2. Table/Tree columns

Columns are managed with three other ViewerManagers methods.

getColumns will provide the array of String identifier of a column. For these columns, getColumnsHeader will provide the displayed header text. Then the last methods getColumnSize will return the size of the column according to its index.

Chapter 5. Managing internationalisation with Nuxeo RCP

Nuxeo RCP is following the Eclipse project way to internationalize messages. This chapter will explain how to quickly make your plugin "internationalizable" how to make a language pack.

5.1. Making your plugin "internationalizable"

5.1.1. Simple rules

Here are some simple rules we are going to follow. Theses rules are based on the way Eclipse organize externalization of strings:

  • The default language is English. All your messages must be in English before begining the process

  • For java files, we are using a .properties file is shared by Java files from the same package and plugin.

5.1.2. Java files

5.1.2.1. Eclipse mecanism

For java files that contains messages to internationalize, use the eclipse externalization tool (right clic, source > externalize strings).

Once you have the dialog box, you have to check "Use eclipse's string externalization mechanism" to use the eclipse way to manage externalization.

if you have already externalized a java file from the same package, select a Message class/.properties that has been created from the combo box.

Most of the time, you will use the default Message class/.properties, but if you're doing a externalization in a package that also exist in another plugin, it's a good idea to rename both the class and properties file to another name.

Things that has to be has to be externalize are strings that are translatable in another speaking language and they must be used in any piece of code is displaying in the user interface or logs (and nothing else).

5.1.2.2. Including variable in translatable strings

What if the strings has a parameters? For example the strings "You can not delete the file example.txt in this directory" has example.txt to be changed according of the name of the file. Use wille use the method NLS.bind: the strings would become "You can not delete the file {0} in this directory", and you will have to change your code to something like NLS.bind(Messages.yourMessage, thefilename).

5.1.3. Externalize plugin.xml

Plugin.xml part of the code can also be translatable: you need to change the Manifest file and add the line

Bundle-Localization: plugin

(plugin is the name of the .properties file which contains the translatable stuff, so your .properties file in this case is plugin.properties)

In the plugin.xml, you will replace all the translatable strings with %the.key to get it translated according to the keys in the plugin.properties file.

You may add to the build directory the properties file

5.2. Contributing a language pack.

Once you have make your plugin "translatable", you may way to contribute to your plugin with language translation other than English like, French or others.

To do so, everywhere you have created a .properties file, you can copy your the file to a _LanguageID.properties: for example, message.properties would become message_fr.properties.

This method is working fine but it may be interesting to give the ability of a pack of languages. To do so, we have to create a set of fragments (we will name them name_of_the_plugin.nl) that contain all the other .properties file, following the same tree structure of all the parents plugins (that the fragment are extending).

Chapter 6. Actions in Nuxeo RCP

TODO

Chapter 7. Nuxeo RCP extension points

7.1. Customize user attributes in the add/edit/view user forms

A user form in Nuxeo is defined by a specific schema with specific attributes. Most of the time, this schema won't changed but in some situation, Nuxeo may have been customised with other attributes or new ones.

The easy and current way to customize this schema in the RCP so that it reflects with the one in the Server is to use the extension point "org.nuxeo.ecm.rcp.usermanager.userFormsContributor".

7.1.1. Different configurations

At the moment, the only attributes that won't be touched are username and password. It has been told that these attribute are must be present in every ECM application for a user. For the other attributes, it's really up to you and the existing customized Nuxeo user schema on the server side.

If you just want to add attributes to the default schema, you'll just have to create a new plugin that extend the extension point and contribute new attributes from there.

If you don't want to use the default configuration, you can disable the fragment "org.nuxeo.ecm.rcp.usermanager.userformcontribution" which contain an extension with the default attributes. You'll will then create brain new plugin that contains ALL the attributes of the user (except username and password of course).

7.1.2. Contribute to the extension point

Each "org.nuxeo.ecm.rcp.usermanager.userFormsContributor" extension will provide a class that implements "org.nuxeo.ecm.usermanager.utils.IUserFormContributor". This class will define the way forms will retrieve data, display data and update data:

  • viewFormAddFields() will provide Fields associated with their key to the view form.

  • editFormAddFields() will provide Fields associated with their key to the edit and add form.

  • loadFromObject() will load data and provide it to the form.

  • saveToObject() will save data from the form.

  • validate() will return a message if there is a problem in the filled form

You may look at the javadoc comments of IUserFormContributor for more details. Here is the default configuration you can use as a template for new contributor:

package org.nuxeo.ecm.rcp.usermanager.userformcontribution;

import java.util.ArrayList; import java.util.Arrays;
import java.util.List; import org.nuxeo.ecm.core.api.NuxeoPrincipal;
import org.nuxeo.ecm.usermanager.utils.FieldItem;
import org.nuxeo.ecm.usermanager.utils.IUserFormContributor;
import org.nuxeo.ecm.usermanager.utils.UserManagerHelper;
import org.nuxeo.forms.utils.Form;
import org.nuxeo.forms.utils.LabelField;
import org.nuxeo.forms.utils.ListField;
import org.nuxeo.forms.utils.TextField;

public class DefaultUserFormContributor implements IUserFormContributor {
 public static final String FIRSTNAME = "firstname"; //$NON-NLS-1$ 
 public static final String LASTNAME = "lastname"; //$NON-NLS-1$ 
 public static final String COMPANY = "company"; //$NON-NLS-1$ 
 public static final String EMAIL = "email"; //$NON-NLS-1$ 
 public static final String GROUPS = "groups"; //$NON-NLS-1$ 

 public List<FieldItem> viewFormAddFields() { 
  ArrayList<FieldItem> list = new ArrayList<FieldItem>(); 
  list.add(new FieldItem(LASTNAME, new LabelField( Messages.DefaultUserFormContributor_lastname))); 
  list.add(new FieldItem(FIRSTNAME, new LabelField( Messages.DefaultUserFormContributor_firstname))); 
  list.add(new FieldItem(COMPANY, new LabelField( Messages.DefaultUserFormContributor_company))); 
  list.add(new FieldItem(EMAIL, new LabelField( Messages.DefaultUserFormContributor_email))); 
  list.add(new FieldItem(GROUPS, new LabelField( Messages.DefaultUserFormContributor_groups, UserManagerHelper.getGroups()))); 
  return list;
 } 

 public List<FieldItem> editFormAddFields() {
  ArrayList<FieldItem> list = new ArrayList<FieldItem>(); 
  list.add(new FieldItem(LASTNAME, new TextField( Messages.DefaultUserFormContributor_lastname))); 
  list.add(new FieldItem(FIRSTNAME, new TextField( Messages.DefaultUserFormContributor_firstname))); 
  list.add(new FieldItem(COMPANY, new TextField( Messages.DefaultUserFormContributor_company))); 
  list.add(new FieldItem(EMAIL, new TextField( Messages.DefaultUserFormContributor_email))); 
  list.add(new FieldItem(GROUPS, new ListField( Messages.DefaultUserFormContributor_groups, UserManagerHelper.getGroups())));
  return list;
 } 

 public void loadFromObject(NuxeoPrincipal principal, Form form) { 
  form.set(LASTNAME, principal.getLastName()); 
  form.set(FIRSTNAME, principal.getFirstName()); 
  form.set(COMPANY, principal.getCompany()); 
  form.set(EMAIL, principal.getModel().getProperty("user", EMAIL)); //$NON-NLS-1$
  List<String> listGroup = principal.getGroups(); 
  String s[] = listGroup.toArray(new String[listGroup.size()]);
  form.set(GROUPS, s);
 } 

 public void saveToObject(NuxeoPrincipal principal, Form form) {
  principal.setLastName((String) form.get(LASTNAME)); 
  principal.setFirstName((String) form.get(FIRSTNAME)); 
  principal.setCompany((String) form.get(COMPANY)); 
  principal.getModel().setProperty( "user", EMAIL, (String) form.get(EMAIL)); //$NON-NLS-1$ 
  String[] strings = (String[]) form.get(GROUPS); 
  if (strings != null) { 
   principal.setGroups(Arrays.asList(strings));
  } 
 } 

 public String validate(Form form) { 
  String email = (String) form.get(EMAIL); 
  if (email == null || email.trim().length() == 0) {
   return Messages.DefaultUserFormContributor_validationEmail;
  }
  return null; 
 }
} 

Appendix A. Commercial Support

A.1. About Us

The Nuxeo open source ECM platform is developed and published by Nuxeo SAS, a company with offices in France and the UK.

Through our commercial offer, Nuxeo Connect, we deliver enterprise-grade functional and technical support, certified software patches and updates, and management tools that assist you during every stage of the application life-cycle - from design and development, throughout testing and deployment, to operations and monitoring. Nuxeo Connect helps reduce business and technical risks, increase productivity, speed time to deployment and improve your success rate for all Nuxeo-based projects.

We're also happy to work with partners, IT Integrators or ISVs, to deliver the best possible applications to customers.

A.2. Contact information

A.2.1. General

Web: www.nuxeo.com

E-mail: contact@nuxeo.com

A.2.2. France

18-20, rue Soleillet

75020 Paris - France

Tel: +33 1 40 33 79 87

Fax: +33 1 43 58 14 15

A.2.3. UK

Garden Studios, 11-15 Betterton Street, London WC2H 9BP

Tel: +44-207-043-7933