March 23, 2011

EMFPath @ Eclipse Con 2011

I just finished presenting my talk about EMFPath @ Eclipse Con 2011. Here are the slides I used to introduce Guava and EMFPath.


November 2, 2010

Creating Android Application with Eclipse Modeling @ ESE 2010

Live from Eclipse Summit Europe 2010.

This morning I gave a tutorial with Stéphane Bégaudeau (my colleague from Obeo) and people from Itemis (Jan Koehlnein, Holger Schill and Dennis Hübner). The purpose was to demonstrate how to use Eclipse Modeling technologies to create an Xtext textual DSL and Acceleo generators to model and generate the code of Android applications.

Here are the slides from the Acceleo generator part :

September 24, 2010

How to embed Xtext editors within Eclipse Forms editors?

With the growing usage of Xtext, people would like to integrate the Xtext editor within other editors. It is useful when a part of a edited model is best described textually and you want to benefit of all almost-free Xtext editor features.

In this goal, I recently created a sample RCP application to demonstrate how to do such a thing. This sample RCP application is hosted within the xtext-forms-integration project on EclipseLabs. This contribution has been made possible thanks to ProxiAD, Obeo and Itemis AG companies.


The framework part of this project is rather small and thus very re-usable. Have a look on the code to make your own opinion. In the mid term, we think it may be interresting to have these classes in the xtext.ui plugin to help people integrating Xtext editors.

Special thanks to Cédric Vidal (blog in french), Sebastian Zarnekow, Nirmal Sasidharan and Andreas Graf for their help and participation.

September 15, 2010

First binary release of EMFPath

The binaries of the EMFPath project are finally available. The release is tagged 0.3.0. It is an early release and the API is still subject to change. Do not hesitate to report bugs or features requests on the tracker page.

The release is available in two shapes:

EMFPath depends on Google Guava r05. People who want to use EMFPath from Eclipse may also want to use the Guava OSGi bundles available from the guava-bundle project. This project provides a P2 repository with all of the released versions of Google Guava.

Note: EMFPath is a set of functions and predicates (as defined by Google Guava libraries) along with a set of utility methods to help navigating and editing Eclipse EMF models.

August 11, 2010

Guava releases as OSGi bundles (with update site)

Last week I created a new project on Eclipse Labs named guava-bundle that provides OSGi bundles of Guava releases along with a P2 update site.

The update site provides SDK (with sources and Javadoc) and Runtime (binary only) features for the following releases:
Guava follows a simple incremental numbering scheme for its releases versionning. As OSGi needs a finest level of details for versionning, guava-bundle mapped this scheme as follow:

A Guava release rX where X is the integral version number of the release will be available in guava-bundle 1.X.0.

For instance, the r05 release is available in the bundle with version number 1.5.0.

All OSGi metadata are synchronized with this version number mapping:
  • Bundles (aka plugins) versions,
  • Exported packages versions,
  • Features versions

Have fun!

Note: there is a similar project named guava-osgi but it only has the r03 release. I suggested to merge the two projects but I did not had an answer yet.

June 2, 2010

Creating a index of EObjects by their type with EMFPath

On common need you may have when working with EMF, it to build an index of elements by their type. In this post index will be an instance of the Multimap class of Google Collections (basically, it is an abstraction of Map<K, Collection<V>>).

Let's say we have an EMF Resource named eResource.

First, we get the whole contents in an Iterable and we give it to the index() method of the Multimaps class and the EObjects.eClass Function as the indexing function.

Iterable<EObject> descendants = descendant.of(eResource);
Multimap<EClass, EObject> descendantsByEClass = Multimaps.index(descendants, EObjects.eClass);

This is a strict index that does not index elements regarding their EClass supertypes' hierarchy. For instance if have an EClass referenced by a variable named b_EClass, descendantsByEClass.get(b_EClass) will return all elements having b_EClass as their EClass, but it will not return elements having a subclass of b_EClass as their own EClass:

EClass a, b; // b inherits from a
descendantsByEClass
.get(b); // will return elements of type b but not a

To do so, we have to substitute the indexing function EObjects.eClass by a composite one. This composite Function get the EClass of the current EObject and return this EClass and all its supertypes. To put all indexes into the Multimap, we have to change to call of Multimaps.index to Multimaps2.index to create an index of all elements by kind:

Iterable<EObject> descendants = descendant.of(eResource);
Multimap<EClass, EObject> descendantsByKind = Multimaps2.index(descendants, Functions.compose(EClasses.eAllSuperTypesAndSelf, EObjects.eClass));

Now, descendantsByEClass.get() will return elements of type b and its supertypes.

EClass a, b; // b inherits from a
descendantsByEClass
.get(b); // will return elements of type b and a

An equivalent without EMFPath nor Google Collections would be:

TreeIterator<EObject> it = eResource.getAllContents();
Map<EClass, List<EObject>> index = new HashMap<EClass, List<EObject>>();
while(it.hasNext()) {
EObject current = it.next();
EClass eClass = current.eClass();
addValueToMap
(index, eClass, current);
for (EClass supertype : eClass.getEAllSuperTypes()) {
addValueToMap
(index, supertype, current);
}
}

public static void addValueToMap(Map<EClass, List<EObject>> index, EClass k, EObject v) {
List<EObject> values = index.get(k);
if (values == null) {
values
= new ArrayList<EObject>();
index
.put(k, values);
}
values
.add(v);
}

No comment ;)

May 26, 2010

EMFPath is available on Eclipse Labs

The EMFPath project is now available on EclipseLabs.

EMFPath is a Java framework based on Google Collections for browsing / editing EMF models. It has a concise and DSL-like API and has been designed with performance in mind.
There are no binary build yet, the API is still in Beta stage and then subject to change. It also lacks some documentations like a "Quick start", but everything is released so you can use it today.

You are welcome to provide feedback / comments / reviews / contributions ;)