Package jisa.experiment.queue
Class AbstractAction<T>
- java.lang.Object
-
- jisa.experiment.queue.AbstractAction<T>
-
- All Implemented Interfaces:
java.io.Serializable
,Action<T>
- Direct Known Subclasses:
MeasurementAction
,SimpleAction
,SweepAction
public abstract class AbstractAction<T> extends java.lang.Object implements Action<T>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jisa.experiment.queue.Action
Action.Status
-
-
Constructor Summary
Constructors Constructor Description AbstractAction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Listener<Action<T>>
addAttributeListener(Listener<Action<T>> listener)
Adds a listener that is triggered any time the attributes of the action are updated.Listener<Action<T>>
addChildrenListener(Listener<Action<T>> listener)
Adds a listener that is triggered any time child actions are added/removed.Listener<Action<T>>
addNameListener(Listener<Action<T>> listener)
Adds a listener to this action that is triggered any time its name is changed.Listener<Action<T>>
addStatusListener(Listener<Action<T>> listener)
Adds a listener that is triggered any time the status of the action is changed.void
addTag(java.lang.String tag)
protected void
childrenChanged()
void
clearTags()
protected void
copyBasicParametersTo(AbstractAction<T> copy)
java.lang.String
getAttribute(java.lang.String key)
Returns the value of the specified attribute for this action.java.util.Map<java.lang.String,java.lang.String>
getAttributes()
Returns an unmodifiable mapping of all attributes.abstract java.util.List<Action>
getChildren()
Returns an unmodifiable list of sub-actions that this action contains.abstract T
getData()
Returns whatever data this action generates.java.lang.String
getName()
Returns the name of the action.Action.Status
getStatus()
Returns the current status of this action.java.util.List<Listener<Action<T>>>
getStatusListeners()
java.util.List<java.lang.String>
getTags()
boolean
hasAttribute(java.lang.String key)
Returns whether this action has an attribute with the given name.boolean
isCritical()
Returns whether this action is critical - critical actions require the entire action queue to abort if they fail.abstract boolean
isRunning()
Returns whether the action is currently running or not.protected void
onFinish()
protected void
onStart()
void
removeAttribute(java.lang.String key)
Removes the attribute with the given name from this action - if it exists.void
removeListener(Listener<Action<T>> listener)
Removes the specified listener for the action - if it has it.void
removeTag(java.lang.String tag)
abstract void
reset()
Resets the action to the state it was in before being run.void
setAttribute(java.lang.String key, java.lang.String value)
Sets the value of the specified attribute for this action.void
setCritical(boolean critical)
Sets whether this action is critical - critical actions require the entire action queue to abort if they fail.void
setName(java.lang.String name)
Changes the name of the action.void
setOnEdit(Listener<Action<T>> onEdit)
void
setOnFinish(Listener<Action<T>> onFinish)
void
setOnStart(Listener<Action<T>> onStart)
void
setStatus(Action.Status status)
Sets the current status of this action.abstract void
skip()
Marks the action to be skipped next time it is run, or immediately if it is currently running.abstract void
start()
Runs the action.abstract void
stop()
Interrupts and stops the action.void
userEdit()
Performs whatever routine is necessary to allow the user to edit this action.-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jisa.experiment.queue.Action
addListener, copy, getAttributeString, getAttributeString, getDisplay, getError, resume
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:Action
Returns the name of the action.
-
setName
public void setName(java.lang.String name)
Description copied from interface:Action
Changes the name of the action.
-
addNameListener
public Listener<Action<T>> addNameListener(Listener<Action<T>> listener)
Description copied from interface:Action
Adds a listener to this action that is triggered any time its name is changed.- Specified by:
addNameListener
in interfaceAction<T>
- Parameters:
listener
- Listener to add- Returns:
- The added listener
-
getAttribute
public java.lang.String getAttribute(java.lang.String key)
Description copied from interface:Action
Returns the value of the specified attribute for this action. Returns null if it doesn't exist.- Specified by:
getAttribute
in interfaceAction<T>
- Parameters:
key
- Attribute key- Returns:
- Attribute value
-
setAttribute
public void setAttribute(java.lang.String key, java.lang.String value)
Description copied from interface:Action
Sets the value of the specified attribute for this action.- Specified by:
setAttribute
in interfaceAction<T>
- Parameters:
key
- Attribute keyvalue
- Attribute value
-
hasAttribute
public boolean hasAttribute(java.lang.String key)
Description copied from interface:Action
Returns whether this action has an attribute with the given name.- Specified by:
hasAttribute
in interfaceAction<T>
- Parameters:
key
- Attribute key to check- Returns:
- Does it exist?
-
removeAttribute
public void removeAttribute(java.lang.String key)
Description copied from interface:Action
Removes the attribute with the given name from this action - if it exists.- Specified by:
removeAttribute
in interfaceAction<T>
- Parameters:
key
- Key of attribute to remove
-
getAttributes
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
Description copied from interface:Action
Returns an unmodifiable mapping of all attributes.- Specified by:
getAttributes
in interfaceAction<T>
- Returns:
- Attribtues
-
addAttributeListener
public Listener<Action<T>> addAttributeListener(Listener<Action<T>> listener)
Description copied from interface:Action
Adds a listener that is triggered any time the attributes of the action are updated.- Specified by:
addAttributeListener
in interfaceAction<T>
- Parameters:
listener
- Listener to add- Returns:
- The added listener
-
removeTag
public void removeTag(java.lang.String tag)
-
getTags
public java.util.List<java.lang.String> getTags()
-
reset
public abstract void reset()
Description copied from interface:Action
Resets the action to the state it was in before being run.
-
setOnStart
public void setOnStart(Listener<Action<T>> onStart)
- Specified by:
setOnStart
in interfaceAction<T>
-
setOnFinish
public void setOnFinish(Listener<Action<T>> onFinish)
- Specified by:
setOnFinish
in interfaceAction<T>
-
onStart
protected void onStart()
-
onFinish
protected void onFinish()
-
start
public abstract void start()
Description copied from interface:Action
Runs the action. Should only return once the action is complete/interrupted/failed.
-
stop
public abstract void stop()
Description copied from interface:Action
Interrupts and stops the action.
-
skip
public abstract void skip()
Description copied from interface:Action
Marks the action to be skipped next time it is run, or immediately if it is currently running.
-
getStatus
public Action.Status getStatus()
Description copied from interface:Action
Returns the current status of this action.
-
setStatus
public void setStatus(Action.Status status)
Description copied from interface:Action
Sets the current status of this action.
-
addStatusListener
public Listener<Action<T>> addStatusListener(Listener<Action<T>> listener)
Description copied from interface:Action
Adds a listener that is triggered any time the status of the action is changed.- Specified by:
addStatusListener
in interfaceAction<T>
- Parameters:
listener
- Listener to add- Returns:
- The added listener
-
removeListener
public void removeListener(Listener<Action<T>> listener)
Description copied from interface:Action
Removes the specified listener for the action - if it has it.- Specified by:
removeListener
in interfaceAction<T>
- Parameters:
listener
- The listener to remove
-
getStatusListeners
public java.util.List<Listener<Action<T>>> getStatusListeners()
- Specified by:
getStatusListeners
in interfaceAction<T>
-
isRunning
public abstract boolean isRunning()
Description copied from interface:Action
Returns whether the action is currently running or not.
-
isCritical
public boolean isCritical()
Description copied from interface:Action
Returns whether this action is critical - critical actions require the entire action queue to abort if they fail.- Specified by:
isCritical
in interfaceAction<T>
- Returns:
- Is it critical?
-
setCritical
public void setCritical(boolean critical)
Description copied from interface:Action
Sets whether this action is critical - critical actions require the entire action queue to abort if they fail.- Specified by:
setCritical
in interfaceAction<T>
- Parameters:
critical
- Should it be critical
-
getData
public abstract T getData()
Description copied from interface:Action
Returns whatever data this action generates.
-
getChildren
public abstract java.util.List<Action> getChildren()
Description copied from interface:Action
Returns an unmodifiable list of sub-actions that this action contains. The exact meaning of a sub-action and how it relates to the running of this action depends on the type of action this is.- Specified by:
getChildren
in interfaceAction<T>
- Returns:
- List of sub-actions
-
addChildrenListener
public Listener<Action<T>> addChildrenListener(Listener<Action<T>> listener)
Description copied from interface:Action
Adds a listener that is triggered any time child actions are added/removed.- Specified by:
addChildrenListener
in interfaceAction<T>
- Parameters:
listener
- Listener to add- Returns:
- The added listener
-
userEdit
public void userEdit()
Description copied from interface:Action
Performs whatever routine is necessary to allow the user to edit this action.
-
childrenChanged
protected void childrenChanged()
-
copyBasicParametersTo
protected void copyBasicParametersTo(AbstractAction<T> copy)
-
-