Vainolo's Blog


leave a comment


List of general plug-ins that I have installed and use with eclipse:

Just downloaded the Aptana Studio plugin for eclipse, to learn ruby and rails. We’ll see how it fares

05/07/2012 – Aptana studio did not give me the extra power I thought it would. Ended up coding ruby and rails using only vi. Sad but true.

Eclipse Editor Tricks

You can disable the Java code formatter in a specific part of your code by adding // @formatter:off at the start of the code and // @formatter:on at the end. You must also enable this in the “Java formatter preferences” which is located in “Preferences->Java->Code Style->Formatter”, click on “Edit”, and the option should be available in the last tab. You can also customize the text used to enable and disable the formatter.


Maven, Tycho, and Eclipse Plugins

  • Eclipse plugins are built using the Tycho Maven plugin
  • As usual, Vogella has a great tutorial on how to build eclipse plugins with maven and tycho
  • Another great Tycho tutorial from Code & Me.
  • List of RCP Best Practices. Great place to get started.
  • List of Tycho packaging types.
  • The version in the maven POM file must match the version in the MANIFEST.MF, except for snapshot builds where maven uses a.b.c-SNAPSHOT and eclipse uses a.b.c.qualifier
  • To promote the latest version (say 0.0.1-SNAPSHOT) to the next release (for example 0.1.0) without having to manually change all your POM and MANIFEST.MF files, you can use the Tycho version plugin which updates all POM and MANIFEST.MF files in one single step. For this you must include the plugin in your POM as follows (remember to update the tycho version as it evolves):

    And execute in the command line:

    > mvn org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion="{new version}"


Basic EMF principles can be found in the EMF Refcard from DZone.

Creating a new ecore:

  • Ns URI is an attribute used for XML serialization of EMF model instances. Choose it right because changing it later can be costly. The best choice is a URL address you own, like followed by a path that you are sure will not be used later. Probably your project name is enough, getting: Ns URI: But since the namespace URI is not used by XML parsers, it does not have to exist.
  • Ns Prefix is the prefix used for XML elements of this mode. Using the last part of the URI is probably safe: Ns Prefix: myprojectname

Code Generation: some flags I use when generating code with an EMF Generator file. The property’s category comes in parenthesis after the property name:

  • Flags for root node:
    • Compliance Level (All): usually set it to 7.0 (Java 7). The default is 5.0.
    • Suppress EMF Types (Model Feature Defaults): I set it to true so model clients don’t have to know anything about EMF. The default is false (meaning your implementation will expose EMF types, like EList to its clients. Bad practice if you ask me).
  • Flags for package node:
    • Adapter Factory (Model): creates an AdapterFactory class and a Switch class in a utilities package. No idea what they do, and they only add more irrelevant code to the model. Until I find what this means, I prefer to set this to false. The default is true.

EMF Annotations: you can do many thing by adding EMF annotations to model elements. It seems only GenModel annotations do interesting things. These annotation must be marked with source Inside this annotations you add detail nodes which can be:

  • key: documentation. value: documentation text you would like to be shown in your generated classes. This annotation can be applied to model elements.
  • key: body. value: the implementation of an operation. This annotation can be applied to operation elements. Since I don’t like to mix generated code with hand-written code, I use this operation to forward model operations to a class that has only static methods, receives the model element and implement the operation.
  • key: suppressedGetVisibility. value: true/false. Valid only for features (attributes or references). Setting this to true will suppress the generation of getters for this feature.
  • key: suppressedSetVisibility. value: true/false. Valid only for features (attributes or references). Setting this to true will suppress the generation of setters for this feature.

More EMF resources:


Eclipse plugin to export GEF editor contents to images, by Maarten Bezemer. Works!!!

Fetching the current screen coordinates in a GEF editor is done like this:

Point pos = Display.getCurrent().getCursorLocation();
pos = editor.getGraphicalViewer().getControl().toControl(pos);

Written by admin

May 14th, 2012 at 12:55 pm

Posted in

Leave a Reply

%d bloggers like this: