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 this worker
- All Implemented Interfaces:
Runnable,Future<T>,RunnableFuture<T>
A SwingWorker implementation. Note that instances of this class are not reusable.
Note that this class does NOT coalesce progress reports or intermediate result publishing, but simply pushes
those directly to the onProgress and onPublish handlers to run on the Event Dispatch Thread.
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();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBuilds aProgressWorkerinstance.static interfaceReports progress and publishes intermediate results for a ProgressWorkerstatic interfaceA progress aware background task producing a result.static interfaceA background task producing a result.Nested classes/interfaces inherited from class javax.swing.SwingWorker
SwingWorker.StateValue -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,V> ProgressWorker.Builder<T, V> builder(ProgressWorker.ProgressResultTask<T, V> task) static <T> ProgressWorker.Builder<T,?> builder(ProgressWorker.ResultTask<T> task) protected Tprotected voiddone()Methods inherited from class javax.swing.SwingWorker
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress
-
Method Details
-
builder
- Type Parameters:
T- the worker result type- Parameters:
task- the task to run- Returns:
- a new
ProgressWorker.Builderinstance
-
builder
public static <T,V> ProgressWorker.Builder<T,V> builder(ProgressWorker.ProgressResultTask<T, V> task) - Type Parameters:
T- the worker result typeV- the intermediate result type- Parameters:
task- the task to run- Returns:
- a new
ProgressWorker.Builderinstance
-
doInBackground
- Specified by:
doInBackgroundin classSwingWorker<T,V> - Throws:
Exception
-
done
protected void done()- Overrides:
donein classSwingWorker<T,V>
-