/** * 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. * <p/> * The resulting progress UI should show a cancel button if the passed * runnable implements org.openide.util.Cancellable. * * @param operation * @param handle * @param includeDetailLabel * @return */ public static <T> Future<T> showProgressDialogAndRunLater (final ProgressRunnable<T> operation, final ProgressHandle handle, boolean includeDetailLabel) { if (PROVIDER instanceof Progress) { Progress p = (Progress) PROVIDER; return p.showProgressDialogAndRunLater(operation, handle, includeDetailLabel); } else { FutureTask<T> result = new FutureTask<T>(new Callable<T>() { @Override public T call() throws Exception { return operation.run(handle); } }); PROVIDER.runOffEventDispatchThread(result, handle.getDisplayName(), new AtomicBoolean(false), true, 0, 0); return result; } }
/** * Show a modal progress dialog that blocks the main window, while running * the passed runnable on a background thread. * <p/> * This method is thread-safe, and will block until the operation has * completed, regardless of what thread calls this method. * <p/> * The resulting progress UI should show a cancel button if the passed * runnable implements org.openide.util.Cancellable. * <p/> * Unless you are being passed the runnable or progress handle from foreign * code (such as in WizardDescriptor.progressInstantiatingIterator), it * is usually simpler to use {@link #showProgressDialogAndRun(ProgressRunnable, String, boolean)}. * * @param operation A runnable to run in the background * @param progress A progress handle to create a progress bar for * @param 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 */ public static void showProgressDialogAndRun(Runnable operation, ProgressHandle progress, boolean includeDetailLabel) { if (PROVIDER instanceof Progress) { Progress p = (Progress) PROVIDER; p.showProgressDialogAndRun(operation, progress, includeDetailLabel); } else { PROVIDER.runOffEventDispatchThread(operation, progress.getDisplayName(), new AtomicBoolean(false), false, 0, 0); } }
p.runOffEventThreadWithProgressDialog(operation, dialogTitle, progress, includeDetailLabel, waitCursorAfter, dialogAfter); } else { PROVIDER.runOffEventDispatchThread(operation, progress.getDisplayName(), new AtomicBoolean(false), true,