Sunday, June 07, 2009
I'm moving to Wordpress
Saturday, May 23, 2009
Useing Qt to write Equinox-OSGi-UI-Applications
I'll start with a Technical Topic because it's a really exciting thing I guess not only for me but also for the whole Equinox-OSGi/Java-Community.
Since some time Qt is released under LGPL and since some weeks now their Java-Binding named Qt-Jambi is released too under LGPL. I've been playing with Qt-Jambi (because my UFaceKit project has a Qt-Port) before but now that the code is under LGPL it's getting more interesting to the wider Java-audience and naturally also people who use Equinox-OSGi for their applications.
A simple QtJambi-Application
Before digging into the details what I've done let's look at a simply QtJambi-Application if we are not using Equinox-OSGi.

package at.bestsolution.qt;
import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QGridLayout;
import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QLineEdit;
import com.trolltech.qt.gui.QMainWindow;
import com.trolltech.qt.gui.QWidget;
public class HelloWorld extends QMainWindow {
public HelloWorld() {
setWindowTitle("Hello World!");
QWidget composite = new QWidget();
QGridLayout layout = new QGridLayout();
composite.setLayout(layout);
QLabel label = new QLabel();
label.setText("Label");
layout.addWidget(label,0,0);
QLineEdit text = new QLineEdit();
layout.addWidget(text,0,1);
setCentralWidget(composite);
}
public static void main(String[] args) {
QApplication.initialize(new String[0]);
HelloWorld world = new HelloWorld();
world.show();
QApplication.exec();
}
}
This looks not much different to a SWT-Application besides the fact that one doesn't has to pass a parent when creating a widget and instead of running the event loop one simply calls QApplication.exec().
QtJambi and Equinox-OSGi
Couldn't be hard you think when you've used other UI-Toolkits (SWT,Swing) in your Equinox-OSGi-Applications already but the problem is that Swing is not problematic because it is part of the JRE and SWT is shipped as an (in fact multiple) Equinox-OSGi-Bundle/Fragment.
What we need to do is to Equinox-OSGify the bundles coming from Qt but this task is more complex then it looks on the first sight because using the simple converter provided by PDE is not providing us a solution because QtJambi-Code expects to load the libraries in very special way which means we need to patch their Java-Code to make it aware of Equinox-OSGi.
The really cool thing is that patching and maintaining the patch is easier than one might think because they provide their sources through a git-repo one could simply clone and maintain the patched sources. So maintaining the patch is easier than it is for example to maintain a patch for the eclipse-platform because of git.
The tough thing is to get the environment setup in a way than one can produce .jars from the sources because one
- Has to compile the Qt-Sources
- To generate the Java-Binding-Classes to the Qt-Sources (extracted from the C++-Header-Files)
which is a bit time consuming and not documented very well at the moment. Though this is doable for a medium skilled Java-Dev I think one should be able to checkout the complete project with native and generated Java-Code and doesn't have to compile all the stuff.
After having managed to setup a build environment I patched the libary loading classes and recreated the .jar-packages. QtJambi is split in 2 .jars:
- qtjambi.jar: Hold platform independent Java-Classes
- qtjambi-${os}.jar: Holding native libraries for the platform and the JNI-Glue
So the setup is similar to SWT but in SWT also the Java-Code is part of the native fragment because it differs from platform to platform and the host bundle is simply an empty bundle. In contrast to that in Qt the Host-Bundle is holding all Java-Classes and in the native fragments one has the native-libs and JNI-Glue.
So what this all means for you? Not too much because I did 2 things as part of UFaceKit-Target-Setup:
- Packaged my changes to the Java-Code and provide it for download
- Added ant-tasks who fetch the native libs from Qt-Software and repackage them

