net.refractions.udig.catalog.ui.workflow
Class Workflow.State

java.lang.Object
  extended by net.refractions.udig.catalog.ui.workflow.Workflow.State
Direct Known Subclasses:
ConnectionErrorState, ConnectionFailureState, DataSourceSelectionState, EndConnectionState, ExportResourceSelectionState, IntermediateState, ResourceSelectionState
Enclosing class:
Workflow

public abstract static class Workflow.State
extends java.lang.Object


Constructor Summary
Workflow.State()
           
 
Method Summary
abstract  java.lang.String getName()
           
 Workflow.State getPreviousState()
          Returns the previous state.
 Workflow getWorkflow()
           
 boolean hasNext()
          Determines if the state can dynamically create a new state to be the next active state of the workflow.
 void init(IProgressMonitor monitor)
          Initialize the state.
 Workflow.State next()
          The final method in the lifecycle of the state.
 boolean run(IProgressMonitor monitor)
          Performs any "hard" work.
 void setPrevious(Workflow.State previous)
          Sets the previous state.
 void setWorkflow(Workflow workflow)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Workflow.State

public Workflow.State()
Method Detail

setWorkflow

public void setWorkflow(Workflow workflow)
Parameters:
workflow - The workflow containing the state.

getName

public abstract java.lang.String getName()

getWorkflow

public Workflow getWorkflow()
Returns:
the worklow containing all the states.

setPrevious

public void setPrevious(Workflow.State previous)
Sets the previous state. The first method in the lifecycle of the state which is called by the data workflow to track the states that have been completed. Should not be called by client code.

Parameters:
previous - The previous state.

getPreviousState

public Workflow.State getPreviousState()
Returns the previous state.

Returns:
The state previous to this state, or null if no such state exisits.

init

public void init(IProgressMonitor monitor)
          throws java.io.IOException
Initialize the state. This is the second method in the lifecycle of the state. It is called after #setPrevious(). If the state needs to "seed" itself with any context, that should occur here.

Throws:
java.io.IOException

run

public boolean run(IProgressMonitor monitor)
            throws java.io.IOException
Performs any "hard" work. This method is provided is provided for states which have to block to get work done. For instance, making a connection to a remote service. This method returns a boolean which signals wether the state was able to get the work done.

Parameters:
monitor - A progress monitor.
Returns:
True if the state was able to complete its job, otherwise false.
Throws:
java.io.IOException

hasNext

public boolean hasNext()
Determines if the state can dynamically create a new state to be the next active state of the workflow. Note, in most cases this is equivalent to next() != null. However some implemtnations require that next() be called only once, as it is a lifecycle event.

Returns:
true if the state can create a new state, otherwise false.

next

public Workflow.State next()
The final method in the lifecycle of the state. This method is used for states to dynamically link to each other. This method returns null to indicate no state.

Returns:
A new state which is to become the next active state, otherwise null.