Java Code Examples for com.intellij.openapi.progress.util.ProgressWindow#start()
The following examples show how to use
com.intellij.openapi.progress.util.ProgressWindow#start() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FormatUtils.java From intellij with Apache License 2.0 | 6 votes |
/** Runs a format future under a progress dialog. */ public static void formatWithProgressDialog( Project project, String title, ListenableFuture<?> future) { ProgressWindow progressWindow = new BackgroundableProcessIndicator( project, title, PerformInBackgroundOption.DEAF, "Cancel", "Cancel", true); progressWindow.setIndeterminate(true); progressWindow.start(); progressWindow.addStateDelegate( new AbstractProgressIndicatorExBase() { @Override public void cancel() { super.cancel(); future.cancel(true); } }); future.addListener( () -> { if (progressWindow.isRunning()) { progressWindow.stop(); progressWindow.processFinish(); } }, MoreExecutors.directExecutor()); }
Example 2
Source File: PendingAsyncTestContext.java From intellij with Apache License 2.0 | 5 votes |
/** * Waits for the run configuration to be configured, displaying a progress dialog if necessary. * * @throws com.intellij.execution.ExecutionException if the run configuration is not successfully * configured */ private void waitForFutureUnderProgressDialog(Project project) throws com.intellij.execution.ExecutionException { if (future.isDone()) { getFutureHandlingErrors(); } // The progress indicator must be created on the UI thread. ProgressWindow indicator = UIUtil.invokeAndWaitIfNeeded( () -> new BackgroundableProcessIndicator( project, progressMessage, PerformInBackgroundOption.ALWAYS_BACKGROUND, "Cancel", "Cancel", /* cancellable= */ true)); indicator.setIndeterminate(true); indicator.start(); indicator.addStateDelegate( new AbstractProgressIndicatorExBase() { @Override public void cancel() { super.cancel(); future.cancel(true); } }); try { getFutureHandlingErrors(); } finally { if (indicator.isRunning()) { indicator.stop(); indicator.processFinish(); } } }
Example 3
Source File: ProgressiveTaskWithProgressIndicator.java From intellij with Apache License 2.0 | 4 votes |
/** * Runs the given task on the specified executor (defaulting to BlazeExecutor's executor) with a * progress dialog. */ public <T> ListenableFuture<T> submitTaskWithResult(ProgressiveWithResult<T> progressive) { // The progress indicator must be created on the UI thread. final ProgressWindow indicator = UIUtil.invokeAndWaitIfNeeded( () -> { if (modality == Modality.MODAL) { ProgressWindow window = new ProgressWindow(cancelable, project); window.setTitle(title); return window; } else { PerformInBackgroundOption backgroundOption = modality == Modality.BACKGROUNDABLE ? PerformInBackgroundOption.DEAF : PerformInBackgroundOption.ALWAYS_BACKGROUND; return new BackgroundableProcessIndicator( project, title, backgroundOption, "Cancel", "Cancel", cancelable); } }); indicator.setIndeterminate(true); indicator.start(); final ListenableFuture<T> future = executor.submit( () -> ProgressManager.getInstance() .runProcess(() -> progressive.compute(indicator), indicator)); if (cancelable) { indicator.addStateDelegate( new AbstractProgressIndicatorExBase() { @Override public void cancel() { super.cancel(); future.cancel(true); } }); } future.addListener( () -> { if (indicator.isRunning()) { indicator.stop(); indicator.processFinish(); } }, MoreExecutors.directExecutor()); return future; }