One could also use these ant-tasks when not using UFaceKit (I'm using it for my RCP-Development-Setup).
The Equinox-OSGi-Support is not fully finished and I'll maybe rework it a bit in future when understanding the code better but for now it sufficient to go on and file a CQ to make use of Qt in UFaceKit. Let's see what's coming out from this now that Qt is LGPL.
Simple Qt-Jambi and Equinox-OSGi-Application
Let's create an Equinox-Application which uses Qt as UI-Toolkit now. The easiest thing is to use the PDE-Wizard to create a "Headless Hello RCP" and add a MainWindow.java.
package at.bestsolution.qt;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QGridLayout;
import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QLineEdit;
import com.trolltech.qt.gui.QMainWindow;
import com.trolltech.qt.gui.QPixmap;
import com.trolltech.qt.gui.QPushButton;
import com.trolltech.qt.gui.QWidget;
public class MainWindow extends QMainWindow {
public MainWindow() {
QWidget widget = new QWidget();
widget.setObjectName("main_window");
QGridLayout layout = new QGridLayout();
layout.setMargin(0);
widget.setLayout(layout);
addHeader(layout,"Tom Schindl","at/bestsolution/qt/bookmarks.png");
QWidget content = new QWidget();
QGridLayout contentLayout = new QGridLayout();
content.setLayout(contentLayout);
addLine(0, contentLayout, "Firstname");
addLine(1, contentLayout, "Lastname");
addLine(2, contentLayout, "Age");
QPushButton button = new QPushButton();
button.setObjectName("submit");
button.setText("Submit");
contentLayout.addWidget(button,3,1);
layout.addWidget(content);
setCentralWidget(widget);
}
private void addHeader(QGridLayout layout, String labelText, String icon) {
QLabel header = new QLabel();
layout.addWidget(header);
header.setObjectName("header");
QGridLayout headerLayout = new QGridLayout();
headerLayout.setMargin(0);
header.setLayout(headerLayout);
QLabel headerIcon = new QLabel();
headerIcon.setObjectName("header_icon");
headerIcon.setPixmap(loadImage(icon));
headerLayout.addWidget(headerIcon);
QLabel headerText = new QLabel();
headerLayout.addWidget(headerText,0,1);
headerLayout.setColumnStretch(1, 100);
headerText.setObjectName("header_text");
headerText.setText(labelText);
}
private void addLine(int line, QGridLayout contentLayout, String labelText) {
QLabel label = new QLabel();
label.setText(labelText);
label.setObjectName("label");
contentLayout.addWidget(label);
QLineEdit text = new QLineEdit();
text.setObjectName("text");
contentLayout.addWidget(text,line,1);
}
private QPixmap loadImage(String path) {
try {
InputStream in = getClass().getClassLoader().getResourceAsStream(path);
ByteArrayOutputStream out = new ByteArrayOutputStream();
int l;
byte[] buffer = new byte[1024];
while ((l = in.read(buffer)) != -1) {
out.write(buffer, 0, l);
}
QPixmap pic = new QPixmap();
pic.loadFromData(out.toByteArray());
return pic;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
and modify the generated application class like this:
package at.bestsolution.qt;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import com.trolltech.qt.gui.QApplication;
public class Application implements IApplication {
public Object start(IApplicationContext context) throws Exception {
QApplication.initialize(new String[0]);
MainWindow window = new MainWindow();
window.show();
QApplication.exec();
return IApplication.EXIT_OK;
}
public void stop() {}
}
Well as you see I'm not a good designer and the application looks well not really nice though it looks native on my OS-X though this is only faked by Qt because they are drawing everything on the screen as far as I understood it.
One could think that this fact is a draw back of Qt but IMHO it's the other way round because with this strategy they can support things SWT can't support easily - Completely restyle your application using a declarative language and well they use CSS like e.g. E4 does too.
The first thing to do is to add a method to load a stylesheet to Application.java:
private String loadStyles(String cssPath) {
InputStream in = getClass().getClassLoader().getResourceAsStream(cssPath);
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuilder s = new StringBuilder();
String line;
try {
while( (line = r.readLine()) != null ) {
s.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
return s.toString();
}and set the style sheet on the main window:
public Object start(IApplicationContext context) throws Exception {
QApplication.initialize(new String[0]);
MainWindow window = new MainWindow();
window.setStyleSheet(loadStyles("at/bestsolution/qt/style.css"));
window.show();
QApplication.exec();
return IApplication.EXIT_OK;
} and we need to define some styles:
resulting in this application:

which we all agree looks better than:

As you see this is also not my design but then one you get when using the Eclipse-Forms-API with the difference that in Eclipse one has to learn a new API to deal with besides SWT whereas in Qt the UI-Code is still Qt and styled by a declarative syntax and if you ask me the Forms-API is going to replace in space of Eclipse in E4 through SWT + CSS but this is only my personal opinion.
So should we all now move to Qt-Jambi to write UI-Applications in Java like we did years ago when we abandoned Swing and started using SWT?
Let's look at some potentially problematic areas:
- Qt and QtJambi misses an application framework like eclipse RCP provides one for SWT-Application developers
- Qt and QtJambi misses Databinding support like Eclipse-Databinding provides one for SWT, JavaBeans and EMF
- Nokia removed all resources from QtJambi development and wants to build a community to work on it
For at least 2 of the above there are solutions already today:
- E4's core application platform is UI-Toolkit agonstic so though E4 is not released until 1.5 years it would give people the possibility to use Qt as their UI-Toolkit of choice which supports many many things starting from animations, multimedia integration, ...
- UFaceKit provides JFace-Viewer like and Eclipse-Databinding support for QtJambi if the CQ I'm going to file is approved
Still the killer problem is the lacking support from Nokia on QtJambi and it's unclear if a community could be build around it who not even maintains but also adds new features.
I think this is a bitty because with getting a real application framework with E4, it's themeing, multimedia and animation support I think QtJambi could get a real possibility to write cross-platform RCP-Applications in Java without the sometimes really hurting lowest common denominator problem we have in SWT.
So what should one do? Though QtJambi looks like a real solution for writing nice looking RCP-Applications the uncertainness caused by Nokia by cutting resources makes it unusable for most companies.
For form developers I could point you once more to UFaceKit which supports both SWT and Qt and your form application code is not affected by changing the underlying technology but one can still rely on native stuff where needed (e.g. using Qt animation/multimedia support).
For me as one of E4 committers and UFaceKit-Project lead it means:
- I'd try to keep the application runtime widget agonstic if possible (well we are on a good track here)
- I'll file a CQ to let UFaceKit make use of QtJambi and provide first class JFace-Viewer and Eclipse-Databinding support for QtJambi
1. updated my wrong capitalization of Qt
2. please note that I'm using Equinox specific stuff to make this work so it is maybe not runnable on other OSGi implementations but I'm happy to incooperate feedback and suggestions into my git-clone to support other OSGi implementations
Monday, March 02, 2009
Give your E4-Application a modern Look&Feel
EclipseCon is coming in about 3 weeks and I started preparing the stuff for my talks about E4 and UFaceKit.
In E4 we are trying to address some of the main pain points RCP-Application developers faced - Their application looks like Eclipse and the theming/presentation API is not flexible enough to modify all aspects of the UI (e.g. Toolbar/MenuBar, ...)!
The first step to make your application look different was that we introduced the concept of declarative styleing (CSS).
Let's take the demo E4-Photo-Demo-application as example.
This is the application without CSS:
This is the application with CSS:
But like in other aspects E4 goes further and allows you to exchange complete widgets like the application-shell, the menu and toolbar, the Stack-Folders (the standard theme uses CTabFolder) resulting in an E4-Demo-Application like this:
You want to know more about how this works and how the internals of the workbench make such things possible? Then I'd suggest to you attend the EcliseCon-talk about the modeled workbench Boris and I are delivering at EclipseCon09
But E4 goes even further! It allows you to plugin every widget-technology you want to! The internals don't care whether your application gets renderered by QT, Swing, UFaceKit you name it. So I've done that and here's my UFaceKit-Demo-Application built on top of E4:
Makeing UFaceKit a possible renderer of E4 opens the doors to all technologies supported by UFaceKit (Swing, QT, GWT, ...) and its advanced DeclartiveStyling-Support
Friday, February 27, 2009
News on UFaceKit
IP-Review passed
This is a great day in the short life of UFaceKit. We passed the initial IP-Review for our code base and I thank all the IP-Team for the great assistance and help to make our code base IP-clean.Abstraction of Application-Bootstrapping
Until today the start up process of an application has been Toolkit specific (e.g. spinning the event-loop) this is now abstracted in a new interface called UIDesktop which can be compared to the mixture of SWT-Display and the Eclipse-Workbench.This abstraction means that switching from SWT to QT means switching exactly one factory and that's it. This new UIDesktop concept is also a result of discussing a potential OpenGL-Implementation of the UFaceKit-API with one of our employees.
public void startup(UIFactory factory) {
UIDesktop desktop = factory.newDesktop();
desktop.runWithDefaultRealm(new UIRunnable() {
@Override
protected IStatus run(UIDesktop element) {
createUI(element,uiMethod);
return Status.OK_STATUS;
}
});
desktop.run();
}
// Creating application with SWT
startup(new JFaceFactory());
// Creating application with QT
startup(new QTFactory());
A first real world application
One of our employees is rewritting our one of our applications using UFaceKit and is making good progress. Writing a real world applications helps us to fill the last missing gaps in API. Maybe I can already show an intial version of the application on EclipseCon 09 then people can see a real world application using UFaceKit + EMF + CDO in my talks:- Mixing Eclipse Technologies to create Enterprise Ready Database-RCP-Frontends
- UFaceKit - A highlevel Databinding and Widget-Toolkit-Abstraction
Saturday, January 17, 2009
Getting started with UFaceKit and QT
QT and UFaceKit
So the big news this week in opensource space was the announcement of Nokia to release their C++ cross-platform widget toolkit under LGPL. This is great and people now once more start to request a SWT-Port for QT. I don't know if any company is going to invest the development resources into such a port at least I haven't heard anything.From UFaceKit point of view the announcement is great because we've been working since some time on an UFaceKit-Implementation for QT. Today I invested some time to implement features to render the AddressBook-Application i showed you in my last blog entry
Below is the application rendered using the CleanlooksStyle on MacOSX:

The only change to the code I showed you last week is how the application is launched.
For SWT the launcher looks like this:
public class Launcher {
public static void main(String[] args) {
final Display display = new Display();
Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
public void run() {
JFaceFactory factory = new JFaceFactory();
Workbench workbench = new Workbench(factory);
workbench.open();
while( ! workbench.isDisposed() ) {
if( ! display.readAndDispatch() ) {
display.sleep();
}
}
}
});
}
}
And for QT:
public class Launcher {
public static void main(String[] args) {
QApplication.initialize(new String[0]);
QApplication.setStyle(new QCleanlooksStyle());
Realm.runWithDefault(QTObservables.getRealm(), new Runnable() {
public void run() {
QTFactory factory = new QTFactory();
Workbench workbench = new Workbench(factory);
workbench.open();
QApplication.exec();
}
});
}
}
And now with styles applied the whole application looks like this:

I'm still in the process to make myself familiar with the QT-API and how I'm supposed to use and implement certain functions. Even if you don't want to use our UFaceKit-API the work we are doing here is interesting to you probably because we provide for example QTObservables for use with Eclipse-Databinding and a Combo/List/Table/Tree-Viewer implementation for QT-Controls.
UFaceKit Dokuware
I was asked to provide instructions how to get the applications I show in my blog running the locally and play with them. I've opened a new section in the Eclipse-Wiki holding all informations about our project - outlining our goals, instructions how to get the current code base running, and hopefully much more information soon.Wednesday, January 14, 2009
Pimp your application L&F with UFaceKit

Making applications look nice and still not cluttering your code with these theming informations is something not provided out of the box by Eclipse. Still the situation is changing since the E4-Team is working on "native" SWT-CSS integration (Kevin McGuire and Kai Tödter) - if I'm not mistaken the code should in theory also work in 3.x.
But besides E4 there's another project called UFaceKit which provides a high-level widget-toolkit API (the application above is written with UFaceKit in about ~250 Lines of code) and part of this high-level abstraction is direct support for Declarative-Styleing.
Let's at first take a look at the above application. I've split it into 3 Classes:
- Workbench.java: Creates the workbench and the TabFolder

- ContactsPart.java: Creates the Content shown in the Contacts-TabItem

- DetailsPart.java: Creates the Content shown in the Details-TabItem

When coding with UFaceKit and you choose to use the SWT-Implementation (we also provide Swing and QT though SWT is the most stable and feature rich) you get the native platform L&F (as you see above) but the application is not really visually appealing.
If you don't have support for declarative styling you'd now have to clutter your code with themeing informations (e.g. setting background-colors, ...) and your code is soon getting unmaintainable. The Web-Guys already found this out for a while and invented CascadingStyleSheets (CSS). So why not learning from them and bring CSS (I more like the term Declarative-Styleing) to the world of Java-Desktops.
As mentionned before the E4-Team is working on CSS support and so does UFaceKit but this is not the only thing. UFaceKit abstracts styling support and you can plug-in your own declarative syntax. Out of the box we support:
- CSS: Like you know it from Web-Development. We currently don't support all features from CSS2 but only the most important ones
- USML: UFaceKitStylingMarkupLanguage is a very simply XML-Definition for css-like styles which has the adavantage that it doesn't add any dependencies like CSS-Support does
As state we don't suppport all features CSS2 defines but a subset of the most important things:
- ID-Definitions like #myelement { }
- Class-Definitions like .mylabel { }
- Element-Definitions like UILabel { }
- Support for pseudo-Attributes like :hover, :focus
- Support for attribute-selectors like .mylabel[@value >= 10]
Let's see what we can achieve by adding this styling support our application.

Amazing isn't it? No single line of application code has changed between those screenshots! As you might noticed I've used Kai Tödters E4-Example application as master and the data is backed up in XMI useing the EMF-Toolchain.
What can you expect in future from UFaceKit:
- Working on better support for Swing (many Styling things are missing)
- Working on better support for QT (some styling and control things are missing)
- Finishing implementation of current API functions
- Adding JUnit-Test, ...
- Declarative Syntax to describe and visual design your UI using EMF
- ...
As you see there's much work that needs to be done and if you are interested in helping out you are more than welcome.
Thursday, January 08, 2009
Where do you go (JFace)Viewers
The presence
Today I thought about a problem of JFace-Viewers when it comes to clever memory management like it is provided for example by CDO. CDO has a very clever memory management concept where objects are swapped out of the memory if they are not referenced in application code.
When using CDO in conjunction with JFace-Viewers this concept doesn't work because JFace-Viewers restore the model element into the TableItem/TreeItem-data-slot and so CDOs clever memory management is not working and the whole model resides in memory.
Inspired by Ed's efforts to minimize the memory footprint of EObject (see bug 252501), I started to think how we could improve on the other side of the fence. I've started today implementing a set of specialized viewer classes which makes it possible for you to take advantage of the clever memory management supplied for example by CDO.
The idea is simple. Instead of restoring the real object in the viewer the object gets translated into a key value (in case of CDO it could the a CDOID) and so CDO can free memory ASAP. The code is available from the UFaceKit-Repository because the scope of UFaceKit is also to provide higherlevel utilities for current Eclipse-Technologies beside inventing it's own high-level API.
The future
The Viewer-Concept provided by JFace for StructuredControls (Combo, List, Table, Tree, TreeTable) is one of the most used concept in Eclipse-Applications and although they are very powerful and we fixed many deficiencies we could provide much better useablility and user experience in E4.
Some of them coming to my mind are:
- No Toolkit-Independence we can only target SWT like controls
- Usage of Java5 generics
- Multiple different APIs to achieve solve a problem
- Problem with memory intensive models
- (Fill in your favorite problem)
If you are a regular reader of my blog you know that in my UFaceKit-Project I've already written a JFace-Viewer like implementation for other widget toolkits (QT, Swing). I've today restarted think whether this would be a good thing for E4 in general and so I filed bug 260451.
I'd like to see Eclipse-Viewer getting a project like Eclipse-Databinding which is split into a general and toolkit specific part and integrate itself seamless into the concepts provided by Eclipse-Databinding. I'd invite all of you to take part in a renewed implementation of the viewer concept by adding yourself to bug 260451 and take part in the design discussion hopefully takeing place there.
The intial list of points I'd mentionned in the bug are:
- Cross-Toolkit like Eclipse-Databinding I'd like to see Viewers getting split
a Toolkit-Neutral and Toolkit-Specific API so that implementation for e.g.
Swing, QT, ... can be created. - Better support for big model graphs (e.g. better support for CDO) (see bug
260422) - Revised inline editing
- Direct-Databinding support
- Builtin support Async-Programming (see bug 253777)
- Support for Java5-Generics
- Builtin databinding support (e.g. a Viewer could direclty implement the
IObservableValue interface)
Friday, November 21, 2008
Back from ESE
My talks
Let me first recap my talks. I think all in all they went quite well though there are always things to improve (it was my first time doing a talk my own)E4 - Modeling the workbench
I think I never talked to so many people ever before because I did my presentation in the biggest room available.Datacentric RCP with EMF and Databinding
I did the presentation in the 2nd biggest room and there even haven't been enough chairs for all people who wanted to attend my talk so they had to stand in the back. Woohoo.I felt more comfortable speaking without a microphone and I think I showed people when mixing the right Eclipse technologies it's possible to write Enterprise ready Database frontends.
I admit my presentation was a bit focused about UI (Key-Binding, UI-Contexts, Commands) and not so how to access data. The only review I found until now is a short sentence in Ed Merks blog where people told him that the talk was "really good". So looking forward for more comments. I think the small application I presented there is what many people requested on the "E4-symposia" when they asked about a best practice example.
I even thought about restarting on an accompanying book about all the stuff one can find in the example and technologies but dismissed this thought immediately because I simply don't have the time and financial grounding to spend my time on it. The time (=money) my small company is investing in Eclipse is big enough already.
Conclusion
I would appreciate to get more comments about my presentation and ask myself why the same we had one EclipseCon was done where people got small pieces of paper to give back comments.I think the intention was that people use gPublication to do so but it looks like people don't know about this. So if you want to give feedback and get access to the slides please do so at: but I'm afraid not all people attending my talks are really following my blog or the Planet so the feedback is going to be less than it was on EclipseCon.
If you and your company need help to get started with Eclipse RCP and other Eclipse technologies like OSGi, the modeling stack like (EMF, Teneo, CDO) my company is offering consultancy and development resources to anyone interested.
The E4 symposia
The symposia once more was I think a well received offer of Eclipse Summit Europe to the community and we talked about a lot different things in the E4 space. Boris Bokowski summarized the symposia in here.For me as someone taking part in E4 project it is important to get feedback from the community to integrate their wishes (if my time permits) in the code base.
Socializing
I got to know my new people and we had a lot of interesting chats about new ideas (e.g. declarative ui) so it's hard to get back to reality and working on all those boring stuff.Tuesday, November 04, 2008
Rotating Image in a PaintListener
Let me first of explain the exercise I had to solve, then show you my solution and then maybe someone can point out a better one.
Exercise
Draw an Image at Point(50,50) in a Canvas which is rotated a variable angle.The solution
Solveing this problem one can use a SWT-Transform to adjust the Graphics-Context looks straight forward but it took me like said 2 hours to wrap my head around the problem. The following function is the solution I came up with.
public void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setAdvanced(true);
Bounds b = image.getBounds();
Transform transform = new Transform(display);
// The rotation point is the center of the image
transform.translate(50 + b.width/2, 50 + b.height/2);
// Rotate
transform.rotate(45);
// Back to the orginal coordinate system
transform.translate(-50 - b.width/2, -50 - b.height/2);
gc.setTransform(transform);
gc.drawImage(image, 50, 50);
transform.dispose();
}
Is the solution right? Is there a better solution?
My skills are very very bad when it comes to matrices and 2-D graphics so the above solution to the problem might be completely wrong and only works by chance.Monday, October 27, 2008
News about UFacekit
1. UFacekit Proposal
The proposal is out and we hope some of you are interested in the targets and ideas we follow with UFacekit. If you are please leave a note on the newly created newsgroup. Share your wishes, critism with us so that we can make UFacekit a success.
2. QT-Port
Just a few minutes ago I checked in a first running version of a QT-Port of the UFacekit-API. Besides providing this API we naturally provide bundles you can consume standalone (e.g. to only use a JFace-Viewer-API in QT-Jambi-Projects, ...).
So we now have:
Platforms I'd like to see a port in future:
- GWT - is going to be revived soon by one of the team-members
- GXT
- Other UI-Toolkits based upon GWT
- Eclipse-Forms - Should be fairly easy to do
- Android - The first test suggest it is possible though we need to see if all widget types are available. Maybe we can only provide some viewer and UI-Observables but not a full fledged UFace-API
Platforms I dream of a port in future:
- Draw2d
- OpenGL
Friday, October 24, 2008
There's no place where Eclipse-Databinding doesn't work
Here's the application:


The model code looks like this (I'm using UBeans here because they are completely self contained and have no dependencies)
private static class Person extends UBean {
public static final int NAME = 1;
public String getName() {
return (String) get(NAME);
}
public void setName(String name) {
set(NAME, name);
}
@Override
public Object getValueType(int featureId) {
return String.class;
}
};
The UI-Code looks like this (fairly straight forward UI-Code):
TextView view = new TextView(this);
view.setText("Name: ");
TableLayout layout = new TableLayout(this);
layout.addView(view);
EditText text = new EditText(this);
layout.addView(text);
Button button = new Button(this);
button.setText("Say Hello");
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Dialog dialog = new Dialog(Test.this);
dialog.setTitle("Hello " + p.getName() + "!");
dialog.show();
}
});
layout.addView(button);
And now the important thing how do we connect UI and Model-Attributes? Right we use Eclipse-Databinding (well not the one you get from Eclipse directly because it doesn't compile out of the box but patching it took about 30 minutes :-).
IObservableValue mObs = UBeansObservables.observeValue(realm, p, Person.NAME);
IObservableValue uiObs = AndroidObservables.observeText(realm, text);
DataBindingContext ctx = new DataBindingContext(realm);
ctx.bindValue(uiObs, mObs, null, null);
Cool isn't it? Would a Eclipse-Databinding port for Android help you? Then take a look at the newly proposed Eclipse-Project UFacekit. We already provide Viewer and UI-Observable implementations for different Platforms (SWT,Swing,QT) and plan to provide one for other platforms (GWT, Eclipse-Forms, ... you name it). Why should we not provide them for Android-Widgets too?
Sunday, October 19, 2008
Update on UFacekit
UFacekit has a new source structure
We have restructured the repository to clearly separate our modules into:
- proper:
This holds stable and actively maintained modules - currently Swing and SWT implementations. Checking them out and compiling works always else it's a bug and someone is to blame. - incubation:
This holds newly and not yet stable modules - currently our new brand new QT support is in there. Checking them out and compiling works most of the times it's not a bug! - dormant:
This holds old modules currently not actively maintained and don't even compile. Sad enough our GWT ports are currently located there. Hopefully we are good to push them forwards once more in the next months. You are a GWT guru and want to help making the GWT port as stable as possible? Come and join us.
The layout is taken from the Apache-Jakrata project.
UFacekit has an QT-Port
I started 2 or 3 weeks ago a port which uses QT-Jambi to bind against QT-Widgets. There's no ufacekit API available but Viewer implementation and observables for some widgets are already available. I hope I can finish this work as soon as possible. Might be interesting what happens when we are moving the sources to Eclipse.
UFacekit has a build story
Having a stable build story is one of the most important things for OpenSource-Projects. Kenneth did amazing work on making UFacekit managed and build with maven. The repository now doesn't hold any IDE-specific settings any more everything is done by maven.
We are not using PDE-build or any Eclipse-specific things because this would interfere with an important UFacekit-target:
"improve adoption of Eclipse Core technologies (like Eclipse-Databinding) outside RCP and SWT (e.g. Swing, GWT, QT)". Having a build story relying on Eclipse would be a bad thing.
The process e.g. for the proper-modules is like this:
svn co http://uface.googlecode.com/svn/trunk/proper/
cd proper
cd org.ufacekit
mvn clean install
mvn eclipse:eclipse
Afterwards fire up eclipse and import the modules. Done. Kenneth you are my king.
Wednesday, October 08, 2008
Disable parts SWT-Table/Tree with SWT.CHECK
I have read many many entries on the newsgroups asking a question like this:
How can I disable certain check boxes in an SWT-Tree/Table. Is this possible?
The standard answer to this was: "Sorry no this is not possible". Today I faced the same problem (mine had to do with ViewerObservables#observeCheckElements()) where the user is not allowed to check the Top-Level-Nodes.
The tree looks like this:
+ Application 1
+ Privilege A
+ Privileg A1
+ Privilege B
+ Privileg B2
+ Application 1
+ Privileg C
The values bound are the ones in Privileg* so I have to lock the Application-checkboxes
The setup is something like this:
Databinding ctx = ....
IObservableSet mObs = ....
Tree tree = new Tree(parent,SWT.BORDER|SWT.V_SCROLL|SWT.H_SCROLL);
CheckBoxTreeViewer v = new CheckBoxTreeViewer(tree);
IObservableSet uiOs = ViewerObservables.observeCheckedElements(v,IPrivileges.class);
ctx.bindSet(uiObs,mObs,null,null);
I nearly gave up but then I had the following idea.
final Tree tree = new Tree(parent,SWT.BORDER|SWT.V_SCROLL|SWT.H_SCROLL);
// Attach a listener directly after the creation
tree.addListener(SWT.Selection,new Listener() {
public void handleEvent(Event event) {
if( event.detail == SWT.CHECK ) {
if( !(event.item.getData() instanceof IPrivileg) ) {
event.detail = SWT.NONE;
event.type = SWT.None;
event.doIt = false;
try {
tree.setRedraw(false);
TreeItem item = (TreeItem)tree.item;
item.setChecked(! item.getChecked() );
} finally {
tree.setRedraw(true);
}
}
}
}
});
CheckBoxTreeViewer v = new CheckBoxTreeViewer(tree);
// ....
This is a hack, I only tested it on Win32 (XP) and don't know how cross platform it is so don't kill me for posting this hack of hacks.
Monday, September 22, 2008
JFace-Viewers for Swing, is this possible?
0. The background
Do you sometimes have to code against Swing and have also been disappointed that you could not remember how to deal with Tables, Trees and TreeTables (I find myself always opening this tedious Swing-Tutorial to find how to do it)?
In last few days I worked on UFacekit's Swing implementation for Tree and TreeTable. JFace-Databinding has added support for Trees and TreeTables in 3.4 and naturally they build upon the JFace-Viewer implementation but naturally JFace-Viewers are bound to SWT and so it is impossible to use this support (or a slighlty one modified) Swing, right?
Well the above is not completely right the main JFace-Viewer-API is fairly free from SWT (besides some Widget, Item stuff) the internals are naturally not. After having noticed this I:
1. Extracted an Widget-Toolkit-Neutral API from JFace
... moved it to a new plugin (org.ufacekit.ui.viewers). I didn't only move the classes and interfaces to a new home I also added support for generics so all this casting is gone and done by the compiler for us.
A content provider now looks like this:
IContentProvider<Person,Collection<Person>> cp =
new IContentProvider<Person,Collection<Person>> {
// ...
}
and a collection can get iterated with a foreach-loop
for( Person p: v.getSelection() ) {
// ...
}
I rearranged some other classes and made interfaces from most of them, ... . So now I have a widget-toolkit-clean Viewer-API.
2. Copied some SWT-Classes (Widget, Table, TableItem, Tree, ...)
... replaced the internals through Swing-counter parts (some of the code is highly ineffecient because e.g. for a Tree we now have 3 Objects (UserObject, TreeItem, DefaultMutableTreeNode) )
3. Commented some JFace-code not needed to provide the minimum JFace-API
... providing a selection, and firing events when the selection changed but I currently e.g. don't need inline Editing so I simply commented all parts of the viewers that deal with this, including Mouse-Handling, ... . The problems from 2. & 3. are hidden from the user because all these are internal classes so I can replace them step by step.
4. Blog how nicely now I can setup a TreeTableViewer for Swing
(in fact SwingX because Swing doesn't has a TreeTable implementation by default - don't ask me why a Toolkit being around for such a long time doesn't has such a standard-control)
So now I don't have to remember how I have to create a TableTree in Swing which loads subnodes lazily because I can simple use the API I already know from JFace for SWT.
@Override
protected Component createUI(JFrame frame, List<Person> model) {
JXTreeTable tree = new JXTreeTable();
TableColumnExt c1 = new TableColumnExt(1);
c1.setHeaderValue("Givenname");
c1.setWidth(200);
tree.getColumnModel().addColumn(c1);
TableColumnExt c2 = new TableColumnExt(1);
c2.setHeaderValue("Surname");
c2.setWidth(200);
tree.getColumnModel().addColumn(c2);
JScrollPane scroll = new JScrollPane(tree);
TreeTableViewer<Person, Collection<Person>> viewer =
new TreeTableViewer<Person, Collection<Person>>(tree);
viewer.addSelectionChangedListener(
new ISelectionChangedListener<Person>() {
public void selectionChanged(SelectionChangedEvent<Person> event) {
for( Person p: event.getSelection() ) {
System.out.println(p);
}
}
});
TreeViewerColumn<Person> c = new TreeViewerColumn<Person>(viewer,c1);
c.setLabelProvider(new LabelConverter<Person>() {
@Override
public String getText(Person element) {
return element.getGivenname();
}
});
c = new TreeViewerColumn<Person>(viewer,c2);
c.setLabelProvider(new LabelConverter<Person>() {
@Override
public String getText(Person element) {
return element.getSurname();
}
});
viewer.setContentProvider(
new ITreeContentProvider<Person,Collection<Person>>() {
public Collection<Person> getChildren(Person parentElement) {
return parentElement.getChildren();
}
public Person getParent(Person element) {
return element.getParent();
}
public boolean hasChildren(Person element) {
return ((Person)element).getChildren().size() > 0;
}
public Collection<Person> getElements(Collection<Person> inputElement) {
return inputElement;
}
public void dispose() {
// TODO Auto-generated method stub
}
public void inputChanged(IViewer<Person, Collection<Person>> viewer,
Collection<Person> oldInput,
Collection<Person> newInput) {
// TODO Auto-generated method stub
}
});
viewer.setInput(model);
return scroll;
}
5. Summary
The internals are quite ugly there is a huge amount of bugs (I'm sure that not all is working smoothly already), missing functionality (e.g. Icon, Color and Font support) but I now have the foundation to add Tree and TreeTable support to the UFacekit-Library. Cleaning up and bugfixing can happen later. Like all other parts of the UFacekit-Project you can consume this swing-jface-bundle standalone because it has no dependency at all (besides the one on org.ufacekit.ui.viewers).
6. So am I now?
- Completely Crazy
- Fairly Crazy
- A bit Crazy
- Fairly normal if you know me and all the crazy ideas I already had
Tuesday, September 09, 2008
UFacekit - Proposed as a Component under Platform/Incubator
- Comment on the following newsgroup post from Boris
- Add yourself/company as an interested party on the proposal page
Wednesday, September 03, 2008
Exploring new technologies part of Ganymede-Release Train
- Eclipse-Databinding and its new features
- EMF-Databinding (Provisional but working very smoothly)
- Teneo: Persist your model via hibernate in a SQL-Database
- CDO: Share your model between different clients and persist it into an SQL-Database (with Revision support)
- New Extension Points to enhance the Expression Framework
- Spring & OSGi
- P2 to install the Products using the P2-Agent
As always when learning new technologies I created an example application but before I started I defined some goals I think are curcial to all Enterprise Datacentric Desktop Applications:
- Nice L&F (as good as I can make an UI Look without a designer)
- Plugable storage technology
- Undo/Redo Support
- How to create an EditingDomain myself when not using the generated editor-classes from EMF?
- How to use the new org.eclipse.ui.services-Extension point to enhance the expression framework?
- Best strategy to use Extension Points when bundles are installed/uninstalled/updated while the application is running
All those things are not hard if you know how to do it but if you don't it's quite tricky to solve these problems. It even gets harder if the technologies you plan to use are quite new and/or are not used together and because of this bugs arise.
So the immediate output of my work was that 2 bugs [239015, 245183] in Eclipse-Databinding got fixed in 3.4.1.
The longterm output for me is:
- I now have a good picture how our next technology stack looks like
- I have an example application (I will add other things in the next weeks) to teach my co-workers the technologies
- I had a lot of fun (besides struggeling with P2)
- You have a small application showing you a lot of different concepts around RCP+EMF+Databinding applications
- EMF-Ecore
- Usage/Creation of your own Extension Points
- Using EditingDomain outside the scope of EMF-Generated artefacts
- Using Teneo
- Using CDO
- I started summerizing all the ideas, technologies and concepts combined in this example in a document, I'm working on from time to time. So maybe some time you'll get a "book" explaining you everything
- Some nice reusable classes e.g. one to use EMF/Databinding-LabelProviders with cool features, a new drop down widget showing a Tree in the popup, ...
This is the application:

If you want to run it locally get a copy of the P2-Agent and point the metadata repository and artifacts repository to this location.
To use the CDO-Version you also need a server component which can be installed when pointing the agent to this location. After having installed the CDO-Server you also have to create a CDO-Configuration (cdo-server.xml) in the installations "configuration" directory which you can fetch from here.

The repository name in the above config "CDO-1" has to be the id of the CDO-Configuration you create in your application.
Finally if you are interested only in the sources then install a subversion plugin in your eclipse and use one of te Team-ProjectSet files from here to check out the necessary projects.
If you want to learn more about these cool technologies. I've proposed beside a talk about E4 - The new platform-ui concepts a talk about this example application on ESE.
Sunday, August 24, 2008
Writing a CTreeCombo-Widget

I'm going to use to present various parts of those technologies to my co-workers and getting familiar with new technologies like CDO, Teneo, Spring and others when I hit the problem that standard CCombo didn't suited my needs.
What I wanted to have was a CCombo which presents a Tree like structure like this

for my Login-Screen and as you all know there's no such widget available currently. As you might guess from the above Screenshot I somehow managed to get such a widget.
Before we dive into it another requirement I had was that the implementation plugs itself into the existing viewer and databinding concepts of Eclipse.
So what did I do and how did it work? Well 95% of the work I had to do is C&P. I copied the CCombo-Code replaced List against Tree and solved compilation errors. To make a CTreeCombo widget I would have been done almost if this would have been the only requirement.
The real problem is that widgets are reparentable and that this can happen across Shells which makes it necessary to recreate the Tree and its popup shell from time to time so directly attaching a TreeViewer on the underlying Tree-Widget is not possible. So the only possibility was to create Proxy objects around TreeItem/TreeColumn who proxy the real implemementation so that they could be recreated whenever needed.
So if one wants to use the widget he/she has to write code like this:
int style = SWT.BORDER|SWT.READ_ONLY|SWT.FULL_SELECTION;
CTreeCombo combo = new CTreeCombo(shell,style);
CTreeComboItem item = new CTreeComboItem(combo,SWT.NONE);
item.setText("Parent 1");
CTreeComboItem childItem = new CTreeComboItem(item,SWT.NONE);
childItem.setText("Child 1.1");
childItem = new CTreeComboItem(item,SWT.NONE);
childItem.setText("Child 1.2");
item = new CTreeComboItem(combo,SWT.NONE);
item.setText("Parent 2");
childItem = new CTreeComboItem(item,SWT.NONE);
childItem.setText("Child 2.1");
childItem = new CTreeComboItem(item,SWT.NONE);
childItem.setText("Child 2.2");
CTreeCombo now works like an ordinary SWT-Tree providing the same API as SWT-Tree (at least currently the one which is necessary to write a JFace-Viewer) so that I could subclass AbstractTreeViewer and providing an implementation for it. So if one uses JFace-Viewers in his/her code they simply need to write:
int style = SWT.READ_ONLY|SWT.BORDER|SWT.FULL_SELECTION
CTreeCombo combo = new CTreeCombo(parent,style);
CTreeComboViewer viewer = new CTreeComboViewer(combo);
viewer.setLabelProvider(new LabelProviderImpl());
viewer.setContentProvider(new ContentProviderImpl());
viewer.setInput(input);
In the end it took me longer than I first thought but after 4 hours I had a working CTreeComboViewer (although it is not thoroughly tested yet) which behaves appropiately (at least in the way I currently use it).
If you are interested in the code of the widget or in the application to learn about:
- Writing a modular RCP-Application
- Using SWT, JFace and Databinding
- Using EMF and EMF-Databinding
- Using and creating your own Extension Points
- Using and extending the Commands, Handlers and the Expression Framework
You can fetch the code from my companies svn-repository but the application is still in flux. If you are only interested in the widget and viewer code you can find it here for the widget and here for the viewer.
Friday, June 13, 2008
Ganymede - What's in JFace and Databinding
The History
JFace-Viewers/ToolTips
In 3.3 the whole Viewer-Infrastructur has been reworked to make it easier to add new features in upcoming releases. Some new features where part of 3.3 (e.g. LabelProvider/Column, CellNavigation, Customizable-Editor). Additionally JFace opened up its viewers for subclassers by wrapping Widget-Specific API (ViewerRow/ViewerCell).
Databinding
3.3 saw the first public release of the Eclipse-Databinding-Framework which removes the need for myiards of listeners to keep your model and UI in sync. Anbody who ever had write a Master-Detail-UI knows how hard it is to get it right.
Today
JFace-Viewers
We saw great adoption of our new API and new features added ontop of it. The most significat one is a LabelProvider which understands StyledText-Instructions named StyledCellLabelProvider. You'll see this LabelProvider in action if you open the Java-ProjectExplorer.
On the other hand we also saw great adoption of our API-Opening-Up effort which allows widget vendors to provide a JFace-Viewer-API for their structured widgets. There are 2 Nebula-Components (Nebula-Gallery and Nebula-Grid) who already adopted the concept and provide a viewer.
Thanks for the great feedback and bug reports from the community we fixed some [92] problems and feature request some of them dating back to 2003!
In comparison to Europa-Release we didn't introduced much new API. From my point of the main focus was to evolve the new API we provided in 3.3 and fix problems which have been introduced. If you saw how much code has been rewritten in 3.3 I think this was thr right thing (although we fairly broke no backward code anyways in 3.3).
Databinding
Thanks to the community and Ed Merks and his team there's now a 2nd possibility to back up your UI with a model beside JavaBeans.
Naturally they provide integration for their EMF-Objects with 2 brand new plugins named org.eclipse.emf.databinding and org.eclipse.emf.databinding.edit. Those plugins are marked as provisional but I'm using them since day 1 in my projects and for the standard cases they just work fine and whenever a bug occurs it's fixed immediately. Give it a try and see how fast you can develop powerful SWT-UIs.
At the very moment you bring EMF into your project it opens up the door for fairly everything you and your customers ever dreamed of (take a look at the teneo to presist your model in a SQL-Database using hibernate, working with distributed objects using CDO, validating your model using OCL and much more).
On UI-Side of Databinding also many new features have been added. You have support for Inline-Editing in Table/TreeViewers (every control inheriting from it e.g. GridViewer), there's new support for Observable-TreeViewers and naturally many many bugfixes [75].
The future
JFace-Viewers/ToolTips
Naturally we are going to fix bugs and problems. I have already some bugs in my queue I can address after the Ganymede-Release is out of the doors. Looking at this back log of viewer bugs [228] I'm going to try to bring this bug count down a bit (say 200 is a good number).
Databinding
I see a bright future for databinding and I'll restart my work on bringing all this (databinding+emf) to the web using it in my GWT-Enabled applications inside my UFace-project if time permits.
Summary
I think all people worked on the projects above have done an amazing job. We fixed many bugs added many great new features, many with the help from the community whether they filed sensetational bug reports or even provided patches. A big thank goes out to you, the community.
One more note in the end. In time of 3.4 we saw the creation of a new project called E4. It was discussed controversial in the blog space and on mailling list as you all known.
After EclipseCon I decided as a community member to take part in this effort for the next generation of an UI-Framework provided by the Eclipse Organisation and had a lot of fun until then. If you are interested in learning new things and exploring new areas in space of ui, resource-managment, model-driven development I can only advice you to take part and learn how to organize, design and implement one of the tools that will have infulence on the next generation of thousands of commercial and none-commercial products.
Thursday, June 05, 2008
E4 is more about bringing it to the web
E4 is much more and that SWT gets a web-port is only a small part. Here's my top list of things for E4:
- Modeldriven:
One extensible model backing up the whole workbench - DOM: At the moment the Workbench is backed up by ONE model you automatically have a DOM and you can do with this DOM the same you do in Web-Applications (See my prototype)
- New Resource Framework:
Making handling resources much more Flexible - New Listener Concept:
The current listener concept in eclipse sucks and makes eclipse slower than it could be - NO SINGLETONS AND STATIC FIELDS
- Plugins in NONE-Java: Make it possible to write an Eclipse-Plugin in other languages (JavaScript, ...)
- Declarative UI, Easier Styling .... and much more
Tuesday, May 20, 2008
A radical approach to explore new paths for e4
It was quite cool to get insights into the platform code and with the code already created for EclipseCon it was not really an achievement to get something running within a fairly short time but finally I wasn't really happy because of multiple things:
- I had to work around problems from the beginning to get a workbench up and running
- It was hard to add new features because I was limited to things I could find a work-around for or going to learn the complete platform code which would have driven me mad
- There was lack of feedback on the real code and we talked more about EMF pros and cons than concentrating on how we want to solve things (I'm still an EMF believer :-)
I asked myself how to solve the following problems:
- How can I get up an Workbench-Window without any of the legacy code
- How can I easily add features
- How can I encourage people to work on E4 without having a deep understanding what's going on inside the current platform. In fact how can I get people outside the Platform-UI-Team to look at the code and understand in an affordable amount of time the concepts behind the workbench and bring up interesting ideas or outline how they think a feature can be implemented
- A workbench with dependency on org.eclipse.jface, org.eclipse.equinox.common, org.eclipse.osgi, org.eclipse.emf
- Built around an extensible EMF-Model
- NO plugin.xml and NO .exsd (you'll see later how I extend the platform - it's a radical approach I know and looking back it got even more radical then I first thought it's going to be)
- Similar but slightly improved EMF-Model compared the original one used to straight port the EclipseCon-Example
- Allow multiple instances of the workbench inside one OSGi-Env - no singletons, no static variables!
- As few API-Methods as possible (=suppress all the EMF-Methods and adding API-Methods e.g. to attach listeners or traverse the DOM generically) but still strongly typed
- provide support for Scripting
Step 1: Redesign The Model From PROTOTYPE_1
I started to redesign the original model and removed some things I didn't like or found they are not needed yet. For example styles/styleclasses now work like they do in a Browser:
.myActiveView {
color: #FF0000;
background-color: #0000FF;
}
<span class="myActiveView" >Green on Blue</span>
where the style-properties and the class-properties are merged. I also moved all UI-Data (Font,Color,Gradient,...) from the UI-Element to the "css"-style definition whether an UI-Element reacts on a style property is the choice of the UI-Element and its implementor.Step 2: Implementing the Workbench-UI-Core From Scratch
With the .ecore-Definition from Step 1 I created a static workbench.xmi file which defines a model of a static workbench.(Yes I started from a static model you'll see how dynamic such a model gets later). The final source code is ~ 88KB and the resulting .jar 36KB (the model, emf-dependencies are not part of this figures of course). But I think the target is reached I think there's no class having more than 500 Lines of Code (including the comments).Creating .xmi-Files is a fairly trivial task because EMF comes with a generic editor and I guess people who know GMF could have written a graphical one with in a minute (any GMF-volunteers around?). When this step was finished my XMI-File looked like this
Step 3: Making the model dynamic
When starting Step 3 I first headed of and created .exsd-Files (you can see them here) to contribute the information to my model (views/perspectives). But while doing this I recognized that I'm redefining my .ecore-Model-Elements using .exsd so why the hell do I not provide plugin.xmi-artefacts instead of those plugin.xml files and at runtime create a complete workbench.xmi from all those artefacts. The hard part was to reimplement the loading of xmi-File (or rather to identify the source-code where the plugin.xml is processed to copy the logic). This left me with 3 files
- workbench.xmi in org.eclipse.e4.workbench.ui

- plugin.xmi in org.eclipse.e4.workbench.ui.ide contributing to workbench.xmi

- plugin.xmi in org.eclipse.e4.workbench.ui.rhino contributing to plugin.xmi from org.eclipse.e4.workbench.ui.ide
Step 4: Implementing a Scritable-DOM
So now I had a workbench-model constructed at runtime using XMI-Artefacts. Doing some cool UI-Stuff was the next on my list. Wraping up an EObject as an Object-Scritable for Rhino was something I had already written for PROTOTYPE_1 so I "stole" the code from myself. The top feature on my list was to move a View (in 3.3 a ViewPart) in the model and automatically update the UI. So I wrote a view which presented the current workbench model inside a TreeViewer and allowed me to drag a view from stack to stack. It wasn't really is to distinguish a move from a remove but with help from Ed I managed to get it working. See the screen cast at the end of this posting.

Step 5: Persisting the current workbench state
So I was able to drag around the views but everytime I shut down the workbench and restarted model was recreated from the artifacts and started in the initial state. So adding persistance was next the next "big" issue. Well there's nothing more to say than these lines of code:
if (!restore) {
uri = URI.createPlatformPluginURI(
"/org.eclipse.e4.workbench.ui/META-INF/EWorkbench.xmi",true);
} else {
uri = URI.createFileURI(restoreFile);
}
// Save
try {
((EObject)workbench).eResource().save(null);
} catch (IOException e) {
e.printStackTrace();
}
Step 6: Extending the extension
Haven't you ever dreamed of extending an extension. I decided that my WorkbenchStructureViewPart should restore the current selection when coming up from a restored state but my generic model-element I contribute didn't had a slot to restore the information. So I digged into and searched how EMF allows me to extend an existing element (in fact once more Ed pointed me in the right direction). Now the plugin.xmi contributed by org.eclipse.e4.workbench.ui.rhino looks like this.
Step 7: Multiple Instances of the workbench
Not using org.eclipse.ui, no singletons and static variables automatically allows to have multiple workbench instances running. So in theory making this workbench run on top of the RAP framework should be possible without patching any code parts.

Acknowledgement / A Screencast / How to get it run
Before I forget about it two other guys (Boris and Ed) provided ideas, code and input to those freaking lines of code available from Eclipse-CVS using this ProjectSet.
Finally I created a Screencast for you to look at (it's a bit big (15MB) because I have no idea how to do Screencasting with OSS-Software on OS-X).
You'll see that I radically stripped down everything and made some strange decisions (e.g. no plugin.xml), backwards compatibility is not addressed at all, ... . Whether you like the idea of contributing XMI-Artefacts instead of .exsd & plugin.xml is not the question. The interesting thing IMHO is that it takes so few lines of code to show a nice workbench backed up by a model and reacting on (structural-)changes inside of it.


