org.netbeans.api.progress/1 1.16.1 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.
 
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

org.netbeans.api.progress/1 1.16.1 1

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