Meta-Modelling with eMoflon::IBeX
Learn how to use the EMF modelling framework with eMoflon::IBeX

Sokoban (Japanese for warehouse keeper) is a cool puzzle game, in which you (the sokoban) have to push boxes to designated end positions.  The warehouse is typically littered with unmovable boulders to make things more challenging.  In this first part of our handbook we’ll concentrate on modelling the concepts and relations required to describe this game using EMF and eMoflon::Core, which provides a few extra goodies to make working with EMF more easy and enjoyable.  eMoflon::Core is part of the eMoflon::IBeX tool suite, which also supports unidirectional and bidirectional model transformation via graph transformations.    

To enjoy this handbook you should have very basic knowledge of Eclipse, Java, and more or less of meta-modelling in general (we won’t explain what exactly a meta-model is).

Install eMoflon::IBeX

  1. Install Eclipse Modeling Tools.  Make sure you take Eclipse Modeling.  We always try to support the very latest version of Eclipse so go ahead and take the latest.
  1. Install eMoflon::IBeX:
  • Click on HelpInstall New Software.
  • Paste this update site into the Eclipse Installation Manager
  • Select eMoflon IBeX::Democles and make sure that “Contact all update sites during install…” is selected. 
  • Before clicking on Next, you have to enable all newly added update sites.  To do this click on Manage, select all sites as indicated in the screenshot below, and click Apply and Close.  If you skip this step, the installation will fail due to missing dependencies.
  • Start the installation by clicking Next.  This might take some time depending on your internet connection.  To speed things up you could try deactivating some standard Eclipse update sites (such as The Eclipse Project Updates), which you don’t need right now for the installation.
  1. Switch to the eMoflon perspective:
  • To confirm that the installation was successful, open the eMoflon perspective by choosing WindowOpen PerspectiveOther…
  • Choose eMoflon from the list and click Open.
  • If everything went well, your workspace should now look like this (new features outlined in red).
  1. Make sure PlantUML is installed and configured properly:  Note the PlantUML view to the right of the editor area directly beside the standard Outline view.  We use PlantUML a lot for visualising all kind of stuff and you’ll have to install Graphviz to get it running (but you might be lucky and already have this installed on your system).

Create a new meta-model

  1. Create an eMoflon EMF Project by clicking on the the new wizard button in the toolbar (the one with a project and a cute little plug/adapter symbol).
  1. Choose SokobanLanguage” as project name and click Finish.  Don’t be creative here and just do as you’re told so everything else works later (you’ve been warned).
  1. In the newly created project, navigate to the .ecore file under /model and double-click it to open the Sample Ecore Editor:

Add concepts and relations for Sokoban

Creating concepts as classes

  • Add your first EClass by right clicking the SokobanLanguage package, going to New Child and choosing EClass:
  • Choose the newly created EClass in the editor and enter “Block” as name in the Properties view below the editor (marked in the screenshot).  Leave all other properties as they are for the moment.  
  • Click on the PlantUML view to set focus to it (and bring it infront of the Outline view).  As from now, always look in the view to see what is being visualised.  For meta-models we provide a helpful class diagram visualisation that adjusts itself to what you select in the editor.  If you select the root element the entire meta-model is visualised, if you select a set of elements only these elements and their direct neighbours are visualised.  This is pretty awesomely helpful when trying to make sense of a huge meta-model with scores of classes.     
  • Now that you know how to add classes, go ahead and add Board, Boulder, Field, Figure and of course Sokoban.
  • Make the Figure abstract by selecting it, and then setting its property Abstract to true.

Adding super classes

  • Make Block inherit from Boulder by selecting Block, going to ESuperTypes under Properties, and selecting the little button to the right of the property entry.  This should pop-up an extra window from which you can choose Boulder as a super class.  Click Add and finally click OK.
  • Repeat this step to make Boulder and Sokoban inherit from Figure.  Your editor should look something like this:
  • Now is probably a good time to play around with the visualisation.  Choose the root node in the editor to visualise the entire meta-model (see the screenshot below).  See what happens when you only choose one of the classes.  How about choosing two?

Creating parent-child relations as containment references