|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jbbres.lib.actions.workflow.Workflow
public class Workflow
An Action(s) workflow: a sequence of discrete tasks called
Action
. The workflow hooks the actions together so that "in most
cases" the output of one action is the input of the subsequent action.
Workflow can also use Variable
objects to temporary store some data
and results.
Workflow are run calling the execute()
method. The execution is
performed in a separate thread.
It is possible to listen to events occurring in the workflow by using
instance of WorkflowListener
and WorkflowDefinitionListener
classes. WorkflowListener
instances listen to the execution part
of the workflow, for example when the workflow is started, paused, stopped
etc. WorkflowDefinitionListener
instances focus on the workflow
definition process by notifying the addition or removal of an
Action
or a Variable
.
v1.1.0:
sendNotification(WorkflowDefinitionNotification)
Constructor Summary | |
---|---|
Workflow()
Instantiates a new workflow. |
Method Summary | |
---|---|
int |
actionsCount()
Returns the number of actions in the workflow. |
boolean |
add(Action action)
Appends the specified action to the end of the workflow. |
boolean |
add(Action action,
boolean useRecommendations)
Deprecated. since 1.1.0 |
void |
add(Action action,
int index)
Inserts the specified action at the specified position in this workflow. |
void |
add(Action action,
int index,
boolean useRecommendations)
Deprecated. since 1.1.0 |
void |
add(java.lang.Class<? extends Action> actionClazz,
int position)
Creates an instance of the Action class and add it to the
workflow. |
void |
add(java.lang.Class<? extends Action> actionClazz,
int position,
boolean useRecommendations)
Deprecated. since 1.1.0 |
boolean |
add(java.lang.Class<? extends Element> elementClazz)
Creates an instance of the Element class and add it to the
workflow. |
boolean |
add(java.lang.Class<? extends Element> elementClazz,
boolean useRecommendations)
Deprecated. since 1.1.0 |
boolean |
add(Element element)
Adds an element (an Action or a Variable ) to
the workflow. |
boolean |
add(Element element,
boolean useRecommendations)
Deprecated. since 1.1.0 |
void |
add(int index,
Action action)
Inserts the given action at the specified position in this workflow. |
void |
add(int index,
Action action,
boolean useRecommendations)
Deprecated. since 1.1.0 |
boolean |
add(Variable variable)
Add an Variable to the workflow. |
void |
addWorkflowDefinitionListener(WorkflowDefinitionListener l)
Adds a definition listener to this workflow. |
void |
addWorkflowListener(WorkflowListener l)
Adds a listener to this workflow. |
void |
clearWorkflowDefinitionListeners()
Removes all the definition listeners to this workflow. |
void |
clearWorkflowListeners()
Removes all the listeners to this workflow. |
Workflow |
clone()
|
boolean |
contains(Element e)
Tests if the specified Element is a component in this
workflow. |
java.awt.Frame |
dialogOwner()
Returns the associated dialog owner. |
boolean |
equals(java.lang.Object obj)
|
void |
execute()
Executes the workflow: executes each action of the workflow one after the other. |
void |
fireActionMoved(Action action,
int previousPosition)
Calls the actionMoved() method of all the workflow
listeners. |
void |
fireActionRemoved(Action action,
int previousPosition)
Calls the elementRemoved() method of all the workflow
listeners. |
void |
fireElementAdded(Element element)
Calls the elementAdded() method of all the workflow
listeners. |
void |
fireElementRemoved(Element element)
Calls the elementRemoved() method of all the workflow
listeners. |
void |
fireWorkflowAskForInterruption()
Calls the workflowAskForInterruption() method of all the
workflow listeners. |
void |
fireWorkflowAskForSuspension()
Calls the workflowAskForSuspension() method of all the
workflow listeners. |
void |
fireWorkflowDefinitionNotification(WorkflowDefinitionNotification notification)
Calls the notificationReceived(WorkflowDefinitionEvent) method of all the workflow
definition listeners. |
void |
fireWorkflowEnd(int workflowStatus,
java.lang.Object workflowResult)
Calls the workflowEnd() method of all the workflow
listeners. |
void |
fireWorkflowResumed()
Calls the workflowResumed() method of all the workflow
listeners. |
void |
fireWorkflowStart()
Calls the workflowStart() method of all the workflow
listeners. |
void |
fireWorkflowSuspended()
Calls the workflowSuspended() method of all the workflow
listeners. |
Action |
getAction(int index)
Returns the action at the specified index. |
Action[] |
getActions()
Returns the actions composing the workflow. |
Action |
getNextAction()
Returns the next action to be executed by the workflow. |
Action |
getNextAction(Action ref)
Returns the action immediatly following ref in the workflow. |
Action |
getPreviousAction(Action ref)
Returns the action immediatly preceding ref in the workflow. |
Variable |
getVariable(int index)
Returns the variable at the specified index. |
Variable[] |
getVariables()
Returns the variables associated to the workflow. |
WorkflowDefinitionListener[] |
getWorkflowDefinitionListeners()
Returns the definition listeners to this workflow. |
WorkflowListener[] |
getWorkflowListeners()
Returns the listeners to this workflow. |
int |
indexOfAction(Action action)
Searches for the first occurence of the given action within the workflow. |
void |
interrupt()
Interrupts (ends) the workflow. |
boolean |
isRunning()
Returns true if the workflow is currently running. |
boolean |
moveAction(Action action,
int toPosition)
Moves the given action to the toPosition position. |
void |
moveAction(int fromPosition,
int toPosition)
Moves the action at the fromPosition position to the
toPosition position in the workflow. |
void |
pause()
Pauses the workflow if it is running. |
int |
positionOf(Action action)
Returns the action position in the workflow. |
boolean |
remove(Element element)
Removes an element (an Action or an Variable )
from the workflow. |
Action |
remove(int index)
Removes the action at the specified position in this Vector. |
boolean |
remove(Variable variable)
Removes a Variable from the workflow. |
void |
removeWorkflowDefinitionListener(WorkflowDefinitionListener l)
Removes a definition listener to this workflow. |
void |
removeWorkflowListener(WorkflowListener l)
Removes a listener to this workflow. |
void |
resume()
Wakes up the workflow if it has been put on hold by invoking the pause() method. |
void |
run()
For internal purpose only. |
void |
sendNotification(WorkflowDefinitionNotification notification)
Send the notification to all the WorkflowDefinitionListeners . |
void |
setDialogOwner(java.awt.Frame frame)
Sets the dialog owner. |
void |
setNextAction(Action nextAction)
Sets the next action to be executed by the workflow. |
void |
step()
Asks the workflow to process only the next step and then pause. |
int |
variablesCount()
Returns the number of variables in the workflow. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Workflow()
Method Detail |
---|
public Variable[] getVariables()
getVariable(int)
,
variablesCount()
public Variable getVariable(int index)
Variable order is not important within the workflow. This method is provided for conveniance only.
index
- - the inde
java.lang.ArrayIndexOutOfBoundsException
- if the index is negative or not less than the current number
of variables in the workflow.getVariables()
,
variablesCount()
public int variablesCount()
getVariables()
,
getVariable(int)
public Action getPreviousAction(Action ref)
ref
in the workflow.
ref
- - the action used as a reference.
ref
in the workflow.getNextAction(Action)
,
getActions()
public Action getNextAction(Action ref)
ref
in the workflow.
ref
- - the action used as a reference.
ref
in the workflow.getPreviousAction(Action)
,
getActions()
public Action[] getActions()
getAction(int)
,
actionsCount()
public Action getAction(int index)
index
- - the index
java.lang.ArrayIndexOutOfBoundsException
- if the index is negative or not less than the current number
of actions in the workflow.getActions()
,
actionsCount()
public int indexOfAction(Action action)
action
- - an action
public int actionsCount()
getActions()
,
getAction(int)
public boolean add(java.lang.Class<? extends Element> elementClazz) throws java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
Element
class and add it to the
workflow.
elementClazz
- - Element
class
java.lang.IllegalArgumentException
- cannot create an instance of the given class.
java.lang.SecurityException
- if a security exception occurs.
java.lang.InstantiationException
- cannot create an instance of the given class.
java.lang.IllegalAccessException
- cannot create an instance of the given class.
java.lang.reflect.InvocationTargetException
- cannot create an instance of the given class.
java.lang.NoSuchMethodException
- cannot create an instance of the given class.remove(Element)
,
add(Element)
,
add(Action)
,
add(Variable)
public boolean add(Element element)
Action
or a Variable
) to
the workflow.
element
- - element to be added
remove(Element)
,
add(Action)
,
add(Variable)
public boolean add(Variable variable)
Variable
to the workflow.
variable
- - variable to be added
remove(Variable)
,
add(Element)
public void add(java.lang.Class<? extends Action> actionClazz, int position) throws java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
Action
class and add it to the
workflow.
actionClazz
- - Action
classposition
- - the position in the workflow
java.lang.IllegalArgumentException
- cannot create an instance of the given class.
java.lang.SecurityException
- if a security exception occurs.
java.lang.InstantiationException
- cannot create an instance of the given class.
java.lang.IllegalAccessException
- cannot create an instance of the given class.
java.lang.reflect.InvocationTargetException
- cannot create an instance of the given class.
java.lang.NoSuchMethodException
- cannot create an instance of the given class.remove(Element)
,
add(Element, boolean)
,
add(Action, int, boolean)
public boolean add(Action action)
action
- the action
remove(Element)
,
add(Action, int)
,
add(Element)
public void add(int index, Action action)
index
- - the indexaction
- - the actionremove(int)
,
add(Action, int)
public void add(Action action, int index)
add(int, Action)
.
action
- - action to be addedindex
- - positionremove(int)
,
add(int, Action)
public void sendNotification(WorkflowDefinitionNotification notification)
WorkflowDefinitionListeners
.
Notifications can be used to provide information to the user while he/she is creating a workflow. Notifications are displayed at the top of the workflow panel.
notification
- the notificationpublic boolean remove(Element element)
Action
or an Variable
)
from the workflow.
element
- - element to be removed
add(Element)
,
remove(int)
,
remove(Variable)
public boolean remove(Variable variable)
Variable
from the workflow.
variable
- - variable to be removed
add(Variable)
,
remove(Element)
public Action remove(int index)
index
- - the index
remove(Element)
,
add(Action, int)
public void moveAction(int fromPosition, int toPosition)
fromPosition
position to the
toPosition
position in the workflow.
fromPosition
- - initial positiontoPosition
- - destinationmoveAction(Action, int)
public boolean moveAction(Action action, int toPosition)
toPosition
position.
action
- - action to be movedtoPosition
- - destination
true
if the function succeed, false
otherwise.moveAction(int, int)
public boolean contains(Element e)
Element
is a component in this
workflow.
e
- - an Element
.
Element
is the
same as a component in this workflow; false otherwise.add(Element)
public int positionOf(Action action)
action
- - action
public void execute()
The execution takes place in a separate Thread
.
pause()
,
resume()
,
interrupt()
,
step()
public boolean isRunning()
true
if the workflow is currently running.
false
otherwise.
true
if the workflow is currently running.
false
otherwise.execute()
public void pause()
The workflow is stopped until the resume()
method is called.
Do not call this method within the
ActionService.execute(Object, Parameters)
method except if you call
it from a another thread than the default one, as it might result for the
workflow to be blocked indefinitely.
execute()
,
resume()
,
interrupt()
public void resume()
pause()
method.
pause()
,
execute()
,
interrupt()
public void step()
pause()
,
resume()
,
interrupt()
,
execute()
public void interrupt()
execute()
,
pause()
,
resume()
public void setNextAction(Action nextAction)
nextAction
must be either one of the actions of the workflow,
either null
. If not, the method will fail and the next action
will not be changed.
Passing null
to this method will stop the workflow once the
current action is processed.
nextAction
- the new next action to be executed by the workflow.public Action getNextAction()
null
.
public final void run()
execute()
method instead.
When an object implementing interface Runnable
is used to
create a thread, starting the thread causes the object's run
method to be called in that separately executing thread. The general
contract of the method run is that it may take any action whatsoever.
run
in interface java.lang.Runnable
execute()
public Workflow clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.awt.Frame dialogOwner()
If an action required to display a JDialog
or a
JFrame
, it can use the result of this function as owner:
JDialog dialog = new JDialog(action.getWorkflow().dialogOwner());
public final void setDialogOwner(java.awt.Frame frame)
frame
- the framepublic void addWorkflowListener(WorkflowListener l)
l
- - new listenerpublic void removeWorkflowListener(WorkflowListener l)
l
- - the listener to be removedpublic WorkflowListener[] getWorkflowListeners()
public void clearWorkflowListeners()
public void fireWorkflowStart()
workflowStart()
method of all the workflow
listeners.
public void fireWorkflowSuspended()
workflowSuspended()
method of all the workflow
listeners.
public void fireWorkflowResumed()
workflowResumed()
method of all the workflow
listeners.
public void fireWorkflowEnd(int workflowStatus, java.lang.Object workflowResult)
workflowEnd()
method of all the workflow
listeners.
workflowStatus
- the workflow statusworkflowResult
- the workflow resultpublic void fireWorkflowAskForSuspension()
workflowAskForSuspension()
method of all the
workflow listeners.
public void fireWorkflowAskForInterruption()
workflowAskForInterruption()
method of all the
workflow listeners.
public void addWorkflowDefinitionListener(WorkflowDefinitionListener l)
l
- - new listenerpublic void removeWorkflowDefinitionListener(WorkflowDefinitionListener l)
l
- - the listener to be removedpublic WorkflowDefinitionListener[] getWorkflowDefinitionListeners()
public void clearWorkflowDefinitionListeners()
public void fireElementAdded(Element element)
elementAdded()
method of all the workflow
listeners.
element
- - added elementpublic void fireActionRemoved(Action action, int previousPosition)
elementRemoved()
method of all the workflow
listeners.
action
- - removed actionpreviousPosition
- the previous positionpublic void fireElementRemoved(Element element)
elementRemoved()
method of all the workflow
listeners.
element
- - removed elementpublic void fireActionMoved(Action action, int previousPosition)
actionMoved()
method of all the workflow
listeners.
action
- - added actionpreviousPosition
- the previous positionpublic void fireWorkflowDefinitionNotification(WorkflowDefinitionNotification notification)
notificationReceived(WorkflowDefinitionEvent)
method of all the workflow
definition listeners.
notification
- the notification@Deprecated public void add(int index, Action action, boolean useRecommendations)
index
- - the indexaction
- - the actionuseRecommendations
- - defines if the warning messages associated to the element
(if any) should be displayed.remove(int)
,
add(Action, int)
@Deprecated public void add(Action action, int index, boolean useRecommendations)
add(int, Action)
.
action
- - action to be addedindex
- - positionuseRecommendations
- - defines if the warning messages associated to the element
(if any) should be displayed.remove(int)
,
add(int, Action)
@Deprecated public void add(java.lang.Class<? extends Action> actionClazz, int position, boolean useRecommendations) throws java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
Action
class and add it to the
workflow.
actionClazz
- - Action
classposition
- - the position in the workflowuseRecommendations
- - defines if the warning messages associated to the element
(if any) should be displayed.
java.lang.IllegalArgumentException
- cannot create an instance of the given class.
java.lang.SecurityException
- if a security exception occurs.
java.lang.InstantiationException
- cannot create an instance of the given class.
java.lang.IllegalAccessException
- cannot create an instance of the given class.
java.lang.reflect.InvocationTargetException
- cannot create an instance of the given class.
java.lang.NoSuchMethodException
- cannot create an instance of the given class.remove(Element)
,
add(Element, boolean)
,
add(Action, int, boolean)
@Deprecated public boolean add(Element element, boolean useRecommendations)
Action
or a Variable
) to
the workflow.
element
- - element to be addeduseRecommendations
- - defines if the warning messages associated to the element
(if any) should be displayed.
remove(Element)
,
add(Action, boolean)
,
add(Variable)
@Deprecated public boolean add(java.lang.Class<? extends Element> elementClazz, boolean useRecommendations) throws java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
Element
class and add it to the
workflow.
elementClazz
- - Element
classuseRecommendations
- - defines if the warning messages associated to the element
(if any) should be displayed.
java.lang.IllegalArgumentException
- cannot create an instance of the given class.
java.lang.SecurityException
- if a security exception occurs.
java.lang.InstantiationException
- cannot create an instance of the given class.
java.lang.IllegalAccessException
- cannot create an instance of the given class.
java.lang.reflect.InvocationTargetException
- cannot create an instance of the given class.
java.lang.NoSuchMethodException
- cannot create an instance of the given class.remove(Element)
,
add(Element, boolean)
,
add(Action)
,
add(Variable)
@Deprecated public boolean add(Action action, boolean useRecommendations)
action
- the actionuseRecommendations
- - defines if the warning messages associated to the element
(if any) should be displayed.
remove(Element)
,
add(Action, int, boolean)
,
add(Element)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |