void () { ProgressIndicator indicator = myIndicator; if (!(indicator instanceof ProgressIndicatorEx)) { return; } ((ProgressIndicatorEx)indicator).addStateDelegate(new AbstractProgressIndicatorExBase() { @Override public void cancel() { super.cancel(); stopAppIconProgress(); } @Override public void stop() { super.stop(); stopAppIconProgress(); } 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 setFraction(final double fraction) { super.setFraction(fraction); ModalityUiUtil.invokeLaterIfNeeded( ModalityState.any(), () -> AppIcon.getInstance().setProgress(myProject, APP_ICON_ID, AppIconScheme.Progress.BUILD, fraction, true) ); } @Override protected void onProgressChange() { myBuildViewService.onProgressChange(mySessionId, this); } }); }