god bless edt cidr/112.658 idea/112.659 pycharm/112.660 rubymine/112.661 storm/112.657
authorKonstantin Bulenkov <kb@jetbrains.com>
Tue, 31 Jan 2012 23:59:12 +0000 (00:59 +0100)
committerKonstantin Bulenkov <kb@jetbrains.com>
Tue, 31 Jan 2012 23:59:12 +0000 (00:59 +0100)
platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java
platform/platform-tests/testSrc/com/intellij/ide/util/treeView/BaseTreeTestCase.java

index 4d39ef8cec918f121012464cfdc7583822162980..2e21403db49bfe0598c71cb556c502168a309ce3 100644 (file)
@@ -380,7 +380,7 @@ public class AbstractTreeUi {
         UIUtil.invokeLaterIfNeeded(actual);
       }
     }
-    
+
     return result;
   }
 
@@ -836,14 +836,14 @@ public class AbstractTreeUi {
         if (edt) {
           final Ref<Boolean> changes = new Ref<Boolean>(false);
           queueToBackground(new Runnable() {
-            public void run() {
-              changes.set(_update(nodeDescriptor));
-            }
-          }, new Runnable() {
-            public void run() {
-              result.setDone(changes.get());
-            }
-          }, nodeDescriptor);
+                              public void run() {
+                                changes.set(_update(nodeDescriptor));
+                              }
+                            }, new Runnable() {
+                              public void run() {
+                                result.setDone(changes.get());
+                              }
+                            }, nodeDescriptor);
         }
         else {
           result.setDone(_update(nodeDescriptor));
@@ -1061,18 +1061,18 @@ public class AbstractTreeUi {
           if (descriptor != null) {
             DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
             maybeYeild(new ActiveRunnable() {
-                @Override
-                public ActionCallback run() {
-                  ActionCallback result = new ActionCallback();
-                  update(descriptor, false).doWhenDone(new Runnable() {
-                    @Override
-                    public void run() {
-                      updateRow(row + 1, pass);
-                    }
-                  }).notify(result);
-                  return result;
-                }
-              }, pass, node);
+              @Override
+              public ActionCallback run() {
+                ActionCallback result = new ActionCallback();
+                update(descriptor, false).doWhenDone(new Runnable() {
+                  @Override
+                  public void run() {
+                    updateRow(row + 1, pass);
+                  }
+                }).notify(result);
+                return result;
+              }
+            }, pass, node);
           }
         }
       }
@@ -1755,7 +1755,7 @@ public class AbstractTreeUi {
       if (!isReleased()) {
         setCancelRequested(true);
         resetToReady();
-      } 
+      }
       throw e;
     }
   }
@@ -2121,8 +2121,8 @@ public class AbstractTreeUi {
 
 
     List<Object> children = preloadedChildren != null
-                    ? preloadedChildren.getElements()
-                    : Arrays.asList(getChildrenFor(element));
+                            ? preloadedChildren.getElements()
+                            : Arrays.asList(getChildrenFor(element));
     int index = 0;
     for (Object child : children) {
       if (!isValid(child)) continue;
@@ -2362,7 +2362,7 @@ public class AbstractTreeUi {
 
     final ActionCallback done = new ActionCallback();
 
-    final Runnable cancelUpdate = new Runnable() {
+    invokeLaterIfNeeded(new Runnable() {
       public void run() {
         if (isReleased()) {
           done.setRejected();
@@ -2371,29 +2371,21 @@ public class AbstractTreeUi {
 
         if (myResettingToReadyNow.get()) {
           _getReady().notify(done);
-        }
-        else if (isReady()) {
+        } else if (isReady()) {
           resetToReadyNow();
           done.setDone();
-        }
-        else {
+        } else {
           if (isIdle() && hasPendingWork()) {
             resetToReadyNow();
             done.setDone();
-          }
-          else {
+          } else {
             _getReady().notify(done);
           }
         }
 
         maybeReady();
       }
-    };
-    if (ApplicationManager.getApplication().isUnitTestMode() && isEdt()) {
-      cancelUpdate.run();
-    } else {
-      invokeLaterIfNeeded(cancelUpdate, false);
-    }
+    }, false);
 
     if (isEdt() || isPassthroughMode()) {
       maybeReady();
@@ -3621,7 +3613,7 @@ public class AbstractTreeUi {
   }
 
   public boolean addSubtreeToUpdate(final DefaultMutableTreeNode root, final Runnable runAfterUpdate, final boolean updateStructure) {
-  Object element = getElementFor(root);
+    Object element = getElementFor(root);
     if (element != null && getTreeStructure().isAlwaysLeaf(element)) {
       removeFromUnbuilt(root);
       removeLoading(root, true);
@@ -3688,7 +3680,7 @@ public class AbstractTreeUi {
   }
 
   public void userSelect(final Object[] elements, final Runnable onDone, final boolean addToSelection, boolean scroll) {
-    _select(elements, onDone, addToSelection, true, false, scroll, false, true, !ApplicationManager.getApplication().isUnitTestMode() && !isEdt());
+    _select(elements, onDone, addToSelection, true, false, scroll, false, true, true);
   }
 
   void _select(final Object[] elements,
index 2a232a72536183b534b78c49a882ca7f720d1312..445b99e6bbdfd5b7d71ab7d0d3016f68bf287a52 100644 (file)
@@ -53,13 +53,13 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
 
   void doAndWaitForBuilder(final Runnable runnable, final Condition condition) throws Exception {
     final Ref<Boolean> started = new Ref<Boolean>();
-    //invokeLaterIfNeeded(new Runnable() {
-    //  @Override
-    //  public void run() {
+    invokeLaterIfNeeded(new Runnable() {
+      @Override
+      public void run() {
         started.set(true);
         runnable.run();
-    //  }
-    //});
+      }
+    });
 
     waitBuilderToCome(new Condition() {
       @Override