From 63fbd088d746c1fc6ba68e64eb31b52dcb16a5f0 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 5 Aug 2015 20:59:27 +0200 Subject: [PATCH] update all status bar progresses at once (IDEA-143500) --- .../wm/impl/status/InfoAndProgressPanel.java | 52 +++++++++---------- .../impl/status/InlineProgressIndicator.java | 18 +++---- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java index 74941d65a1a6..a3ae87811322 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java @@ -22,7 +22,6 @@ import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; import com.intellij.openapi.fileEditor.impl.EditorsSplitters; import com.intellij.openapi.progress.ProgressIndicator; @@ -47,6 +46,7 @@ import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; import com.intellij.ui.components.panels.Wrapper; import com.intellij.util.Alarm; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.*; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; @@ -62,7 +62,6 @@ import java.util.*; import java.util.List; public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidget { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.wm.impl.status.InfoAndProgressPanel"); private final ProcessPopup myPopup; private final StatusPanel myInfoPanel = new StatusPanel(); @@ -86,30 +85,26 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge private String myCurrentRequestor; + private final Set myDirtyIndicators = ContainerUtil.newIdentityTroveSet(); + private final Update myUpdateIndicators = new Update("UpdateIndicators", false, 1) { + @Override + public void run() { + List indicators; + synchronized (myDirtyIndicators) { + indicators = ContainerUtil.newArrayList(myDirtyIndicators); + myDirtyIndicators.clear(); + } + for (InlineProgressIndicator indicator : indicators) { + indicator.updateAndRepaint(); + } + } + }; + public InfoAndProgressPanel() { setOpaque(false); myRefreshIcon = new RefreshFileSystemIcon(); - // new AsyncProcessIcon("Refreshing filesystem") { - // protected Icon getPassiveIcon() { - // return myEmptyRefreshIcon; - // } - // - // @Override - // public Dimension getPreferredSize() { - // if (!isRunning()) return new Dimension(0, 0); - // return super.getPreferredSize(); - // } - // - // @Override - // public void paint(Graphics g) { - // g.translate(0, -1); - // super.paint(g); - // g.translate(0, 1); - // } - //}; - myRefreshIcon.setPaintPassiveIcon(false); myRefreshAndInfoPanel.setLayout(new BorderLayout()); @@ -277,6 +272,9 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge final ProgressIndicatorEx original = myInline2Original.get(progress); myInline2Original.remove(progress); + synchronized (myDirtyIndicators) { + myDirtyIndicators.remove(progress); + } myOriginal2Inlines.remove(original, progress); if (myOriginal2Inlines.get(original) == null) { @@ -670,13 +668,11 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge } @Override - protected void queueProgressUpdate(final Runnable update) { - myUpdateQueue.queue(new Update(MyInlineProgressIndicator.this, false, 1) { - @Override - public void run() { - update.run(); - } - }); + protected void queueProgressUpdate() { + synchronized (myDirtyIndicators) { + myDirtyIndicators.add(this); + } + myUpdateQueue.queue(myUpdateIndicators); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java index 9c983b3381d4..39ec892afed9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java @@ -139,15 +139,15 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di } protected void updateProgress() { - queueProgressUpdate(new Runnable() { - public void run() { - if (isDisposed()) return; + queueProgressUpdate(); + } - updateProgressNow(); + protected void updateAndRepaint() { + if (isDisposed()) return; - myComponent.repaint(); - } - }); + updateProgressNow(); + + myComponent.repaint(); } public void updateProgressNow() { @@ -197,8 +197,8 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di return false; } - protected void queueProgressUpdate(Runnable update) { - update.run(); + protected void queueProgressUpdate() { + updateAndRepaint(); } protected void queueRunningUpdate(Runnable update) {