diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/PotemkinProgress.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/PotemkinProgress.java index 0d33a12c1479..b78f1b570a4e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/PotemkinProgress.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/PotemkinProgress.java @@ -67,8 +67,11 @@ public class PotemkinProgress extends ProgressWindow { public void interact() { if (ApplicationManager.getApplication().isDispatchThread()) { - dispatchAwtEventsWithoutModelAccess(0); - updateUI(); + long now = System.currentTimeMillis(); + if (shouldDispatchAwtEvents(now)) { + dispatchAwtEventsWithoutModelAccess(0); + } + updateUI(now); } } @@ -87,6 +90,14 @@ public class PotemkinProgress extends ProgressWindow { } } + private long myLastShouldDispatchCheck = 0; + private boolean shouldDispatchAwtEvents(long now) { + if (now == myLastShouldDispatchCheck) return false; + + myLastShouldDispatchCheck = now; + return getDialog().getPanel().isShowing(); + } + private void dispatchInputEvent(InputEvent e) { if (isCancellationEvent(e)) { cancel(); @@ -104,20 +115,20 @@ public class PotemkinProgress extends ProgressWindow { return dialogWindow instanceof JDialog && SwingUtilities.isDescendingFrom(source, dialogWindow); } - private void updateUI() { + private void updateUI(long now) { JRootPane rootPane = getDialog().getPanel().getRootPane(); if (rootPane == null) { - rootPane = considerShowingDialog(); + rootPane = considerShowingDialog(now); } - if (rootPane != null && timeToPaint()) { + if (rootPane != null && timeToPaint(now)) { paintProgress(); } } @Nullable - private JRootPane considerShowingDialog() { - if (System.currentTimeMillis() - myLastUiUpdate > DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS) { + private JRootPane considerShowingDialog(long now) { + if (now - myLastUiUpdate > DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS) { getDialog().myRepaintRunnable.run(); showDialog(); return getDialog().getPanel().getRootPane(); @@ -125,8 +136,7 @@ public class PotemkinProgress extends ProgressWindow { return null; } - private boolean timeToPaint() { - long now = System.currentTimeMillis(); + private boolean timeToPaint(long now) { if (now - myLastUiUpdate <= ProgressDialog.UPDATE_INTERVAL) { return false; } @@ -172,7 +182,7 @@ public class PotemkinProgress extends ProgressWindow { while (isRunning()) { dispatchAwtEventsWithoutModelAccess(10); - updateUI(); + updateUI(System.currentTimeMillis()); } } finally {