Package com.globalmentor.model
Class AbstractSequenceTask
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- com.globalmentor.model.AbstractTask
-
- com.globalmentor.model.AbstractSequenceTask
-
- All Implemented Interfaces:
PropertyBindable
,PropertyConstrainable
,SequenceTask
,Task
public abstract class AbstractSequenceTask extends AbstractTask implements SequenceTask
Abstract implementation of a task performed in a sequence.- Author:
- Garret Wilson
-
-
Field Summary
-
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
-
Fields inherited from interface com.globalmentor.model.SequenceTask
SEQUENCE_INDEX_PROPERTY
-
Fields inherited from interface com.globalmentor.model.Task
STATE_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description AbstractSequenceTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
finish()
Finishes the sequence.protected abstract void
first()
Goes to the first step in the sequence.protected int
getMaxSequenceIndex()
Determines the current highest valid sequence index.protected int
getMinSequenceIndex()
Determines the current lowest valid sequence index.int
getSequenceIndex()
Returns the index in the sequence.void
goFinish()
Verifies the contents and finishes the sequence.void
goFirst()
Goes to the first step in the sequence.void
goNext()
Goes to the next step in the sequence.void
goPrevious()
Goes to the previous step in the sequence.void
goStart()
Starts the sequence annd goes to the first step in the sequence.abstract boolean
hasNext()
Determines if there is a next step in the sequence.abstract boolean
hasPrevious()
Determines if there is a previous step in the sequence.protected abstract void
next()
Goes to the next step in the sequence.protected abstract void
previous()
Goes to the previous step in the sequence.protected void
setSequenceIndex(int newSequenceIndex)
Goes to the indicated index in the sequence.protected void
start()
Starts the sequence by going to the first step in the sequence.-
Methods inherited from class com.globalmentor.model.AbstractTask
getEventListenerManager, getState, setState
-
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface com.globalmentor.beans.PropertyConstrainable
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, hasVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Method Detail
-
getSequenceIndex
public int getSequenceIndex()
Returns the index in the sequence. This is a constrained property of typeInteger
.- Specified by:
getSequenceIndex
in interfaceSequenceTask
- Returns:
- The index in the sequence, or -1 if the sequence has not started.
-
setSequenceIndex
protected void setSequenceIndex(int newSequenceIndex) throws java.beans.PropertyVetoException
Goes to the indicated index in the sequence. This is a bound property of typeInteger
.- Parameters:
newSequenceIndex
- The new index in the sequence.- Throws:
java.lang.IllegalArgumentException
- if the given sequence index is not within the allowed range.java.beans.PropertyVetoException
- if the sequence index change has been vetoed.- See Also:
SequenceTask.SEQUENCE_INDEX_PROPERTY
,getMinSequenceIndex()
,getMaxSequenceIndex()
-
getMinSequenceIndex
protected int getMinSequenceIndex()
Determines the current lowest valid sequence index. This method is called to validate the allowed range of the sequence index. This version returns 0.- Returns:
- The current lowest valid sequence index, inclusive.
-
getMaxSequenceIndex
protected int getMaxSequenceIndex()
Determines the current highest valid sequence index. This method is called to validate the allowed range of the sequence index. This version returnsInteger.MAX_VALUE
.- Returns:
- The current highest valid sequence index, inclusive.
-
goStart
public void goStart()
Starts the sequence annd goes to the first step in the sequence. If the sequence is already started, no action occurs. This implementation delegates tostart()
, which derived classes should override instead of this method.- Specified by:
goStart
in interfaceSequenceTask
- See Also:
start()
-
start
protected void start()
Starts the sequence by going to the first step in the sequence. This implementation sets the task state toTaskState.INCOMPLETE
. This implementation callsgoFirst()
.- Throws:
java.lang.IllegalStateException
- if the task has already been started.- See Also:
goFirst()
-
goFirst
public void goFirst() throws java.beans.PropertyVetoException
Goes to the first step in the sequence. This implementation delegates tofirst()
, which derived classes should override instead of this method.- Specified by:
goFirst
in interfaceSequenceTask
- Throws:
java.beans.PropertyVetoException
- if the sequence index change has been vetoed.- See Also:
first()
-
first
protected abstract void first() throws java.beans.PropertyVetoException
Goes to the first step in the sequence.- Throws:
java.beans.PropertyVetoException
- if the sequence index change has been vetoed.
-
hasPrevious
public abstract boolean hasPrevious()
Determines if there is a previous step in the sequence.- Specified by:
hasPrevious
in interfaceSequenceTask
- Returns:
true
if there is a previous step before the current one.
-
goPrevious
public void goPrevious() throws java.beans.PropertyVetoException
Goes to the previous step in the sequence. If there is no previous component, no action occurs. This implementation delegates toprevious()
, which derived classes should override instead of this method.- Specified by:
goPrevious
in interfaceSequenceTask
- Throws:
java.beans.PropertyVetoException
- if the sequence index change has been vetoed.- See Also:
hasPrevious()
,previous()
-
previous
protected abstract void previous() throws java.beans.PropertyVetoException
Goes to the previous step in the sequence. If there is no previous step, no action occurs.- Throws:
java.beans.PropertyVetoException
- if the sequence index change has been vetoed.
-
hasNext
public abstract boolean hasNext()
Determines if there is a next step in the sequence.- Specified by:
hasNext
in interfaceSequenceTask
- Returns:
true
if there is a next step after the current one.
-
goNext
public void goNext() throws java.beans.PropertyVetoException
Goes to the next step in the sequence. If there is no next step, no action occurs. This implementation delegates tonext()
, which derived classes should override instead of this method.- Specified by:
goNext
in interfaceSequenceTask
- Throws:
java.beans.PropertyVetoException
- if the sequence index change has been vetoed.- See Also:
hasNext()
,next()
-
next
protected abstract void next() throws java.beans.PropertyVetoException
Goes to the next step in the sequence. If there is no next step, no action occurs.- Throws:
java.beans.PropertyVetoException
- if the sequence index change has been vetoed.
-
goFinish
public void goFinish()
Verifies the contents and finishes the sequence. This implementation delegates tofinish()
, which derived classes should override instead of this method.- Specified by:
goFinish
in interfaceSequenceTask
- See Also:
finish()
-
finish
protected void finish()
Finishes the sequence. This implementation sets the task state toTaskState.INCOMPLETE
.
-
-