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

The following examples show how to use com.intellij.openapi.progress.ProgressIndicator#start() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: consulo   File: BackgroundTaskUtil.java    License: 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 Project: consulo   File: MultiThreadSearcher.java    License: 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;
}