Skip to content

Eclipse Modeling Framework (EMF)

Making EMF models serialized in XMI available in JSON with emfjson

This post is archived. It is left as is and won't receive updates.

This summer we had two interns in our team at the Software Engineering Lab who started creating a web application for our TouchCORE tool. I have wanted this for a long time. Not only does it allow you to model in your browser, you can also do this collaboratively! For now class diagrams are supported but more supported will be added in the future (for example for sequence diagrams and feature models).

How to use OCL when running EMF standalone with Eclipse Mars

This post is archived. It is left as is and won't receive updates.

I previously explained on how to use OCL when running EMF in standalone (not as an Eclipse application). This method works until Eclipse Luna. With Eclipse Mars, OCL was heavily updated again. For instance, it was promoted out of the examples space.

The good thing is it seems to be much easier to initialize it now. Add a dependency to org.eclipse.ocl.xtext.completeocl and use the following code:

PivotStandaloneSetup.doSetup();
CompleteOCLStandaloneSetup.doSetup();

Modifying the "New Child" sub-menu items in EMF

This post is archived. It is left as is and won't receive updates.

I was just looking into a way to adjust the text of the items in the "New Child" (the same applies to "New Sibling" as well) sub-menu of the generated editor with EMF. By default the items just show the type name of the element to create. Depending on your meta-model it might be necessary to add some more information in order to be able to see which feature the new element gets added (or set) to.

The available items are depending on the current selected element. The collectNewChildDescriptors(Collection<Object>, Object) method is called on the item provider of this element. The actions for those menu items are created inside your ActionBarContributor class (see generateCreateChildActions(Collection<?>, ISelection)), which is located in the editor project. The text for this action is determined by CreateChildCommand.getText(), which in turn calls getCreateChildText(Object, Object, Object, Collection<?>) of the corresponding item provider. The default case is implemented in ItemProviderAdapter.

There seem to be two approaches, depending on what your goal is.