Module is.codion.swing.common.model
Interface ProgressWorker.Builder<T,V>
- Type Parameters:
T
- the worker result typeV
- the intermediate result type
- Enclosing class:
ProgressWorker<T,
V>
public static interface ProgressWorker.Builder<T,V>
Builds a
ProgressWorker
instance.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
execute()
Builds and executes a newProgressWorker
based on this buildermaximumProgress
(int maximumProgress) Overrides any maximumProgress specified by the task itself.onCancelled
(Runnable onCancelled) Called in case the background task is cancelled viaSwingWorker.cancel(boolean)
or if it throws aCancelException
onException
(Consumer<Exception> onException) onInterrupted
(Runnable onInterrupted) onProgress
(Consumer<Integer> onProgress) Note that this handler does not get called in case the background task finishes before theSwingWorker.StateValue.STARTED
change event is fired.
-
Method Details
-
maximumProgress
Overrides any maximumProgress specified by the task itself.- Parameters:
maximumProgress
- the maximum progress,ProgressWorker.DEFAULT_MAXIMUM_PROGRESS
(100) by default- Returns:
- this builder instance
- See Also:
-
onStarted
Note that this handler does not get called in case the background task finishes before theSwingWorker.StateValue.STARTED
change event is fired.- Parameters:
onStarted
- called on the EDT before background processing is started- Returns:
- this builder instance
-
onDone
- Parameters:
onDone
- called on the Event Dispatch Thread when the task is done running, successfully or not, before the result is processed- Returns:
- this builder instance
-
onResult
- Parameters:
onResult
- called on the Event Dispatch Thread when the result of a successful run is available- Returns:
- this builder instance
-
onResult
- Parameters:
onResult
- called on the Event Dispatch Thread when the result of a successful run is available- Returns:
- this builder instance
-
onProgress
- Parameters:
onProgress
- called on the Event Dispatch Thread when progress is reported- Returns:
- this builder instance
-
onPublish
- Parameters:
onPublish
- called on the Event Dispatch Thread when chunks are available for publishing- Returns:
- this builder instance
-
onException
- Parameters:
onException
- called on the Event Dispatch Thread if an exception occurred- Returns:
- this builder instance
-
onCancelled
Called in case the background task is cancelled viaSwingWorker.cancel(boolean)
or if it throws aCancelException
- Parameters:
onCancelled
- called on the Event Dispatch Thread if the background task was cancelled- Returns:
- this builder instance
-
onInterrupted
- Parameters:
onInterrupted
- called on the Event Dispatch Thread if the background task was interrupted- Returns:
- this builder instance
-
execute
ProgressWorker<T,V> execute()Builds and executes a newProgressWorker
based on this builder- Returns:
- a
ProgressWorker
based on this builder
-
build
ProgressWorker<T,V> build()- Returns:
- a
ProgressWorker
based on this builder
-