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.voidaddTag(java.lang.String tag)protected voidchildrenChanged()voidclearTags()protected voidcopyBasicParametersTo(AbstractAction<T> copy)java.lang.StringgetAttribute(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 TgetData()Returns whatever data this action generates.java.lang.StringgetName()Returns the name of the action.Action.StatusgetStatus()Returns the current status of this action.java.util.List<Listener<Action<T>>>getStatusListeners()java.util.List<java.lang.String>getTags()booleanhasAttribute(java.lang.String key)Returns whether this action has an attribute with the given name.booleanisCritical()Returns whether this action is critical - critical actions require the entire action queue to abort if they fail.abstract booleanisRunning()Returns whether the action is currently running or not.protected voidonFinish()protected voidonStart()voidremoveAttribute(java.lang.String key)Removes the attribute with the given name from this action - if it exists.voidremoveListener(Listener<Action<T>> listener)Removes the specified listener for the action - if it has it.voidremoveTag(java.lang.String tag)abstract voidreset()Resets the action to the state it was in before being run.voidsetAttribute(java.lang.String key, java.lang.String value)Sets the value of the specified attribute for this action.voidsetCritical(boolean critical)Sets whether this action is critical - critical actions require the entire action queue to abort if they fail.voidsetName(java.lang.String name)Changes the name of the action.voidsetOnEdit(Listener<Action<T>> onEdit)voidsetOnFinish(Listener<Action<T>> onFinish)voidsetOnStart(Listener<Action<T>> onStart)voidsetStatus(Action.Status status)Sets the current status of this action.abstract voidskip()Marks the action to be skipped next time it is run, or immediately if it is currently running.abstract voidstart()Runs the action.abstract voidstop()Interrupts and stops the action.voiduserEdit()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:ActionReturns the name of the action.
-
setName
public void setName(java.lang.String name)
Description copied from interface:ActionChanges the name of the action.
-
addNameListener
public Listener<Action<T>> addNameListener(Listener<Action<T>> listener)
Description copied from interface:ActionAdds a listener to this action that is triggered any time its name is changed.- Specified by:
addNameListenerin 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:ActionReturns the value of the specified attribute for this action. Returns null if it doesn't exist.- Specified by:
getAttributein 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:ActionSets the value of the specified attribute for this action.- Specified by:
setAttributein interfaceAction<T>- Parameters:
key- Attribute keyvalue- Attribute value
-
hasAttribute
public boolean hasAttribute(java.lang.String key)
Description copied from interface:ActionReturns whether this action has an attribute with the given name.- Specified by:
hasAttributein interfaceAction<T>- Parameters:
key- Attribute key to check- Returns:
- Does it exist?
-
removeAttribute
public void removeAttribute(java.lang.String key)
Description copied from interface:ActionRemoves the attribute with the given name from this action - if it exists.- Specified by:
removeAttributein 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:ActionReturns an unmodifiable mapping of all attributes.- Specified by:
getAttributesin interfaceAction<T>- Returns:
- Attribtues
-
addAttributeListener
public Listener<Action<T>> addAttributeListener(Listener<Action<T>> listener)
Description copied from interface:ActionAdds a listener that is triggered any time the attributes of the action are updated.- Specified by:
addAttributeListenerin 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:ActionResets the action to the state it was in before being run.
-
setOnStart
public void setOnStart(Listener<Action<T>> onStart)
- Specified by:
setOnStartin interfaceAction<T>
-
setOnFinish
public void setOnFinish(Listener<Action<T>> onFinish)
- Specified by:
setOnFinishin interfaceAction<T>
-
onStart
protected void onStart()
-
onFinish
protected void onFinish()
-
start
public abstract void start()
Description copied from interface:ActionRuns the action. Should only return once the action is complete/interrupted/failed.
-
stop
public abstract void stop()
Description copied from interface:ActionInterrupts and stops the action.
-
skip
public abstract void skip()
Description copied from interface:ActionMarks 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:ActionReturns the current status of this action.
-
setStatus
public void setStatus(Action.Status status)
Description copied from interface:ActionSets the current status of this action.
-
addStatusListener
public Listener<Action<T>> addStatusListener(Listener<Action<T>> listener)
Description copied from interface:ActionAdds a listener that is triggered any time the status of the action is changed.- Specified by:
addStatusListenerin interfaceAction<T>- Parameters:
listener- Listener to add- Returns:
- The added listener
-
removeListener
public void removeListener(Listener<Action<T>> listener)
Description copied from interface:ActionRemoves the specified listener for the action - if it has it.- Specified by:
removeListenerin interfaceAction<T>- Parameters:
listener- The listener to remove
-
getStatusListeners
public java.util.List<Listener<Action<T>>> getStatusListeners()
- Specified by:
getStatusListenersin interfaceAction<T>
-
isRunning
public abstract boolean isRunning()
Description copied from interface:ActionReturns whether the action is currently running or not.
-
isCritical
public boolean isCritical()
Description copied from interface:ActionReturns whether this action is critical - critical actions require the entire action queue to abort if they fail.- Specified by:
isCriticalin interfaceAction<T>- Returns:
- Is it critical?
-
setCritical
public void setCritical(boolean critical)
Description copied from interface:ActionSets whether this action is critical - critical actions require the entire action queue to abort if they fail.- Specified by:
setCriticalin interfaceAction<T>- Parameters:
critical- Should it be critical
-
getData
public abstract T getData()
Description copied from interface:ActionReturns whatever data this action generates.
-
getChildren
public abstract java.util.List<Action> getChildren()
Description copied from interface:ActionReturns 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:
getChildrenin interfaceAction<T>- Returns:
- List of sub-actions
-
addChildrenListener
public Listener<Action<T>> addChildrenListener(Listener<Action<T>> listener)
Description copied from interface:ActionAdds a listener that is triggered any time child actions are added/removed.- Specified by:
addChildrenListenerin interfaceAction<T>- Parameters:
listener- Listener to add- Returns:
- The added listener
-
userEdit
public void userEdit()
Description copied from interface:ActionPerforms whatever routine is necessary to allow the user to edit this action.
-
childrenChanged
protected void childrenChanged()
-
copyBasicParametersTo
protected void copyBasicParametersTo(AbstractAction<T> copy)
-
-