Matthias Schoettle

PhD Student & Software Developer

Category: Frameworks

MT4j with Processing 2

In our TouchCORE project at the Software Engineering Lab at McGill University, we use MT4j (Multitouch for Java) for the multitouch-enabled user interface.

For a long time, we had the problem that we couldn’t run it on OSX using Java 7 and newer, because it is based on an older version of Processing (1.x), which in turn uses an old version of JOGL (Java Binding for the OpenGL API). That version is only compatible with the Java supplied by Apple. As we know, they stopped support with Java 6.

We grudgingly lived with this state for a long time, which meant that OSX users needed to download and use an old version of Java. Now, with the new release of Eclipse Mars, support for Java 6 was dropped, i.e., Java 7 or greater is required. We wanted to update to Mars, and since we use some Eclipse plugins, such as the Eclipse Modeling Framework (EMF), we needed to use at least Java 7.

This finally pushed us to update MT4j ourselves. With the help of the UltraCom project who did the same but added a ton of other stuff. Based on their commits we managed to update it on our copy (which already had some minor improvements) of MT4j’s last official release v0.98.

We put it up on GitHub so hopefully other people can benefit from it: https://github.com/mschoettle/mt4j

How to use OCL when running EMF standalone with Eclipse Mars

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

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.

General approach: If you want to change the text independent from the element, meaning for all elements, you should change the _UI_CreateChild_text key in plugin.properties. By default this is {0}. This refers to the type name of the child. Also available are the feature text ({1}) and the type name of the owner ({2}).

Case-specific approach: If you just need to adjust it for one element, simply overwrite getCreateChildText(Object, Object, Object, Collection<?>) in the corresponding item provider and adjust it to your needs. Here is an example, that simply adds the features’ text in front of the default child text:

@Override
public String getCreateChildText(Object owner, Object feature,
        Object child, Collection<?> selection) {
    StringBuffer result = new StringBuffer();

    result.append(getFeatureText(feature));
    result.append(" ");
    result.append(super.getCreateChildText(owner, feature, child, selection));

    return result.toString();
}

How to use OCL when running EMF standalone

If you are using EMF standalone, i.e. you are not running it in an Eclipse-based environment, and you want to use OCL some additional steps have to be performed besides registering your resource factory.

This description is for the MDT OCL project which can be found and installed from the Juno update site under Modeling > OCL Examples and Editors.

Note: See the update on Eclipse Mars.

Continue reading

Things discovered in Struts 2

In this post I write about some things I discovered during the development of a project where Struts 2 is used. I note them since I couldn’t find them in the documentation and they were discovered through digging through pieces of documentation, the code and the web.

In general, sometimes more detailed information can be found in the Javadoc of the frameworks classes, e.g. interceptors.

Continue reading

© 2017 Matthias Schoettle

Theme by Anders NorenUp ↑