Class MultiProgressWorker

java.lang.Object
ca.corbett.extras.progress.MultiProgressWorker
All Implemented Interfaces:
Runnable

public abstract class MultiProgressWorker extends Object implements Runnable
Represents some generic worker thread that performs a complex task (major steps and minor steps), and can be subscribed to for major and minor progress events. Intended for use with MultiProgressDialog.

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 fireMajorProgressUpdate() and fireMinorProgressUpdate() methods return 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

    • MultiProgressWorker

      public MultiProgressWorker()
  • Method Details

    • addProgressListener

      public void addProgressListener(MultiProgressListener listener)
    • removeProgressListener

      public void removeProgressListener(MultiProgressListener listener)
    • clearProgressListeners

      public void clearProgressListeners()
    • fireProgressBegins

      protected void fireProgressBegins(int totalMajorSteps)
    • fireMajorProgressUpdate

      protected boolean fireMajorProgressUpdate(int majorStep, int totalMinorSteps, String message)
    • fireMinorProgressUpdate

      public boolean fireMinorProgressUpdate(int majorStep, int minorStep, String message)
    • fireProgressError

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

      public void fireProgressComplete()
    • fireProgressCanceled

      public void fireProgressCanceled()