Side of Software
Wizard Library 1.6

sos.wizard
Interface Task

All Superinterfaces:
javax.swing.ComboBoxModel, javax.swing.ListModel, Model, java.lang.Runnable
All Known Implementing Classes:
AbstractTask

public interface Task
extends javax.swing.ComboBoxModel, Model, java.lang.Runnable

A Runnable object that can consist of any number of sub-tasks, can notify listeners of its progress, and can be paused, resumed, and interrupted.

If an implementation of Task wishes to be interruptible, it should periodically check if its thread has been interrupted. If the thread has been interrupted, then it should undo any changes it has made and return, ensuring that it leaves its thread's interrupted flag set.

Since:
1.0

Method Summary
 void addProgressListener(ProgressListener listener)
          Registers the specified listener to get notified when this task's progress changes.
 java.lang.String getName()
          Returns the (localized) name of this task.
 double getProgress()
          Returns a number between 0 and 100 that estimates this task's percentage complete.
 boolean isInterruptible()
          Returns true if this task can be interrupted.
 boolean isPaused()
          Returns true is this task is paused.
 void pause()
          Pauses this task.
 void removeProgressListener(ProgressListener listener)
          Unregisters the specified listener for getting notified when this task's progress changes.
 void resume()
          Resumes this task if it is paused.
 void run()
          Executes this task.
 
Methods inherited from interface javax.swing.ComboBoxModel
getSelectedItem, setSelectedItem
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, getElementAt, getSize, removeListDataListener
 
Methods inherited from interface sos.wizard.Model
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 

Method Detail

addProgressListener

public void addProgressListener(ProgressListener listener)
Registers the specified listener to get notified when this task's progress changes.

Parameters:
listener - object wishing to get notified

isInterruptible

public boolean isInterruptible()
Returns true if this task can be interrupted.

Returns:
true if this task can be interrupted

getProgress

public double getProgress()
Returns a number between 0 and 100 that estimates this task's percentage complete.

Returns:
the amount of progress this task has made

isPaused

public boolean isPaused()
Returns true is this task is paused.

Returns:
true is this task is paused.


pause

public void pause()
Pauses this task. If it is already paused, then this method has no effect.

Throws:
java.lang.UnsupportedOperationException - if this task is not interruptible
See Also:
resume(), isInterruptible()

resume

public void resume()
Resumes this task if it is paused. If it is not paused, then this method has no effect.

Throws:
java.lang.UnsupportedOperationException - if this task is not interruptible
See Also:
pause(), isInterruptible()

run

public void run()
Executes this task.

Specified by:
run in interface java.lang.Runnable

getName

public java.lang.String getName()
Returns the (localized) name of this task.

Returns:
this task's name

removeProgressListener

public void removeProgressListener(ProgressListener listener)
Unregisters the specified listener for getting notified when this task's progress changes.

Parameters:
listener - object that no longer wishes to be notified

Side of Software
Wizard Library 1.6

Copyright 2004-07 Side of Software (SOS). All rights reserved.