IDEA-144699: add a merging update queue for repaint rubymine/142.4589
authorSergey Ignatov <sergey.ignatov@jetbrains.com>
Fri, 4 Sep 2015 12:37:44 +0000 (15:37 +0300)
committerSergey Ignatov <sergey.ignatov@jetbrains.com>
Fri, 4 Sep 2015 12:39:05 +0000 (15:39 +0300)
platform/lang-impl/src/com/intellij/ide/actions/GotoActionAction.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java

index 2040d6bf835e52ae305484227e4d4b21d177faa1..f9508aa5d53d4f015764cbe5088181f976999aae 100644 (file)
@@ -179,7 +179,7 @@ public class GotoActionAction extends GotoActionBase implements DumbAware {
 
   private static void repaint(@Nullable ChooseByNamePopup popup) {
     if (popup != null) {
-      popup.repaintList();
+      popup.repaintListImmediate();
     }
   }
 
index dff46257c914947388dbaf7508ed968698868ac2..65ae2b3a2d7c2e4bb7d74bb8831c8536cec7f064 100644 (file)
@@ -31,6 +31,8 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.statistics.StatisticsInfo;
 import com.intellij.psi.statistics.StatisticsManager;
 import com.intellij.ui.ScreenUtil;
+import com.intellij.util.ui.update.MergingUpdateQueue;
+import com.intellij.util.ui.update.Update;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -54,6 +56,7 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP
   private ActionMap myActionMap;
   private InputMap myInputMap;
   private String myAdText;
+  private MergingUpdateQueue myRepaintQueue = new MergingUpdateQueue("ChooseByNamePopup repaint", 50, true, myList);
 
   protected ChooseByNamePopup(@Nullable final Project project,
                               @NotNull ChooseByNameModel model,
@@ -463,6 +466,30 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP
   }
 
   public void repaintList() {
+    myRepaintQueue.cancelAllUpdates();
+    myRepaintQueue.queue(new MyUpdate(this));
+  }
+
+  private static class MyUpdate extends Update {
+    private final ChooseByNamePopup myPopup;
+
+    public MyUpdate(ChooseByNamePopup popup) {
+      super(popup);
+      myPopup = popup;
+    }
+
+    @Override
+    public void run() {
+      myPopup.repaintListImmediate();
+    }
+
+    @Override
+    public boolean canEat(final Update update) {
+      return true;
+    }
+  }
+
+  public void repaintListImmediate() {
     myList.repaint();
   }
 }