Galileo: Improved EMF-Databinding-Support

DZone 's Guide to

Galileo: Improved EMF-Databinding-Support

· Java Zone ·
Free Resource

I’m happy to announce that EMF-2.5 will come along with support for the brand new Eclipse-Databinding API coming with Eclipse-Galileo. A big kudos goes to Matthew Hall who reviewed my patches and helped me shapeing the support and it’s documentation (more in bug 262160).

I got voted in some weeks ago as a committer on EMF and so now I’m in charge of the Databinding-Support for EMF and I’ll try to fix problems with the API and give answer to questions on the Newsgroup.

Before I start explaining some nifty and nice things about the API and how one can use (and probably extend) it let me state that the API is marked as provisional and there are chances (though small ones) that we’ll introduce a breaking API change in the next release.

This is going to be a series of blog postings showing some new EMF-Databinding stuff in action:

  • Part 1: Create the Domain-Model
  • Part 2: Introduce the new Properties API
  • Part 3: Setting up a TreeViewer with EMF-Databinding
  • Part 4: Using the properties API in master-detail
  • Part 5: Setting up a TableViewer with EMF-Databinding
  • Part 6: Write your own Property for unsupport Widget-Types
  • Part 7: Make the storage system plugable

To give you a possible jump-start on EMF-Databinding I’ve been working on an example application in the last few days.
Sample Application
All example code is available from Eclipse-CVS and released under EPL.

Creation of the Domain-Model

Before we can start with the domain model for our application we need to know
what the model is going to be for. So let me explain the application we are
going to write in this blog series:

Suppose the Eclipse Foundation hired you to write an application which allows them to administrate their committer and project metadata.

We now need to create a domain model of this minimal information given
which could potentially look like this:
Screen shot of the Ecore-Editor
Let’s take a closer look on the domain model objects:

  • Foundation
    Foundation Class
    The root of the domain model is the foundation which has 2 list properties:
    • projects: top level projects like EMF, Technology, Platform, …
    • persons: persons who take a part in one ore multiple projects
  • Project
    Project Class
    An Eclipse project has many different properties from the project start to the project end date to the url of the homepage. The most interesting ones are:
    • subprojects: a project can have subprojects who can then itself have subprojects
    • parent: a project has one parent pro ject (beside the top-level ones) – this means projet-subprojects relation is modeled as a bidirectional relationship
    • projectleads: a projet can have multiple project leads
    • committers: a project has multiple committers
  • CommitterShip
    Committership Class
    People who are committers on a project get a so called committership which has a start and end date. The most interesting of them are:
    • project: the project the committership is for – this means once more that the committership-project relation is modeled as a bidirectional relationship
    • person: the person who holds the committership
  • Person
    Person Class
    The “real” person who gets committer or project lead on a project. The field of interest here is:
    • committerships: which holds all committerships a person has this means that the committership-person relation is also once more modeled as a bidirectional relationship

To get a highlevel overview above the model and how the classes are related together the Class-Diagram helps a lot:
As you noticed I modeled many of the relations as bidirectional relations. This is not strictly need everywhere because some of the relations like project-subproject have an implicit parent relation because they are containments and hence eContainer() could be used to access the parent. Still when it comes to databinding such a containment relationship doesn’t help because there’s no feature you can use to navigate from child to container but only the call to the method eContainer().

EMF also provides an editor to create an instance of your Ecore-Model and save it to XMI which makes it easy for us to create test data. An example of an XMI looks like this:

 From http://tomsondev.bestsolution.at


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}