Java Code Examples for com.intellij.openapi.progress.ProgressIndicator#start()

The following examples show how to use com.intellij.openapi.progress.ProgressIndicator#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: BackgroundTaskUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static <T> T runUnderDisposeAwareIndicator(@Nonnull Disposable parent, @Nonnull Computable<T> task) {
  ProgressIndicator indicator = new EmptyProgressIndicator(ModalityState.defaultModalityState());
  indicator.start();

  Disposable disposable = () -> {
    if (indicator.isRunning()) indicator.cancel();
  };

  if (!registerIfParentNotDisposed(parent, disposable)) {
    indicator.cancel();
    throw new ProcessCanceledException();
  }

  try {
    return ProgressManager.getInstance().runProcess(task, indicator);
  }
  finally {
    Disposer.dispose(disposable);
  }
}
 
Example 2
Source File: MultiThreadSearcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public ProgressIndicator findMoreItems(@Nonnull Map<? extends SearchEverywhereContributor<?>, Collection<SearchEverywhereFoundElementInfo>> alreadyFound,
                                       @Nonnull String pattern,
                                       @Nonnull SearchEverywhereContributor<?> contributor,
                                       int newLimit) {
  ProgressIndicator indicator = new ProgressIndicatorBase();
  ResultsAccumulator accumulator = new ShowMoreResultsAccumulator(alreadyFound, myEqualityProvider, contributor, newLimit, myListener, myNotificationExecutor, indicator);
  indicator.start();
  Runnable task = createSearchTask(pattern, accumulator, indicator, contributor, () -> indicator.stop());
  ApplicationManager.getApplication().executeOnPooledThread(task);

  return indicator;
}