Run JTree row queries on EDT
com.intellij.ui.tree.ui.DispatchThreadValidator does not allow
background threads to handle Swing components, so move the getRowCount()
to EDT instead.
Bug: 138841377
Test: LayoutInspectorTest
Change-Id: I925d0b0fc64d239246837ded0f8335a67e8d3781
diff --git a/fest-swing/src/main/java/org/fest/swing/fixture/JTreeFixture.java b/fest-swing/src/main/java/org/fest/swing/fixture/JTreeFixture.java
index 87fbc06..ab51c95 100644
--- a/fest-swing/src/main/java/org/fest/swing/fixture/JTreeFixture.java
+++ b/fest-swing/src/main/java/org/fest/swing/fixture/JTreeFixture.java
@@ -14,20 +14,20 @@
*/
package org.fest.swing.fixture;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
-
import org.fest.swing.cell.JTreeCellReader;
import org.fest.swing.core.MouseButton;
import org.fest.swing.core.MouseClickInfo;
import org.fest.swing.core.Robot;
import org.fest.swing.driver.BasicJTreeCellReader;
import org.fest.swing.driver.JTreeDriver;
+import org.fest.swing.edt.GuiQuery;
import org.fest.swing.exception.ActionFailedException;
import org.fest.swing.exception.ComponentLookupException;
import org.fest.swing.exception.LocationUnavailableException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* <p>
@@ -655,4 +655,11 @@
public @Nullable String valueAt(@NotNull String path) {
return driver().nodeValue(target(), path);
}
+
+ /**
+ * @return the number of viewable nodes
+ */
+ public int getRowCount() {
+ return GuiQuery.getNonNull(() -> target().getRowCount());
+ }
}
\ No newline at end of file