org.netbeans.api.progress/1 1.20.1

org.netbeans.api.progress
Class ProgressUtils

java.lang.Object
  extended by org.netbeans.api.progress.ProgressUtils

public final class ProgressUtils
extends Object

Useful static methods

Since:
1.16

Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

runOffEventDispatchThread

public 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. First it shows wait cursor after ~50ms elapses, if operation takes longer than ~10s a dialog with Cancel button is shown.

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!

Parameters:
operation - operation to perform
operationDescr - text shown in dialog
cancelOperation - set to true if user canceled the operation
waitForCanceled - true if method should wait until canceled task is finished (if it is not finished in 1s ISE is thrown)

runOffEventDispatchThread

public 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. First it shows wait cursor after waitCursorAfter elapses, if operation takes longer than dialogAfter a dialog with Cancel button is shown.

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!

Parameters:
operation - operation to perform
operationDescr - text shown in dialog
cancelOperation - set to true if user canceled the operation
waitForCanceled - 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 shown
dialogAfter - time in ms after which dialog with "Cancel" button is shown
Since:
1.19

showProgressDialogAndRun

public 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.

This method is thread-safe, and will block until the operation has completed, regardless of what thread calls this method.

Unless you are being passed the runnable or progress handle from foreign code (such as in WizardDescriptor.progressInstantiatingIterator), it is usually simpler to use the version of this method that takes a ProgressCallable.

Parameters:
operation - A runnable to run in the background
progress - A progress handle to create a progress bar for
includeDetailLabel - 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.
Since:
1.19

showProgressDialogAndRun

public 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.

This method is thread-safe, and will block until the operation has completed, regardless of what thread calls this method.

Type Parameters:
T - The result type - use Void if no return type needed
Parameters:
operation - A runnable-like object which performs work in the background, and is passed a ProgressHandle to update progress
displayName - The display name for this operation
includeDetailLabel - If true, include a lable to show progress details (needed only if you plan to call ProgressHandle.setProgress(String, int)
Returns:
The result of the operation.
Since:
1.19

showProgressDialogAndRun

public 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.

This method is thread-safe, and will block until the operation has completed, regardless of what thread calls this method. .

Parameters:
operation - A runnable to run
displayName - The display name of the operation, to show in the dialog
Since:
1.19

showProgressDialogAndRunLater

public 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. This call should block until the work is started, and then return a task which can be monitored for completion or cancellation. This method will not block while the work is run, only until the progress UI is initialized.

Parameters:
operation -
handle -
includeDetailLabel -
Returns:

org.netbeans.api.progress/1 1.20.1

Built on February 9 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.