Class SimpleProgressWorker

java.lang.Object
ca.corbett.extras.progress.SimpleProgressWorker
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ExtensionDownloadThread

public abstract class SimpleProgressWorker extends Object implements Runnable
Represents some generic worker thread that performs a simple task, and can be subscribed to for progress events. Intended for use with a simple progress bar such as ProgressMonitor or with SplashProgressWindow. You can also use this class with SplashProgressWindow. For complex tasks with multiple progress bars (major tasks and minor tasks), use the MultiProgressWorker instead.

USAGE: Generally, you just need to extend this class and implement the run() method from the Runnable interface. Use the various fire...() methods to keep listeners up to date as to the status of your operation. Remember to end by invoking EITHER fireProgressComplete() or fireProgressCanceled()! Failure to fire one of these termination events will result in the progress dialog remaining open.

It is important to check for cancellation! The fireProgressUpdate() method returns a boolean indicating whether the operation should continue. If any listener returns false, you should abort your operation as soon as possible and invoke fireProgressCanceled(). Failure to do so may result in the progress dialog remaining open indefinitely.

Reporting errors - If a recoverable error occurs during your operation, you can report it by invoking fireProgressError(). This will notify all listeners of the error. The listeners can then decide whether to continue or cancel the operation by returning true or false. If any listener returns false, you should abort your operation and invoke fireProgressCanceled().

Since:
swing-extras 1.6 (2022-05-10)
Author:
scorbo2
  • Constructor Details

    • SimpleProgressWorker

      public SimpleProgressWorker()
  • Method Details

    • addProgressListener

      public void addProgressListener(SimpleProgressListener listener)
    • removeProgressListener

      public void removeProgressListener(SimpleProgressListener listener)
    • clearProgressListeners

      public void clearProgressListeners()
    • fireProgressBegins

      protected void fireProgressBegins(int totalMajorSteps)
    • fireProgressUpdate

      protected boolean fireProgressUpdate(int currentStep, String message)
    • fireProgressError

      protected boolean fireProgressError(String errorSource, String errorDetails)
    • fireProgressComplete

      protected void fireProgressComplete()
    • fireProgressCanceled

      public void fireProgressCanceled()