Getting Started

This page gives a simple getting started example that provides a quick tour through the basics of writing TEA Tasks and TaskChains.

Preparation

To implement TEA components, you will need a workspace with a project that will host these components. Most importantly:

  • The Target Platform needs to be set to an Eclipse installation with TEA available. The most simple case is the running Eclipse with TEA installed (see here).
  • A plug-in project that will host the code.
  • A launch configuration that will launch Eclipse with your plug-in added.

Creating the first Task

A Task in TEA is nothing more than a simple POJO with an @Execute annotated method.

@Named("My Task")
public class MyTask {
	@Execute
	public void demo(TaskingLog log) {
		log.info("Hello World!");
	}
}
					
Note how @Named can be used to set a user visible name for the task. If the annotation is not present, the toString of the Task is used, and if this is the default Object.toString the simple class name of the Task is used as a last resort.

Creating the first TaskChain

Now that there is a Task, we want to execute it somehow. TEA uses TaskChains to accomplish this.

Each TaskChain must at least:

  • Implement the TaskChain interface.
  • Be registered as OSGi service. The easiest way to do so is to use the @Component annotation. Processing of this annotation needs to be enabled in Eclipse (on the projects properties: Plug-in Development > DS Annotations > Generate descriptors from annotated sources)
  • Have a method annotated with @TaskChainContextInit which accepts a TaskExecutionContext (and optionally more parameters available for injection - more on this later).
Each TaskChain can optionally have:
  • A method annotated with @TaskChainUiInit which may present UI to the user (and is called in the UI thread) in case the TaskChain is executed in the IDE. This method may accept a Shell parameter which represents the Shell to be used as parent for dialogs.
  • A top-level @TaskChainId annotation, which can be used to add a human readable description as well as aliases which can be used to access the TaskChain more easily from the command line application.
  • A top-level @TaskChainMenuEntry annotation, which can be used to make this TaskChain available from the TEA menu inside the IDE.

A simple example TaskChain which contains the above Task could look like this:

@TaskChainId(description = "My TaskChain", alias = "MyChainAlias")
@TaskChainMenuEntry(path = "Demos")
@Component
public class MyChain implements TaskChain {
	@TaskChainContextInit
	public void init(TaskExecutionContext c) {
		c.addTask(MyTask.class);
	}
}
					
Note that the Task is added using MyTask.class. Alternatively, if the Task would require additional constructor parameters, an instance of MyTask could be passed as well.

Testing in the IDE

Once you have these two classes in place, you can test your first TaskChain already. Simply run your prepared Eclipse launch configuration to run another IDE from your IDE. It now should contain a top-level menu entry TEA > Demos > My TaskChain. Clicking this menu item will run the TaskChain MyChain from your plug-in.

Testing Headless

This one is a little tricky at first. What you will need:

  • An (empty) property file called with an arbitrary name, lets call it headless.properties.
  • The name of the TaskChain you want to run. In this case it's either MyChainAlias or the fully qualified class name your.pkg.name.MyChain
Now you will need to create a new Eclipse launch configuration. You can copy this one from the Eclipse configuration you used before. Change the configuration and use org.eclipse.tea.core.ui.HeadlessTaskingEngine as product to run. Also change the Program arguments on the according tab. Add:
  • -properties /path/to/headless.properties
  • -taskchain MyChainAlias
Once you run this launch configuration, you should see TEA starting up and executing your TaskChain before exiting again.

Headless TEA product settings Headless TEA argument settings