public final class ProgressUtils 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 <T> T |
showProgressDialogAndRun(ProgressRunnable<T> operation,
String displayName,
boolean includeDetailLabel)
Show a modal progress dialog that blocks the main window, 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, 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, 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 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)
ProgressCallable
.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 <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 February 25 2013. | Portions Copyright 1997-2013 Sun Microsystems, Inc. All rights reserved.