public final class BaseProgressUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
runOffEventDispatchThread(Runnable operation,
String operationDescr,
AtomicBoolean cancelOperation,
boolean waitForCanceled)
Runs operation out of event dispatch thread, blocks UI while operation is in progress.
|
static void |
runOffEventDispatchThread(Runnable operation,
String operationDescr,
AtomicBoolean cancelOperation,
boolean waitForCanceled,
int waitCursorAfter,
int dialogAfter)
Runs operation out of event dispatch thread, blocks UI while operation is in progress.
|
static void |
runOffEventThreadWithProgressDialog(Runnable operation,
String dialogTitle,
ProgressHandle progress,
boolean includeDetailLabel,
int waitCursorAfter,
int dialogAfter)
Runs operation out of the event thread, blocking the whole UI.
|
static <T> T |
showProgressDialogAndRun(ProgressRunnable<T> operation,
String displayName,
boolean includeDetailLabel)
Show a modal progress dialog that blocks the main window and all other
currently displayed frames or dialogs, while running the passed runnable
on a background thread.
|
static void |
showProgressDialogAndRun(Runnable operation,
ProgressHandle progress,
boolean includeDetailLabel)
Show a modal progress dialog that blocks the main window and all other
currently displayed frames or dialogs, while running the passed runnable
on a background thread.
|
static void |
showProgressDialogAndRun(Runnable operation,
String displayName)
Show a modal progress dialog that blocks the main window and all other
currently displayed frames or dialogs, while running the passed runnable
on a background thread with an indeterminate-state progress bar.
|
static <T> Future<T> |
showProgressDialogAndRunLater(ProgressRunnable<T> operation,
ProgressHandle handle,
boolean includeDetailLabel)
Show a modal progress dialog that blocks the main window and all other
currently displayed frames or dialogs while running a background process.
|
public static void runOffEventDispatchThread(Runnable operation, String operationDescr, AtomicBoolean cancelOperation, boolean waitForCanceled)
This method is supposed to be used by user invoked foreground actions, that are expected to run very fast in vast majority of cases. However, in some rather rare cases (e.g. extensive IO operations in progress), supplied operation may need longer time. In such case this method first displays wait cursor and if operation takes even more time it displays dialog allowing to cancel operation. DO NOT use this method for operations that may take long time under normal circumstances!
operation
- operation to performoperationDescr
- text shown in dialogcancelOperation
- set to true if user canceled the operationwaitForCanceled
- true if method should wait until canceled task is finished (if it is not finished in 1s ISE is thrown)public static void runOffEventDispatchThread(Runnable operation, String operationDescr, AtomicBoolean cancelOperation, boolean waitForCanceled, int waitCursorAfter, int dialogAfter)
This method is supposed to be used by user invoked foreground actions, that are expected to run very fast in vast majority of cases. However, in some rather rare cases (e.g. extensive IO operations in progress), supplied operation may need longer time. In such case this method first displays wait cursor and if operation takes even more time it displays dialog allowing to cancel operation. DO NOT use this method for operations that may take long time under normal circumstances!
operation
- operation to performoperationDescr
- text shown in dialogcancelOperation
- set to true if user canceled the operationwaitForCanceled
- true if method should wait until canceled task is finished (if it is not finished in 1s ISE is thrown)waitCursorAfter
- time in ms after which wait cursor is showndialogAfter
- time in ms after which dialog with "Cancel" button is shownpublic static void showProgressDialogAndRun(Runnable operation, ProgressHandle progress, boolean includeDetailLabel)
showProgressDialogAndRun(ProgressRunnable, String, boolean)
.operation
- A runnable to run in the backgroundprogress
- A progress handle to create a progress bar forincludeDetailLabel
- True if the caller will use
ProgressHandle.progress (String, int), false if not. If true, the
created dialog will include a label that shows progress details.public static void runOffEventThreadWithProgressDialog(Runnable operation, String dialogTitle, ProgressHandle progress, boolean includeDetailLabel, int waitCursorAfter, int dialogAfter)
Cancellable
interface, cancel button is part of dialog and can be used
to interrupt the operation.operation
- task to perform in the backgrounddialogTitle
- dialog titleprogress
- progress handle. Do not invoke any methods before
passing to this method. Start/progress/finish it
only in operation
includeDetailLabel
- show progress detail label in the dialogwaitCursorAfter
- amount of time, in milliseconds, after which wait
cursor is showndialogAfter
- amount of time, in milliseconds, after which dialog
is shownpublic static <T> T showProgressDialogAndRun(ProgressRunnable<T> operation, String displayName, boolean includeDetailLabel)
T
- The result type - use Void if no return type neededoperation
- A runnable-like object which performs work in the
background, and is passed a ProgressHandle to update progressdisplayName
- The display name for this operationincludeDetailLabel
- If true, include a lable to show progress
details (needed only if you plan to call ProgressHandle.setProgress(String, int)public static void showProgressDialogAndRun(Runnable operation, String displayName)
operation
- A runnable to rundisplayName
- The display name of the operation, to show in the dialogpublic static <T> Future<T> showProgressDialogAndRunLater(ProgressRunnable<T> operation, ProgressHandle handle, boolean includeDetailLabel)
operation
- handle
- includeDetailLabel
- Built on June 4 2024. | Copyright © 2017-2024 Apache Software Foundation. All Rights Reserved.