Module is.codion.swing.common.model
Class ProgressWorker<T,V>
java.lang.Object
javax.swing.SwingWorker<T,V>
is.codion.swing.common.model.worker.ProgressWorker<T,V>
- Type Parameters:
T- the type of result thisProgressWorkerproduces.V- the type of intermediate result produced by thisProgressWorker
- All Implemented Interfaces:
Runnable,Future<T>,RunnableFuture<T>
A SwingWorker implementation. Instances of this class are not reusable.
Note that this implementation does NOT coalesce progress reports or intermediate result publishing, but simply pushes
those directly to the onProgress and onPublish handlers on the Event Dispatch Thread.
The onStarted handler is guaranteed to be called on the Event Dispatch Thread before the background task executes,
and the onDone handler is guaranteed to be called after the background task completes.
ProgressWorker.builder(this::performTask)
.onStarted(this::displayDialog)
.onDone(this::closeDialog)
.onResult(this::handleResult)
.onProgress(this::displayProgress)
.onPublish(this::publishMessage)
.onCancelled(this::displayCancelledMessage)
.onException(this::displayException)
.execute();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBuilds aProgressWorkerinstance.static interfaceProvides builders for a given task type.static interfaceReports progress and publishes intermediate results for a ProgressWorkerstatic interfaceA progress aware background task producing a result.static interfaceA progress aware background task.static interfaceA background task producing a result.static interfaceA background task.Nested classes/interfaces inherited from class javax.swing.SwingWorker
SwingWorker.StateValueNested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Field Summary
Fields -
Method Summary
Methods inherited from class javax.swing.SwingWorker
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgressMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Field Details
-
DEFAULT_MAXIMUM
public static final int DEFAULT_MAXIMUM- See Also:
-
-
Method Details
-
builder
- Returns:
- a
ProgressWorker.BuilderFactory
-
doInBackground
- Specified by:
doInBackgroundin classSwingWorker<T,V> - Throws:
Exception
-
done
protected void done()- Overrides:
donein classSwingWorker<T,V>
-