Friday, October 30, 2009

Eclipse Summit Europe 2009 retrospective

Attending Eclipse Summit Europe 2009 once again felt like a big family meeting. It is always a pleasure to meet people you usually only correspond with electronically in person. The organization was once again almost perfect and the food excellent. Thanks a lot to the organizers and sponsors!

We had a very productive project meeting for the EMF Index project, clarifying a lot of critical points and further aligning the efforts and requirements of the involved parties.

Markus, Sebastian, Karsten and me were impressed by the large number of about 50 participants in our workshop on Domain-specific Languages with Eclipse Modeling. The slides are now online at slideshare, just in case you're interested. With such an audience it was of course a little bit difficult to make it a real hands-on experience, but I think we at least managed to leave a good impression on the presented toolchain.

Jos's and my talk on Combining text and graphics in modeling tools was also well attended, and from the quality of questions that were asked I guess our message has been understood. The slides are also available at slideshare.

Apart from a number of really impressive talks, the thing that most impressed me was SAP's graphical editing framework. Instead of using a code-generation approach it rather focusses on an provider-based Java API. They are currently in the process of adapting it to EMF and their plan is to make it open source. I hope they really do, because it seems to have the potential of greatly reducing the complexity of creating graphical editors.

Sunday, October 25, 2009

GMFTools Part 2: Sharing an EditingDomain

In this blog, I will elaborate on how GMFTools facilitates to share the same instance of an EditingDomain across multiple diagram editors.

What is an EditingDomain?

In GMF, each diagram editor works on its own instance of a so called TransactionalEditingDomain. TransactionalEditingDomain is a concept from EMF Transaction. In GMF, it contains an EMF ResourceSet holding the diagram model, its semantic model and all referenced models as well as a command stack for undo/redo support. In addition, each editor registers a WorkspaceSynchronizer to its resource files, making sure external changes are synchronized with the editor's content.

Why share the EditingDomain?

In the default setup, problems occur if two editors operate on the same resources: If both editors change the same resource, saving one will overwrite the changes of the other. This situation already happens when you're using the Related Diagrams feature in the gmfmap model: On double click, it will open a new diagram that is saved in the same resource but in a different editing domain. As the original editor is still open, conflicts can arise quickly.

Another reason for sharing the editing domain is to save memory and performance, especially if you're working on big models with a couple of editors.

In many cases you might want to see changes immediately in all editors without having to save first, e.g. when your editors show different parts or aspects of the same model. GMF has already built-in support for that as it uses EMF's notification mechanism to synchronize the notation (diagram) model with the semantic model.

Consequences of sharing an EditingDomain

Sharing the editing domain across several editors has a number of consequences
  • The editors will also share the same command stack. Undo/redo becomes a global operation and can therefore affect other editors than the currently active one.
  • For reasons of simplicity, all editors should be saved synchronously, and they will all be either dirty or clean at the same time.
  • You should no longer dispose the editing domain when closing an editor. That means, to avoid memory leaks you need strategy for unloading unneeded resources.
  • The command stack will keep references to unloaded model elements, too, so you might want to have an garbage collecting strategy here as well or at least keep the command history short.
Solution in GMFTools

The solution in GMFTools is based on a WiKi page of GMF and a couple of newsgroup entries combined with our own experiences. It has been recently refactored to reenable the WorkspaceSynchronizer.

It comes in a number of aspectual template changes for the GMF code generator, an additional runtime plug-in and tool support for fixing the type registry, such that it is rather easy to consume even if you're not too familiar with the GMF runtime. Note that so far we have only been using it to generate plain diagram plug-ins, i.e. not for GMF's RCP generator.

The major changes are
  • Redirect all creation statements of an editing domain to a new utility class and the dispose statements to an unloading tool.
  • Make sure to use consistent element types.
  • The common behavior of all XXDocumentProvider.ResourceSetInfo has been extracted to avoid synchronization feedback loops.
If you're interested in the details have a look at the WiKi-page.

Friday, October 9, 2009

GMFTools Part 1: UI Extensions

This is the first of a short series of posts on GMFTools.

The Graphical Modeling Framework is a powerful framework for the development of graphical editors for EMF-based models. It's based on EMF and GEF and uses a model-driven approach for designing the editors.

