This page gives a simple getting started example that provides a quick tour through the basics of writing TEA Tasks and TaskChains.
To implement TEA components, you will need a workspace with a project that will host these components. Most importantly:
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.
Now that there is a Task, we want to execute it somehow. TEA uses TaskChains to accomplish this.
Each TaskChain must at least:
TaskChain
interface.@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)@TaskChainContextInit
which accepts a TaskExecutionContext
(and optionally more parameters available for injection - more on this later).@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.@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.@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.
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.
This one is a little tricky at first. What you will need:
MyChainAlias
or the fully qualified class name
your.pkg.name.MyChain
org.eclipse.tea.core.ui.HeadlessTaskingEngine
as product to run.
Also change the Program arguments on the according tab. Add: