private boolean doQueue( @NotNull Document document, @NotNull Project project, CommitStage start, @NonNls @NotNull Object reason) { synchronized (documentsToCommit) { if (!changeCommitStage(document, start, CommitStage.QUEUED_TO_COMMIT, false)) return false; Object[] documentTasks = documentsToCommit.toArray(); for (Object o : documentTasks) { assert o != null : "Null element in:" + documentsToCommit; CommitTask task = (CommitTask) o; if (task.document == document) { ProgressIndicator current = document.getUserData(COMMIT_PROGRESS); if (current == null) { // already queued, not started yet return true; } else { // cancel current commit process to re-queue current.cancel(); removeCommitFromQueue(document); break; } } } ProgressIndicator indicator = new ProgressIndicatorBase(); indicator.start(); documentsToCommit.addLast(new CommitTask(document, project, indicator, reason)); log("Queued", document, false, reason); wakeUpQueue(); return true; } }
@CalledInAwt @Nullable public static <T> T tryComputeFast( @NotNull final Function<ProgressIndicator, T> backgroundTask, final int waitMillis) { final Ref<T> resultRef = new Ref<T>(); ProgressIndicator indicator = executeAndTryWait( new Function<ProgressIndicator, Runnable>() { @Override public Runnable fun(final ProgressIndicator indicator) { final T result = backgroundTask.fun(indicator); return new Runnable() { @Override public void run() { resultRef.set(result); } }; } }, null, waitMillis, false); indicator.cancel(); return resultRef.get(); }
private void useIndicator(ProgressIndicator indicator) { synchronized (documentsToCommit) { // sync to prevent overwriting indicator assert indicator == null || myProgressIndicator != indicator; if (myProgressIndicator != null) { myProgressIndicator.cancel(); } myProgressIndicator = indicator; } }
static Void cancelAndRestartDaemonLater( ProgressIndicator progress, final Project project, TextEditorHighlightingPass pass) { PassExecutorService.log(progress, pass, "Cancel and restart"); progress.cancel(); ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { try { Thread.sleep(new Random().nextInt(100)); } catch (InterruptedException e) { LOG.error(e); } DaemonCodeAnalyzer.getInstance(project).restart(); } }, project.getDisposed()); throw new ProcessCanceledException(); }
void dispose() { myDisposed = true; myProgress.cancel(); }
protected void close() { final ProgressIndicator progress = myBuilder.getUi().getProgress(); if (progress != null) { progress.cancel(); } }
@Override public final void cancel() { super.cancel(); myOriginal.cancel(); }
@Override public void cancel() { myIndicator.cancel(); }
public void cancel() { if (!myIndicator.isCanceled()) { myIndicator.cancel(); } }
@Override public void gutterClosed() { myIndicator.cancel(); }
public void cancel() { super.cancel(); myOriginal.cancel(); }