flush ant messages in smart mode (EA-91687 - INRE: FileBasedIndexImpl.handleDumbMode)
authorpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 16:19:04 +0000 (17:19 +0100)
committerpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 17:18:28 +0000 (18:18 +0100)
plugins/ant/src/com/intellij/lang/ant/config/execution/AntBuildMessageView.java

index e38e3b4e6ee187384c53bdda2df28be2dbf918f5..7dfb89c04b100a3c69b161389286dfd558b0873b 100644 (file)
@@ -35,6 +35,7 @@ import com.intellij.lang.ant.segments.OutputPacketProcessor;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
@@ -112,15 +113,9 @@ public final class AntBuildMessageView extends JPanel implements DataProvider, O
   private final AntMessageCustomizer[] myMessageCustomizers = AntMessageCustomizer.EP_NAME.getExtensions();
 
   private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
-  private final Runnable myFlushLogRunnable = new Runnable() {
-    @Override
-    public void run() {
-      if (myCommandsProcessedCount < myLog.size()) {
-        if (!myIsOutputPaused) {
-          new OutputFlusher().doFlush();
-          myTreeView.scrollToLastMessage();
-        }
-      }
+  private final Runnable myFlushLogRunnable = () -> {
+    if (myCommandsProcessedCount < myLog.size()) {
+      flushWhenSmart(true);
     }
   };
 
@@ -834,14 +829,16 @@ public final class AntBuildMessageView extends JPanel implements DataProvider, O
         }
       }
     });
-    //noinspection SSBasedInspection
-    SwingUtilities.invokeLater(() -> {
-      if (!myProject.isDisposed()) {
-        DumbService.getInstance(myProject).runWhenSmart(() -> {
-          if (!myIsOutputPaused) {
-            new OutputFlusher().doFlush();
-          }
-        });
+    ApplicationManager.getApplication().invokeLater(() -> flushWhenSmart(false), ModalityState.any(), myProject.getDisposed());
+  }
+
+  private void flushWhenSmart(boolean scroll) {
+    DumbService.getInstance(myProject).runWhenSmart(() -> {
+      if (!myIsOutputPaused) {
+        new OutputFlusher().doFlush();
+        if (scroll) {
+          myTreeView.scrollToLastMessage();
+        }
       }
     });
   }