Example: Modify a Tree model with EOL


  • AddLeaves.eol
  • Tree.emf
  • Get it!
var i := 0;
for (leaf in Tree.all.select(t|t.children.isEmpty())) {
  var child : new Tree;
  i := i+1;
  child.label := 'Added' + i;
  leaf.children.add(child);
}

Model.store(Model.modelFile + 'copy.model');
@namespace(uri="Tree", prefix="Tree")
package Tree;

class Tree {
   val Tree[*]#parent children;
   ref Tree#children parent;
   attr String label;
}

There are two ways to get the code of this example:

  1. download the following zip archive(s), extract them and import them as new Eclipse projects
  2. or check out the code from the SVN
    • go to the SVN repository
    • navigate to trunk/examples
    • check out the org.eclipse.epsilon.examples.metamodels project
    • check out the org.eclipse.epsilon.examples.modelmodification project

Once you have checked out/imported the code, to run the example you need to go through the following steps:

  1. register all .ecore metamodels in the org.eclipse.epsilon.examples.metamodels project (select all of them and then right click and select Register EPackages)
  2. right click the .launch file in the org.eclipse.epsilon.examples.modelmodification project
  3. select Run as... and click the first item in the menu that pops up