Module is.codion.swing.common.ui
Package is.codion.swing.common.ui.dialog
Interface ProgressWorkerDialogBuilder<T,V>
- Type Parameters:
T- the type of result thisProgressWorkerproduces.V- the type of intermediate result thisProgressWorkerproduces.
- All Superinterfaces:
DialogBuilder<ProgressWorkerDialogBuilder<T,V>>
public interface ProgressWorkerDialogBuilder<T,V>
extends DialogBuilder<ProgressWorkerDialogBuilder<T,V>>
A builder for a
ProgressWorker implementation which displays a progress bar in a modal dialog
while background work is being performed.
The progress bar can be of type 'indeterminate' or with the progress ranging from 0 to 100.
By default, the progress dialog uses a delayed show/hide mechanism to prevent flickering for fast operations:
- The dialog is only shown if the operation takes longer than
SHOW_DELAYmilliseconds (default: 350ms) - If shown, the dialog remains visible for at least
HIDE_DELAYmilliseconds (default: 800ms)
delay(int, int) or the system properties.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceProvides builders for a given task type. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyValue<Integer> Specifies the minimum duration in milliseconds that a progress dialog should remain visible.static final PropertyValue<Integer> Specifies the delay in milliseconds before showing a progress dialog. -
Method Summary
Modifier and TypeMethodDescriptionbuild()delay(int show, int hide) Configures dialog delay settings to prevent flicker for fast operations.eastComponent(@Nullable JComponent eastComponent) execute()Builds and executes a newProgressWorkerbased on this builderindeterminate(boolean indeterminate) maximum(int maximum) Note that calling this method renders the progress bar determinatenorthComponent(@Nullable JComponent northComponent) onException(String exceptionTitle) onException(Consumer<Exception> onException) progressBarSize(@Nullable Dimension progressBarSize) stringPainted(boolean stringPainted) westComponent(@Nullable JComponent westComponent) Methods inherited from interface is.codion.swing.common.ui.dialog.DialogBuilder
icon, keyEvent, location, locationRelativeTo, onBuild, owner, owner, title, title
-
Field Details
-
SHOW_DELAY
Specifies the delay in milliseconds before showing a progress dialog. Progress dialogs are only shown if the operation takes longer than this delay, preventing dialog flicker for fast operations.- Value type: Integer
- Default value: 350
- See Also:
-
HIDE_DELAY
Specifies the minimum duration in milliseconds that a progress dialog should remain visible. If a progress dialog is shown, it will remain visible for at least this duration even if the operation completes faster, preventing dialog flicker.- Value type: Integer
- Default value: 800
- See Also:
-
-
Method Details
-
indeterminate
- Parameters:
indeterminate- true if the progress bar should be indeterminate- Returns:
- this Builder instance
-
maximum
Note that calling this method renders the progress bar determinate- Parameters:
maximum- the maximum progress, 100 by default- Returns:
- this Builder instance
- See Also:
-
stringPainted
- Parameters:
stringPainted- the string painted status of the progress bar- Returns:
- this Builder instance
-
border
- Parameters:
border- the border to add around the progress bar- Returns:
- this Builder instance
-
northComponent
- Parameters:
northComponent- if specified this component will be added to the BorderLayout.NORTH position of the dialog- Returns:
- this Builder instance
-
westComponent
- Parameters:
westComponent- if specified this component will be added to the BorderLayout.WEST position of the dialog- Returns:
- this Builder instance
-
eastComponent
- Parameters:
eastComponent- if specified this component will be added to the BorderLayout.EAST position of the dialog- Returns:
- this Builder instance
-
control
- Parameters:
control- the control to be added to the dialog as a button- Returns:
- this Builder instance
-
control
- Parameters:
control- this control will be added to the dialog as a button- Returns:
- this Builder instance
-
progressBarSize
- Parameters:
progressBarSize- the size of the progress bar- Returns:
- this Builder instance
-
delay
Configures dialog delay settings to prevent flicker for fast operations. The dialog will only be shown if the operation takes longer thanshowmilliseconds. If the dialog is shown, it will remain visible for at leasthidemilliseconds even if the operation completes faster.Setting the
showdelay to 0 guarantees that the dialog is shown for at leasthidemilliseconds.- Parameters:
show- the delay in milliseconds before showing the dialoghide- the minimum duration in milliseconds to keep the dialog visible once shown- Returns:
- this Builder instance
- See Also:
-
onPublish
- Parameters:
onPublish- called on the Event Dispatch Thread when chunks are available for publishing- Returns:
- this builder instance
-
onResult
- Parameters:
onResult- executed on the Event Dispatch Thread after a successful run- Returns:
- this Builder instance
-
onResult
- Parameters:
onResult- executed on the Event Dispatch Thread after a successful run- Returns:
- this Builder instance
-
onResult
- Parameters:
title- the dialog titlemessage- if specified then this message is displayed after the task has successfully run- Returns:
- this Builder instance
-
onException
- Parameters:
onException- the exception handler- Returns:
- this Builder instance
-
onException
- Parameters:
exceptionTitle- the title of the exception dialog- Returns:
- this Builder instance
-
execute
ProgressWorker<T,V> execute()Builds and executes a newProgressWorkerbased on this builder- Returns:
- a
ProgressWorkerbased on this builder
-
build
ProgressWorker<T,V> build()- Returns:
- a
ProgressWorkerbased on this builder
-