org.progeeks.util
Class ProgressManager

java.lang.Object
  extended by org.progeeks.util.ProgressManager

public class ProgressManager
extends java.lang.Object

Provides thread-context sensitive access to progress reporters. A lot of times, deeply nested code will want to report progress to the user or caller or whomever. The idea is that this should be a global resource similar to logging or stdout, etc.. Furthermore, progress reporting is very specific to the thread in which the code is being run. On the swing thread, for example, there is little point to opening up a progress dialog since it will never be updated. ProgressManager provides a mechanism whereby the thread creators can determine what method should be used when reporting progress. Code that does lengthy processing can simply access the static getProgressReporter() methods on this class and the appropriate factory will be used to construct one.

Version:
$Revision: 1.2 $
Author:
Paul Speed

Nested Class Summary
static class ProgressManager.ReporterFactory
          Base implementation of the ProgressReporterFactory.
static class ProgressManager.UserRequestReporterFactory
          ProgressReporter factory that wraps a UserRequestHAndler to provide access to progress reporter instances.
 
Constructor Summary
ProgressManager()
           
 
Method Summary
protected static ProgressManager.ReporterFactory getFactory()
          Returns the progress reporter factory for this thread.
static ProgressReporter getProgressReporter(java.lang.String title, java.lang.String message, int min, int max)
          Returns a ProgressReporter that can be used to report status to the user.
static void setDefaultFactory(ProgressManager.ReporterFactory factory)
          Sets the default ReporterFactory that will be used when a thread has no other factory specified.
static void setFactory(ProgressManager.ReporterFactory factory)
          Registers the specified ReporterFactory as the context factory for this thread.
static void setUserRequestHandler(UserRequestHandler reqHandler)
          Convenience method for registering a factory for this thread by wrapping the specified UserRequestHandler using UserRequestReporterFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressManager

public ProgressManager()
Method Detail

setDefaultFactory

public static void setDefaultFactory(ProgressManager.ReporterFactory factory)
Sets the default ReporterFactory that will be used when a thread has no other factory specified.


setFactory

public static void setFactory(ProgressManager.ReporterFactory factory)
Registers the specified ReporterFactory as the context factory for this thread. Any process running on this thread will retrieve progress reporters created by the specified factory.


setUserRequestHandler

public static void setUserRequestHandler(UserRequestHandler reqHandler)
Convenience method for registering a factory for this thread by wrapping the specified UserRequestHandler using UserRequestReporterFactory.


getFactory

protected static ProgressManager.ReporterFactory getFactory()
Returns the progress reporter factory for this thread.


getProgressReporter

public static ProgressReporter getProgressReporter(java.lang.String title,
                                                   java.lang.String message,
                                                   int min,
                                                   int max)
Returns a ProgressReporter that can be used to report status to the user.

Parameters:
title - The main operation being performed or some descriptive title. Depending on the underlying implementation, status may be grouped by title.
message - The current status message of the operation.
min - The initial minimum value.
max - The initial maximum value. If min and max are -1 then the progress reporter is in an indeterminate state. For example, a swing dialog will just swish back and forth until a real min/max are provided.


Copyright © 2002-2003 Paul Speed. All Rights Reserved.