jebl.util
Class CompositeProgressListener

java.lang.Object
  extended by jebl.util.ProgressListener
      extended by jebl.util.CompositeProgressListener

public final class CompositeProgressListener
extends ProgressListener

Author:
Tobias Thierer

Field Summary
protected  double baseTime
           
protected  int currentOperationNum
           
protected  double currentOperationProgress
           
protected  ProgressListener listener
           
protected  int numOperations
           
protected  double[] time
           
 
Fields inherited from class jebl.util.ProgressListener
EMPTY
 
Constructor Summary
CompositeProgressListener(ProgressListener listener, double[] operationDuration)
           
 
Method Summary
protected  void _setIndeterminateProgress()
          This method is a hook called from ProgressListener.setIndeterminateProgress() to allow subclasses a custom reaction to setIndeterminateProgress events.
protected  void _setMessage(String message)
          This method is a hook called from ProgressListener.setMessage(java.lang.String) to allow subclasses a custom reaction to setMessage events.
protected  void _setProgress(double fractionCompleted)
          This method is a hook called from ProgressListener.setProgress(double) to allow subclasses a custom reaction to setProgress events.
 boolean addProgress(double fractionCompletedDiff)
           
 void beginNextSubtask()
          begins the next subtask.
 void beginNextSubtask(String message)
          Convenience method to start the next operation AND set a new message.
 void beginSubtask()
          Used as an alternative to beginNextSubtask().
 void beginSubtask(String message)
          Used as an alternative to beginNextSubtask().
 void clearAllProgress()
          Clear all progress, including that of previous subtasks.
static CompositeProgressListener forFiles(ProgressListener listener, List<File> files)
           
 boolean hasNextSubtask()
           
 boolean isCanceled()
          This method must be implemented by all subclasses.
 boolean setComplete()
           
 
Methods inherited from class jebl.util.ProgressListener
setIndeterminateProgress, setMessage, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numOperations

protected int numOperations

listener

protected ProgressListener listener

currentOperationNum

protected int currentOperationNum

time

protected double[] time

baseTime

protected double baseTime

currentOperationProgress

protected double currentOperationProgress
Constructor Detail

CompositeProgressListener

public CompositeProgressListener(ProgressListener listener,
                                 double[] operationDuration)
Method Detail

forFiles

public static CompositeProgressListener forFiles(ProgressListener listener,
                                                 List<File> files)

beginSubtask

public void beginSubtask()
Used as an alternative to beginNextSubtask(). Instead of calling beginNextSubtask() once after each subtask (except the last), you can instead call beginSubTask at the beginning of every subtask including the first.


beginSubtask

public void beginSubtask(String message)
Used as an alternative to beginNextSubtask(). Instead of calling beginNextSubtask() once after each subtask (except the last), you can instead call beginSubTask at the beginning of every subtask including the first.

Parameters:
message - a message to be displayed to the user as part of the progress

_setProgress

protected void _setProgress(double fractionCompleted)
Description copied from class: ProgressListener
This method is a hook called from ProgressListener.setProgress(double) to allow subclasses a custom reaction to setProgress events. Currently, subclasses are required to implement this method, but in the future it may get an empty default implementation to make it optional for subclasses to subscribe to setProgress events.

Specified by:
_setProgress in class ProgressListener

_setIndeterminateProgress

protected void _setIndeterminateProgress()
Description copied from class: ProgressListener
This method is a hook called from ProgressListener.setIndeterminateProgress() to allow subclasses a custom reaction to setIndeterminateProgress events. Currently, subclasses are required to implement this method, but in the future it may get an empty default implementation to make it optional for subclasses to subscribe to setIndeterminateProgress events.

Specified by:
_setIndeterminateProgress in class ProgressListener

_setMessage

protected void _setMessage(String message)
Description copied from class: ProgressListener
This method is a hook called from ProgressListener.setMessage(java.lang.String) to allow subclasses a custom reaction to setMessage events. Currently, subclasses are required to implement this method, but in the future it may get an empty default implementation to make it optional for subclasses to subscribe to setMessage events.

Specified by:
_setMessage in class ProgressListener

isCanceled

public boolean isCanceled()
Description copied from class: ProgressListener
This method must be implemented by all subclasses. It is called from ProgressListener.setProgress(double), ProgressListener.setIndeterminateProgress() and ProgressListener.setMessage(java.lang.String) to determine the return value of these methods.

Specified by:
isCanceled in class ProgressListener
Returns:
true if the user has requested that this operation be canceled.

addProgress

public boolean addProgress(double fractionCompletedDiff)

setComplete

public boolean setComplete()

hasNextSubtask

public boolean hasNextSubtask()
Returns:
true if there is another subtask available after the current one

clearAllProgress

public void clearAllProgress()
Clear all progress, including that of previous subtasks. Note: if the task has already been canceled, this does not reset its status to non-canceled.


beginNextSubtask

public void beginNextSubtask(String message)
Convenience method to start the next operation AND set a new message.

Parameters:
message - message to set (will be passed to setMessage()

beginNextSubtask

public void beginNextSubtask()
begins the next subtask. Should not be called on the first subtask, but should only be called to start tasks after the first one. If you wish to call a begin subtask method for each task including the first, use beginSubtask() instead.