Search in sources :

Example 1 with AppIcon

use of com.intellij.ui.AppIcon in project intellij-community by JetBrains.

the class CompilerTask method addIndicatorDelegate.

private void addIndicatorDelegate() {
    ProgressIndicator indicator = myIndicator;
    if (!(indicator instanceof ProgressIndicatorEx)) {
        return;
    }
    ((ProgressIndicatorEx) indicator).addStateDelegate(new AbstractProgressIndicatorExBase() {

        @Override
        public void cancel() {
            super.cancel();
            selectFirstMessage();
            stopAppIconProgress();
        }

        @Override
        public void stop() {
            super.stop();
            if (!isCanceled()) {
                selectFirstMessage();
            }
            stopAppIconProgress();
        }

        private void selectFirstMessage() {
            if (!isHeadlessMode()) {
                SwingUtilities.invokeLater(() -> {
                    if (myProject != null && myProject.isDisposed()) {
                        return;
                    }
                    synchronized (myMessageViewLock) {
                        if (myErrorTreeView != null) {
                            myErrorTreeView.selectFirstMessage();
                        }
                    }
                });
            }
        }

        private void stopAppIconProgress() {
            UIUtil.invokeLaterIfNeeded(() -> {
                if (myProject != null && myProject.isDisposed()) {
                    return;
                }
                final 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 setText(final String text) {
            super.setText(text);
            updateProgressText();
        }

        @Override
        public void setText2(final String text) {
            super.setText2(text);
            updateProgressText();
        }

        @Override
        public void setFraction(final double fraction) {
            super.setFraction(fraction);
            updateProgressText();
            GuiUtils.invokeLaterIfNeeded(() -> AppIcon.getInstance().setProgress(myProject, APP_ICON_ID, AppIconScheme.Progress.BUILD, fraction, true), ModalityState.any());
        }

        @Override
        protected void onProgressChange() {
            prepareMessageView();
        }
    });
}
Also used : AbstractProgressIndicatorExBase(com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ProgressIndicatorEx(com.intellij.openapi.wm.ex.ProgressIndicatorEx) AppIcon(com.intellij.ui.AppIcon)

Example 2 with AppIcon

use of com.intellij.ui.AppIcon in project intellij-community by JetBrains.

the class TestsUIUtil method showIconProgress.

public static void showIconProgress(Project project, int n, final int maximum, final int problemsCounter, boolean updateWithAttention) {
    AppIcon icon = AppIcon.getInstance();
    if (n < maximum || !updateWithAttention) {
        if (!updateWithAttention || icon.setProgress(project, TESTS, AppIconScheme.Progress.TESTS, (double) n / (double) maximum, problemsCounter == 0)) {
            if (problemsCounter > 0) {
                icon.setErrorBadge(project, String.valueOf(problemsCounter));
            }
        }
    } else {
        if (icon.hideProgress(project, TESTS)) {
            if (problemsCounter > 0) {
                icon.setErrorBadge(project, String.valueOf(problemsCounter));
                icon.requestAttention(project, false);
            } else {
                icon.setOkBadge(project, true);
                icon.requestAttention(project, false);
            }
        }
    }
}
Also used : AppIcon(com.intellij.ui.AppIcon)

Aggregations

AppIcon (com.intellij.ui.AppIcon)2 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 AbstractProgressIndicatorExBase (com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase)1 ProgressIndicatorEx (com.intellij.openapi.wm.ex.ProgressIndicatorEx)1