Building graphical editors is a complex task. While GMF tries to facilitate that procedure, its abstractions are sometimes still a little hard to grasp, and the generated results often need manual fine-tunig to meet end-user expectations. I am a user, not a developer of GMF. Mymain concern is getting things done in the projects I am working on. That's why I sometimes bend GMF to do what I want it do, rather than use it the way it is meant to be used. That fact makes it somehow hard to contribute back to the GMF project. Still, me and my colleagues take a lot of benefit from using GMF.


As a long term user of GMF, I started to collect code, tools, samples and several tipps and tricks in the GMFTools project about a year ago. In the meantime, the project has attracted additional committers and it has become quite a useful collection of real-world solutions around GMF.

GMFTools roughly consists of three components
  • UI-Extensions making GMF easier to use.
  • Runtime extensions that add new functionality by means of additional classes and generator template changes.
  • Examples demonstrating the use of the runtime extensions.
The GMFTools Button

The first thing that may catch your attention after having installed GMFTools is a new GMF button in your button bar. It is meant to make GMF development easier and performs a bunch of actions on your GMF projects, including running the GMF code generator. To see what kind of actions, open the preference page for GMFTools. Each action can be enabled and disabled separately.

Most of the actions are self-explanatory. You may wonder why I want to delete the gmfgen model and the diagram code before re-generating. The reason is that by deleting the generated artifacts before re-generation, I circumvent all reconciliation steps (including JMerge). I have very bad experiences with reconcilers in general and so I prefer not to mix manually written and generated code. Some people have called me a "purist" for this attitude, but from my experience a clean separation will pay in the long run of a model-driven project.

As a consequence gmfgen model becomes a temporary artifact in the whole code generation procedure. To be able to modify the gmfgen model nevertheless, I have introduced a model-to-model transformation that is performed before generating the actual diagram code from the gmfgen model. This transformation is performed using an Xtend file (both oAW and M2T work) which is persisted next to your GMF design models.

The fix of the type registration will be covered in a post on shared editing domains.

In the middle of the preferences, you can manipulate your current set of GMF models (might not be the best name), i.e. the combinations of ecore, genmodel, gmfgraph, gmftool and gmfmap models you need to generate a GMF editor, as well as the Xtend transformation. These sets can also be provided by means of *.def files that can be stored in your workspace next to the design models.

By a single click on the GMF button, all enabled actions are executed on the currently / last selected models. In its drop-down menu you can access all your editor model individually. That really speeds up GMF development significantly, as you no longer have to find your way through the popup menus of different files. Nevertheless, individual actions can still be executed from the popup menus of the respective files.

That's all for today. Stay tuned for more.

Thursday, October 8, 2009

Eclipse Summit Europe 2009

I'm speaking at Eclipse Summit Europe 2009
I am looking forward to Eclipse Summit Europe 2009 in Ludwigsburg, Germany.

My colleagues from itemis and me, we're once again going to have our share:

Sebastian Zarnekow, Karsten Thoms, Markus Voelter and me are going to give a tutorial on Domain-specific Languages with Eclipse Modeling, in which we show how to set up your own easy-to-use MDSD toolchain.

In the short talk Combining Graphics and Text in Modeling Tools, Jos Warmer and me will be elaborating on mixing concrete syntaxes for the same model using state-of-the-art modeling tool frameworks such as Xtext and GMF.

In the talk Xtext - From Galileo to Helios, Sven Efftinge and Sebastian Zarnekow are presenting the future plans for Xtext.

Finally, Andreas Graf and Markus Voelter are going to talk on Leighweight Model-Driven Development for Embedded Systems.

So, maybe there's something in for you, too?

Monday, October 5, 2009

MacOSX window trouble

Clever people know that cleaning your keyboard while your computer is switched on might be a bad idea. I did anyway, and as a result my Eclipse window looked like this:

For the non MacOSX experts: You won't be able to click on the right restore button, and there is no such menu entry anywhere. Luckily, Eclipse can be restored using Window->New Window (thanks for the hint, Sebastian). Restarting the application or the computer would not work.

But how's that supposed to work in MacOSX anyway? I found a couple of Applescript solutions, but nothing really user-friendly in the internet. I couldn't even figure out how I got into this situation. Any ideas?