Example: Creating custom Java tools for Epsilon

package org.eclipse.epsilon.examples.tools;

import org.eclipse.epsilon.eol.execute.context.Variable;
import org.eclipse.epsilon.eol.tools.AbstractTool;

public class SampleTool extends AbstractTool {
  
  protected String name;
  
  public void setName(String name) {
    this.name = name;
  }
  
  public String getName() {
    return name;
  }
  
  public String sayHello() {
    return "Hello " + name;
  }
  
  // Creates a new variable called variableName
  // and adds it to the frame stack
  public void sayHelloAsVariable(String variableName) {
    context.getFrameStack().put(Variable.
      createReadOnlyVariable(variableName, sayHello()));
  }
  
}
var sampleTool = new Native("org.eclipse.epsilon.examples.tools.SampleTool");
sampleTool.name = "George";
sampleTool.sayHello().println();

sampleTool.sayHelloAsVariable("greeting");
greeting.println();
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.epsilon.common.dt.tool">
      <tool
            class="org.eclipse.epsilon.examples.tools.SampleTool"
            defaultName="SampleTool">
      </tool>
   </extension>

</plugin>
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               plugin.xml

Check out the code from the SVN:

  • go to the SVN repository
  • navigate to trunk/examples
  • check out the org.eclipse.epsilon.examples.tools project

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

  1. register any .ecore metamodels in the org.eclipse.epsilon.examples.tools project
  2. right click the .launch file in the org.eclipse.epsilon.examples.tools project
  3. select Run as... and click the first item in the menu that pops up

What's this?

In this example, we create a custom tool for Epsilon.

What are .emf files?

.emf files are Ecore metamodels expressed using the Emfatic textual syntax.

More examples...

Epsilon Object Language
Epsilon Transformation Language
Epsilon Generation Language
Epsilon Validation Language
Epsilon Merging Language
Epsilon Flock
Combining the Epsilon Languages
EuGENia
EUnit

Even more examples...

More examples are available in the examples folder of the SVN repository.