com.intellij.openapi.wm.ex.ProgressIndicatorEx Java Examples
The following examples show how to use
com.intellij.openapi.wm.ex.ProgressIndicatorEx.
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: FindUsagesImpl.java From Android-Resource-Usage-Count with MIT License | 6 votes |
private static void dropResolveCacheRegularly(ProgressIndicator indicator, @NotNull final Project project) { if(indicator instanceof ProgressIndicatorEx) { ((ProgressIndicatorEx)indicator).addStateDelegate(new ProgressIndicatorBase() { volatile long lastCleared = System.currentTimeMillis(); public void setFraction(double fraction) { super.setFraction(fraction); long current = System.currentTimeMillis(); if(current - this.lastCleared >= 500L) { this.lastCleared = current; PsiManager.getInstance(project).dropResolveCaches(); } } }); } }
Example #2
Source File: PsiManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
public void dropResolveCacheRegularly(@Nonnull ProgressIndicator indicator) { indicator = ProgressWrapper.unwrap(indicator); if (indicator instanceof ProgressIndicatorEx) { ((ProgressIndicatorEx)indicator).addStateDelegate(new AbstractProgressIndicatorExBase() { private final AtomicLong lastClearedTimeStamp = new AtomicLong(); @Override public void setFraction(double fraction) { long current = System.currentTimeMillis(); long last = lastClearedTimeStamp.get(); if (current - last >= 500 && lastClearedTimeStamp.compareAndSet(last, current)) { // fraction is changed when each file is processed => // resolve caches used when searching in that file are likely to be not needed anymore dropResolveCaches(); } } }); } }
Example #3
Source File: CoreProgressManager.java From consulo with Apache License 2.0 | 6 votes |
@Override public void run() { try { getTask().run(myIndicator); } finally { try { if (myIndicator instanceof ProgressIndicatorEx) { ((ProgressIndicatorEx)myIndicator).finish(getTask()); } } finally { if (myContinuation != null) { myContinuation.run(); } } } }
Example #4
Source File: AbstractProgressIndicatorExBase.java From consulo with Apache License 2.0 | 6 votes |
@Override public final void addStateDelegate(@Nonnull ProgressIndicatorEx delegate) { synchronized (getLock()) { delegate.initStateFrom(this); ProgressIndicatorEx[] stateDelegates = myStateDelegates; if (stateDelegates == null) { myStateDelegates = stateDelegates = new ProgressIndicatorEx[1]; stateDelegates[0] = delegate; } else { // hard throw is essential for avoiding deadlocks if (ArrayUtil.contains(delegate, stateDelegates)) { throw new IllegalArgumentException("Already registered: " + delegate); } myStateDelegates = ArrayUtil.append(stateDelegates, delegate, ProgressIndicatorEx.class); } } }
Example #5
Source File: ProgressSuspender.java From consulo with Apache License 2.0 | 6 votes |
private ProgressSuspender(@Nonnull ProgressIndicatorEx progress, @Nonnull String suspendedText) { mySuspendedText = suspendedText; assert progress.isRunning(); assert ProgressIndicatorProvider.getGlobalProgressIndicator() == progress; myPublisher = ApplicationManager.getApplication().getMessageBus().syncPublisher(TOPIC); attachToProgress(progress); new ProgressIndicatorListenerAdapter() { @Override public void cancelled() { resumeProcess(); } }.installToProgress(progress); myPublisher.suspendableProgressAppeared(this); }
Example #6
Source File: DumbServiceImpl.java From consulo with Apache License 2.0 | 6 votes |
private static void runSingleTask(final DumbModeTask task, final ProgressIndicatorEx taskIndicator) { if (ApplicationManager.getApplication().isInternal()) LOG.info("Running dumb mode task: " + task); // nested runProcess is needed for taskIndicator to be honored in ProgressManager.checkCanceled calls deep inside tasks ProgressManager.getInstance().runProcess(() -> { try { taskIndicator.checkCanceled(); taskIndicator.setIndeterminate(true); taskIndicator.setText(IdeBundle.message("progress.indexing.scanning")); task.performInDumbMode(taskIndicator); } catch (ProcessCanceledException ignored) { } catch (Throwable unexpected) { LOG.error(unexpected); } }, taskIndicator); }
Example #7
Source File: DumbServiceImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private Pair<DumbModeTask, ProgressIndicatorEx> getNextTask(@Nullable DumbModeTask prevTask) { CompletableFuture<Pair<DumbModeTask, ProgressIndicatorEx>> result = new CompletableFuture<>(); UIUtil.invokeLaterIfNeeded(() -> { if (myProject.isDisposed()) { result.completeExceptionally(new ProcessCanceledException()); return; } if (prevTask != null) { Disposer.dispose(prevTask); } result.complete(pollTaskQueue()); }); return waitForFuture(result); }
Example #8
Source File: DumbServiceImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private Pair<DumbModeTask, ProgressIndicatorEx> pollTaskQueue() { while (true) { if (myUpdatesQueue.isEmpty()) { queueUpdateFinished(); return null; } DumbModeTask queuedTask = myUpdatesQueue.pullFirst(); myQueuedEquivalences.remove(queuedTask.getEquivalenceObject()); ProgressIndicatorEx indicator = myProgresses.get(queuedTask); if (indicator.isCanceled()) { Disposer.dispose(queuedTask); continue; } return Pair.create(queuedTask, indicator); } }
Example #9
Source File: InfoAndProgressPanel.java From consulo with Apache License 2.0 | 6 votes |
void addProgress(@Nonnull ProgressIndicatorEx original, @Nonnull TaskInfo info) { synchronized (myOriginals) { final boolean veryFirst = !hasProgressIndicators(); myOriginals.add(original); myInfos.add(info); MyInlineProgressIndicator expanded = createInlineDelegate(info, original, false); MyInlineProgressIndicator compact = createInlineDelegate(info, original, true); myPopup.addIndicator(expanded); updateProgressIcon(); if (veryFirst && !myPopup.isShowing()) { buildInInlineIndicator(compact); } else { buildInProcessCount(); if (myInfos.size() > 1 && Registry.is("ide.windowSystem.autoShowProcessPopup")) { openProcessPopup(false); } } runQuery(); } }
Example #10
Source File: InfoAndProgressPanel.java From consulo with Apache License 2.0 | 6 votes |
private ProgressIndicatorEx removeFromMaps(@Nonnull MyInlineProgressIndicator progress) { final ProgressIndicatorEx original = myInline2Original.get(progress); myInline2Original.remove(progress); synchronized (myDirtyIndicators) { myDirtyIndicators.remove(progress); } myOriginal2Inlines.remove(original, progress); if (myOriginal2Inlines.get(original) == null) { final int originalIndex = myOriginals.indexOf(original); myOriginals.remove(originalIndex); myInfos.remove(originalIndex); } return original; }
Example #11
Source File: FindUsagesImpl171.java From Android-Resource-Usage-Count with MIT License | 6 votes |
private static void dropResolveCacheRegularly(ProgressIndicator indicator, final Project project) { if (indicator instanceof ProgressIndicatorEx) { ((ProgressIndicatorEx)indicator).addStateDelegate(new ProgressIndicatorBase() { volatile long lastCleared = System.currentTimeMillis(); public void setFraction(double fraction) { super.setFraction(fraction); long current = System.currentTimeMillis(); if (current - this.lastCleared >= 500L) { this.lastCleared = current; PsiManager.getInstance(project).dropResolveCaches(); } } }); } }
Example #12
Source File: InfoAndProgressPanel.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private String getMultiProgressLinkText() { ProgressIndicatorEx latest = getLatestProgress(); String latestText = latest == null ? null : latest.getText(); if (StringUtil.isEmptyOrSpaces(latestText) || myPopup.isShowing()) { return myOriginals.size() + pluralizeProcess(myOriginals.size()) + " running..."; } int others = myOriginals.size() - 1; String trimmed = latestText.length() > 55 ? latestText.substring(0, 50) + "..." : latestText; return trimmed + " (" + others + " more" + pluralizeProcess(others) + ")"; }
Example #13
Source File: CodeSmellDetectorImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private List<CodeSmellInfo> findCodeSmells(@Nonnull final VirtualFile file, @Nonnull final ProgressIndicator progress) { final List<CodeSmellInfo> result = Collections.synchronizedList(new ArrayList<CodeSmellInfo>()); final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject); final ProgressIndicator daemonIndicator = new DaemonProgressIndicator(); ((ProgressIndicatorEx)progress).addStateDelegate(new AbstractProgressIndicatorExBase() { @Override public void cancel() { super.cancel(); daemonIndicator.cancel(); } }); ProgressManager.getInstance().runProcess(new Runnable() { @Override public void run() { DumbService.getInstance(myProject).runReadActionInSmartMode(new Runnable() { @Override public void run() { final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file); final Document document = FileDocumentManager.getInstance().getDocument(file); if (psiFile == null || document == null) { return; } List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, daemonIndicator); convertErrorsAndWarnings(infos, result, document); } }); } }, daemonIndicator); return result; }
Example #14
Source File: AbstractProgressIndicatorExBase.java From consulo with Apache License 2.0 | 5 votes |
private void delegate(@Nonnull IndicatorAction action) { ProgressIndicatorEx[] list = myStateDelegates; if (list != null) { for (ProgressIndicatorEx each : list) { action.execute(each); } } }
Example #15
Source File: ProgressIndicatorListener.java From consulo with Apache License 2.0 | 5 votes |
default void installToProgress(ProgressIndicatorEx progress) { progress.addStateDelegate(new AbstractProgressIndicatorExBase() { @Override public void cancel() { super.cancel(); cancelled(); } @Override public void stop() { super.stop(); stopped(); } }); }
Example #16
Source File: InfoAndProgressPanel.java From consulo with Apache License 2.0 | 5 votes |
MyInlineProgressIndicator(final boolean compact, @Nonnull TaskInfo task, @Nonnull ProgressIndicatorEx original) { super(compact, task); myOriginal = original; original.addStateDelegate(this); addStateDelegate(new AbstractProgressIndicatorExBase() { @Override public void cancel() { super.cancel(); updateProgress(); } }); runOnProgressRelatedChange(this::queueProgressUpdate, this); }
Example #17
Source File: InfoAndProgressPanel.java From consulo with Apache License 2.0 | 5 votes |
private void removeProgress(@Nonnull MyInlineProgressIndicator progress) { synchronized (myOriginals) { if (!myInline2Original.containsKey(progress)) return; // already disposed final boolean last = myOriginals.size() == 1; final boolean beforeLast = myOriginals.size() == 2; myPopup.removeIndicator(progress); final ProgressIndicatorEx original = removeFromMaps(progress); if (myOriginals.contains(original)) { Disposer.dispose(progress); return; } if (last) { restoreEmptyStatus(); if (myShouldClosePopupAndOnProcessFinish) { hideProcessPopup(); } } else { if (myPopup.isShowing() || myOriginals.size() > 1) { buildInProcessCount(); } else if (beforeLast) { buildInInlineIndicator(createInlineDelegate(myInfos.get(0), myOriginals.get(0), true)); } else { restoreEmptyStatus(); } } runQuery(); } Disposer.dispose(progress); }
Example #18
Source File: DumbServiceImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void cancelTask(@Nonnull DumbModeTask task) { if (ApplicationManager.getApplication().isInternal()) LOG.info("cancel " + task); ProgressIndicatorEx indicator = myProgresses.get(task); if (indicator != null) { indicator.cancel(); } }
Example #19
Source File: ProgressIndicatorScope.java From intellij with Apache License 2.0 | 5 votes |
public ProgressIndicatorScope(ProgressIndicator progressIndicator) { this.progressIndicator = progressIndicator; if (progressIndicator instanceof ProgressIndicatorEx) { ((ProgressIndicatorEx) progressIndicator).addStateDelegate(this); } }
Example #20
Source File: InfoAndProgressPanel.java From consulo with Apache License 2.0 | 4 votes |
private ProgressIndicatorEx getLatestProgress() { return ContainerUtil.getLastItem(myOriginals); }
Example #21
Source File: InfoAndProgressPanel.java From consulo with Apache License 2.0 | 4 votes |
@Nullable private ProgressSuspender getSuspender() { ProgressIndicatorEx original = myOriginal; return original == null ? null : ProgressSuspender.getSuspender(original); }
Example #22
Source File: ProgressWindow.java From consulo with Apache License 2.0 | 4 votes |
@Override public void addStateDelegate(@Nonnull ProgressIndicatorEx delegate) { throw new IncorrectOperationException(); }
Example #23
Source File: IdeStatusBarImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public void addProgress(@Nonnull ProgressIndicatorEx indicator, @Nonnull TaskInfo info) { myInfoAndProgressPanel.addProgress(indicator, info); }
Example #24
Source File: DumbServiceImpl.java From consulo with Apache License 2.0 | 4 votes |
private void runBackgroundProcess(@Nonnull final ProgressIndicator visibleIndicator) { ((ProgressManagerImpl)ProgressManager.getInstance()).markProgressSafe((ProgressWindow)visibleIndicator); if (!myState.compareAndSet(State.SCHEDULED_TASKS, State.RUNNING_DUMB_TASKS)) return; // Only one thread can execute this method at the same time at this point. try (ProgressSuspender suspender = ProgressSuspender.markSuspendable(visibleIndicator, "Indexing paused")) { myCurrentSuspender = suspender; suspendIfRequested(suspender); //IdeActivity activity = IdeActivity.started(myProject, "indexing"); final ShutDownTracker shutdownTracker = ShutDownTracker.getInstance(); final Thread self = Thread.currentThread(); try { shutdownTracker.registerStopperThread(self); ((ProgressIndicatorEx)visibleIndicator).addStateDelegate(new AppIconProgress()); DumbModeTask task = null; while (true) { Pair<DumbModeTask, ProgressIndicatorEx> pair = getNextTask(task); if (pair == null) break; task = pair.first; //activity.stageStarted(task.getClass()); ProgressIndicatorEx taskIndicator = pair.second; suspender.attachToProgress(taskIndicator); taskIndicator.addStateDelegate(new AbstractProgressIndicatorExBase() { @Override protected void delegateProgressChange(@Nonnull IndicatorAction action) { super.delegateProgressChange(action); action.execute((ProgressIndicatorEx)visibleIndicator); } }); try (AccessToken ignored = HeavyProcessLatch.INSTANCE.processStarted("Performing indexing tasks")) { runSingleTask(task, taskIndicator); } } } catch (Throwable unexpected) { LOG.error(unexpected); } finally { shutdownTracker.unregisterStopperThread(self); // myCurrentSuspender should already be null at this point unless we got here by exception. In any case, the suspender might have // got suspended after the the last dumb task finished (or even after the last check cancelled call). This case is handled by // the ProgressSuspender close() method called at the exit of this try-with-resources block which removes the hook if it has been // previously installed. myCurrentSuspender = null; //activity.finished(); } } }
Example #25
Source File: ProgressSuspender.java From consulo with Apache License 2.0 | 4 votes |
public static ProgressSuspender markSuspendable(@Nonnull ProgressIndicator indicator, @Nonnull String suspendedText) { return new ProgressSuspender((ProgressIndicatorEx)indicator, suspendedText); }
Example #26
Source File: ProgressSuspender.java From consulo with Apache License 2.0 | 4 votes |
/** * Associates an additional progress indicator with this suspender, so that its {@code #checkCanceled} can later block the calling thread. */ public void attachToProgress(@Nonnull ProgressIndicatorEx progress) { myProgresses.add(progress); ((UserDataHolder)progress).putUserData(PROGRESS_SUSPENDER, this); }
Example #27
Source File: CompilerTask.java From consulo with Apache License 2.0 | 4 votes |
private void addIndicatorDelegate() { ProgressIndicator indicator = myIndicator; if (!(indicator instanceof ProgressIndicatorEx)) return; ((ProgressIndicatorEx)indicator).addStateDelegate(new AbstractProgressIndicatorExBase() { @Override public void cancel() { super.cancel(); closeUI(); stopAppIconProgress(); } @Override public void stop() { super.stop(); if (!isCanceled()) { closeUI(); } stopAppIconProgress(); } private void stopAppIconProgress() { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { AppIcon appIcon = AppIcon.getInstance(); if (appIcon.hideProgress(myProject, APP_ICON_ID)) { if (myErrorCount > 0) { appIcon.setErrorBadge(myProject, String.valueOf(myErrorCount)); appIcon.requestAttention(myProject, true); } else if (!myCompilationStartedAutomatically) { appIcon.setOkBadge(myProject, true); appIcon.requestAttention(myProject, false); } } } }); } @Override public void setFraction(final double fraction) { super.setFraction(fraction); UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { AppIcon.getInstance().setProgress(myProject, APP_ICON_ID, AppIconScheme.Progress.BUILD, fraction, true); } }); } }); }
Example #28
Source File: TestWindowManager.java From consulo with Apache License 2.0 | 4 votes |
@Override public void addProgress(@Nonnull ProgressIndicatorEx indicator, @Nonnull TaskInfo info) { }
Example #29
Source File: MigrationsToolWindow.java From yiistorm with MIT License | 4 votes |
public void runBackgroundTask(final int Action, Project project) { final Task.Backgroundable task = new Task.Backgroundable(project, "Yii migrations", false) { @Override public String getProcessId() { return "Yii migrations"; } @Override public DumbModeAction getDumbModeAction() { return DumbModeAction.CANCEL; } public void run(@NotNull final ProgressIndicator indicator) { final Task.Backgroundable this_task = this; ((ProgressIndicatorEx) indicator).addStateDelegate(new ProgressIndicatorBase() { @Override public void cancel() { this_task.onCancel(); } }); switch (Action) { case MigrationsToolWindow.MIGRATE_DOWN_BACKGROUND_ACTION: indicator.setText("Migrating 1 down"); indicator.setFraction(0.1); MigrationsToolWindow.toolw.migrateDown(); indicator.setFraction(0.3); MigrationsToolWindow.toolw.updateNewMigrations(true); indicator.setFraction(0.5); indicator.setText("Updating migrations menu"); MigrationsToolWindow.toolw.fillActionMenu(); indicator.setFraction(0.8); break; case MigrationsToolWindow.ADD_MENUS_BACKGROUND_ACTION: indicator.setText("Updating migrations list"); indicator.setFraction(0.1); MigrationsToolWindow.toolw.updateNewMigrations(true); indicator.setFraction(0.5); MigrationsToolWindow.toolw.addMenus(); indicator.setFraction(0.8); break; case MigrationsToolWindow.UPDATE_MIGRAITIONS_MENUS_BACKGROUND_ACTION: indicator.setText("Updating migrations list"); indicator.setFraction(0.1); MigrationsToolWindow.toolw.updateNewMigrations(true); indicator.setFraction(0.5); indicator.setText("Updating migrations menu"); MigrationsToolWindow.toolw.fillActionMenu(); indicator.setFraction(0.8); break; case MigrationsToolWindow.APPLY_MIGRATIONS_BACKGROUND_ACTION: indicator.setText("Applying migrations list"); indicator.setFraction(0.1); MigrationsToolWindow.toolw.applyMigrations(); indicator.setFraction(0.3); MigrationsToolWindow.toolw.updateNewMigrations(false); indicator.setFraction(0.5); indicator.setText("Updating migrations menu"); MigrationsToolWindow.toolw.fillActionMenu(); indicator.setFraction(0.8); break; case MigrationsToolWindow.CREATE_MIGRATION_BACKGROUND_ACTION: indicator.setText("Creating migration: " + newMigrationDialog.getMigrationName()); indicator.setFraction(0.1); MigrationsToolWindow.toolw.createMigrationByName(newMigrationDialog.getMigrationName()); indicator.setFraction(0.3); MigrationsToolWindow.toolw.updateNewMigrations(false, true); indicator.setFraction(0.5); indicator.setText("Updating migrations menu"); MigrationsToolWindow.toolw.fillActionMenu(); indicator.setFraction(0.8); break; } indicator.stop(); } }; task.setCancelText("Stop processing").queue(); }
Example #30
Source File: WebStatusBarImpl.java From consulo with Apache License 2.0 | 2 votes |
@Override public void addProgress(@Nonnull ProgressIndicatorEx indicator, @Nonnull TaskInfo info) { }