Understanding Actions

Actions are needed to execute specific operations and can be associated with Selena elements as well as with any SWT/JFace objects.

Depending on whether an operation is executed on one element (object) or several elements/objects, we differentiate between single actions and multi-element actions.

If you have to write your own actions as a plug-in developer, you will generally have to implement one or even several single actions, while the number of multi-element actions you require will be very small.

 

Single Action

 

A single action executes an operation on an element or object.

To write a single action you need an action class that implements the interface IElementSingleAction (for Selena elements) or ISingleAction (for SWT/JFace objects).

 

Multi-Element Action

 

A multi-element action executes an operation on a set of elements or objects.

An example of this is the operation SWAP(a, b, ...), which can only be used with a minimum of two elements or objects.

To write a multi-element action you need an action class that implements the interface IElementMultiAction (for Selena elements) or IMultiAction (for objects).

 

 

 

Relevant Action Classes/Interfaces

 

Package com.tssap.util.action

 

IAction

 

Basis interface for different action types.

IAction is not intended for direct implementation.

 

Method:

public ICategory getCategory()

Returns the category that this action belongs to. The getCategory() method must be implemented by an action class.

ISingleAction

 

This interface defines single actions that are associated with any objects (SWT/JFace).

ISingleAction extends the basis interface IAction and also defines the following three methods:

 

boolean isEnabled(Object object)

Specifies whether an operation can currently be executed on an object. The return value can change throughout the runtime of the VM. Therefore, the implementation of this method could contain queries for conditions under which any access to an operation could change.

The return value is true if the operation can currently be executed on the object.

The return value is false if the operation cannot currently be executed on the object.

 

boolean isAvailable(Object object)

Checks whether an operation can be executed on an object at all.

The return value of this method remains constant for this object throughout the runtime of the VM.

The return value is true if the action is available to this object.

The return value is false if the action is not available to this object at all.

 

void run(Object object)

Executes the operation on the object.

 

IMultiAction

 

This interface defines multi-element actions that are associated with any objects (SWT/JFace).

IMultiAction extends the basis interface IAction and also defines the following three methods:

 

boolean isEnabled(Object[] objects)

Specifies whether an operation can currently be executed on a set of objects. The return value can change throughout the runtime of the VM. Therefore, the implementation of this method could contain queries for conditions under which any access to an operation could change.

The return value is true if the operation can currently be executed on the set of objects.

The return value is false if the operation cannot currently be executed on the set of objects.

 

boolean isAvailable(Object[] objects)

Checks whether an operation can be executed on a set of objects at all.

The return value of this method remains constant for all elements throughout the runtime of the VM.

The return value is true if the action can be executed on all objects.

The return value is false if the action cannot be executed on all objects.

 

void run(Object[] objects)

Executes the operation on the set of objects.

 

 

 

 

Package com.tssap.selena.model.extension.action

 

IElementSingleAction

 

This interface is used to define single actions for Selena elements.

IElementSingleAction extends IAction and also defines the following three methods:

 

boolean isEnabled(Element element)

Specifies whether an operation can currently be executed on an element. The return value can change throughout the runtime of the VM. Therefore, the implementation of this method could contain queries for conditions under which any access to an operation could change.

The return value is true if the operation can currently be executed on the element.

The return value is false if the operation cannot currently be executed on the element.

 

boolean isAvailable(Element element)

Checks whether an operation can be executed on an element at all.

The return value of this method remains constant throughout the runtime of the VM for this element.

The return value is true if the action is available to this element.

The return value is false if the action is not available to this element at all.

 

void run(Element element)

Executes the operation on the element.

 

IElementMultiAction

 

This interface is used to define multi-element actions for Selena elements. A multi-element action executes an operation on a set of elements.

This interface extends IAction and also defines the following three methods:

 

boolean isEnabled(Element[] elements)

 

Specifies whether an operation can currently be executed on a set of elements. The return value can change throughout the runtime of the VM. Therefore, the implementation of this method could contain queries for conditions under which any access to an operation could change.

The return value is true if the operation can currently be executed on the set of elements.

The return value is false if the operation cannot currently be executed on the set of elements.

 

boolean isAvailable(Element[] elements)

Checks whether an operation can be executed on the set of elements at all.

The return value of this method remains constant for all elements throughout the runtime of the VM.

The return value is true if the action can be executed on all elements.

The return value is false if the action cannot be executed on all elements.

 

void run(Element[] elements)

Executes the operation on the set of elements.

 

 

Relationship Between Classes/Interfaces

All four action types are derived from the basis interface IAction.