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 thisProgressWorker
produces.V
- the type of intermediate result produced by thisProgressWorker
- All Implemented Interfaces:
Runnable
,Future<T>
,RunnableFuture<T>
A SwingWorker implementation. Note that 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 for running 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
Modifier and TypeClassDescriptionstatic interface
Builds aProgressWorker
instance.static interface
Reports progress and publishes intermediate results for a ProgressWorkerstatic interface
A progress aware background task producing a result.static interface
A 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 T
protected void
done()
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.Builder
instance
-
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.Builder
instance
-
doInBackground
- Specified by:
doInBackground
in classSwingWorker<T,
V> - Throws:
Exception
-
done
protected void done()- Overrides:
done
in classSwingWorker<T,
V>
-