Package jisa.experiment.queue
Interface Action<T>
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
AbstractAction
,MeasurementAction
,MeasurementSubAction
,SimpleAction
,SweepAction
public interface Action<T> extends java.io.Serializable
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Action.Status
-
Method Summary
All Methods Instance Methods Abstract Methods Default 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.default Listener<Action<T>>
addListener(Listener<Action<T>> listener)
Adds a listener that is triggered any time the name, status or attributes of the action are changed.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)
void
clearTags()
Action<T>
copy()
Creates a deep copy of this action.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.default java.lang.String
getAttributeString()
default java.lang.String
getAttributeString(java.lang.String delimiter, java.lang.String assignment)
java.util.List<Action>
getChildren()
Returns an unmodifiable list of sub-actions that this action contains.T
getData()
Returns whatever data this action generates.ActionDisplay<Action<T>>
getDisplay()
Returns the JavaFX node used to display this action in an ActionQueueDisplay object.java.lang.Exception
getError()
Returns the exception that caused the the action to result in failure.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.boolean
isRunning()
Returns whether the action is currently running or not.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)
void
reset()
Resets the action to the state it was in before being run.default void
resume()
Resumes the action from where it was last interruptedvoid
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
setOnFinish(Listener<Action<T>> onFinish)
void
setOnStart(Listener<Action<T>> onStart)
void
setStatus(Action.Status status)
Sets the current status of this action.void
skip()
Marks the action to be skipped next time it is run, or immediately if it is currently running.void
start()
Runs the action.void
stop()
Interrupts and stops the action.void
userEdit()
Performs whatever routine is necessary to allow the user to edit this action.
-
-
-
Method Detail
-
getName
java.lang.String getName()
Returns the name of the action.- Returns:
- Name of the action
-
setName
void setName(java.lang.String name)
Changes the name of the action.- Parameters:
name
- The new name
-
addNameListener
Listener<Action<T>> addNameListener(Listener<Action<T>> listener)
Adds a listener to this action that is triggered any time its name is changed.- Parameters:
listener
- Listener to add- Returns:
- The added listener
-
getAttribute
java.lang.String getAttribute(java.lang.String key)
Returns the value of the specified attribute for this action. Returns null if it doesn't exist.- Parameters:
key
- Attribute key- Returns:
- Attribute value
-
setAttribute
void setAttribute(java.lang.String key, java.lang.String value)
Sets the value of the specified attribute for this action.- Parameters:
key
- Attribute keyvalue
- Attribute value
-
hasAttribute
boolean hasAttribute(java.lang.String key)
Returns whether this action has an attribute with the given name.- Parameters:
key
- Attribute key to check- Returns:
- Does it exist?
-
removeAttribute
void removeAttribute(java.lang.String key)
Removes the attribute with the given name from this action - if it exists.- Parameters:
key
- Key of attribute to remove
-
getAttributes
java.util.Map<java.lang.String,java.lang.String> getAttributes()
Returns an unmodifiable mapping of all attributes.- Returns:
- Attribtues
-
getAttributeString
default java.lang.String getAttributeString(java.lang.String delimiter, java.lang.String assignment)
-
getAttributeString
default java.lang.String getAttributeString()
-
addAttributeListener
Listener<Action<T>> addAttributeListener(Listener<Action<T>> listener)
Adds a listener that is triggered any time the attributes of the action are updated.- Parameters:
listener
- Listener to add- Returns:
- The added listener
-
addTag
void addTag(java.lang.String tag)
-
removeTag
void removeTag(java.lang.String tag)
-
clearTags
void clearTags()
-
getTags
java.util.List<java.lang.String> getTags()
-
reset
void reset()
Resets the action to the state it was in before being run.
-
start
void start()
Runs the action. Should only return once the action is complete/interrupted/failed.
-
resume
default void resume()
Resumes the action from where it was last interrupted
-
stop
void stop()
Interrupts and stops the action.
-
skip
void skip()
Marks the action to be skipped next time it is run, or immediately if it is currently running.
-
getStatus
Action.Status getStatus()
Returns the current status of this action.- Returns:
- Status of action
-
getError
java.lang.Exception getError()
Returns the exception that caused the the action to result in failure.- Returns:
- Exception
-
setStatus
void setStatus(Action.Status status)
Sets the current status of this action.- Parameters:
status
- The status to set
-
addStatusListener
Listener<Action<T>> addStatusListener(Listener<Action<T>> listener)
Adds a listener that is triggered any time the status of the action is changed.- Parameters:
listener
- Listener to add- Returns:
- The added listener
-
addListener
default Listener<Action<T>> addListener(Listener<Action<T>> listener)
Adds a listener that is triggered any time the name, status or attributes of the action are changed.- Parameters:
listener
- Listener to add- Returns:
- The added listener
-
removeListener
void removeListener(Listener<Action<T>> listener)
Removes the specified listener for the action - if it has it.- Parameters:
listener
- The listener to remove
-
isRunning
boolean isRunning()
Returns whether the action is currently running or not.- Returns:
- Is it running?
-
isCritical
boolean isCritical()
Returns whether this action is critical - critical actions require the entire action queue to abort if they fail.- Returns:
- Is it critical?
-
setCritical
void setCritical(boolean critical)
Sets whether this action is critical - critical actions require the entire action queue to abort if they fail.- Parameters:
critical
- Should it be critical
-
getData
T getData()
Returns whatever data this action generates.- Returns:
- Generated data
-
getChildren
java.util.List<Action> getChildren()
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.- Returns:
- List of sub-actions
-
addChildrenListener
Listener<Action<T>> addChildrenListener(Listener<Action<T>> listener)
Adds a listener that is triggered any time child actions are added/removed.- Parameters:
listener
- Listener to add- Returns:
- The added listener
-
userEdit
void userEdit()
Performs whatever routine is necessary to allow the user to edit this action.
-
getDisplay
ActionDisplay<Action<T>> getDisplay()
Returns the JavaFX node used to display this action in an ActionQueueDisplay object.- Returns:
- Node
-
-