Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Struckmann2014-04-01 10:49:53 -0400
committerSebastian Struckmann2014-04-01 10:52:13 -0400
commit3088958b93642c030cefd6c483e727879f0a01a5 (patch)
tree0f255a4d953e748d160abde5d3ee85b73b873889
parent4e565dba089a46037efbe84822238a387ab20fee (diff)
downloadorg.eclipse.jubula.core-3088958b93642c030cefd6c483e727879f0a01a5.tar.gz
org.eclipse.jubula.core-3088958b93642c030cefd6c483e727879f0a01a5.tar.xz
org.eclipse.jubula.core-3088958b93642c030cefd6c483e727879f0a01a5.zip
Sprint task - Improvements for scrolling in JavaFX and workaround for Groups as content of ScrollPanes; see https://bugs.eclipse.org/429027
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/driver/RobotJavaFXImpl.java49
1 files changed, 39 insertions, 10 deletions
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/driver/RobotJavaFXImpl.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/driver/RobotJavaFXImpl.java
index 55ed5c686..22a4fc863 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/driver/RobotJavaFXImpl.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/driver/RobotJavaFXImpl.java
@@ -29,6 +29,7 @@ import javafx.geometry.BoundingBox;
import javafx.geometry.Bounds;
import javafx.geometry.Point2D;
import javafx.geometry.Rectangle2D;
+import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
@@ -174,9 +175,7 @@ public class RobotJavaFXImpl implements IRobot {
treeView.scrollTo(treeView.getRow(
((TreeCell) scrollNode).getTreeItem()));
}
- } else if (parent instanceof ScrollPane) {
- scrollToNode((ScrollPane) parent, scrollNode);
- }
+ }
}
/**
@@ -197,9 +196,35 @@ public class RobotJavaFXImpl implements IRobot {
// translate local node bounds to ScrollPane content node relative bounds
Node currentNode = scrollNode;
do {
- nodeInScrollPaneContent = currentNode
- .localToParent(nodeInScrollPaneContent);
- currentNode = currentNode.getParent();
+ Parent nextParent = currentNode.getParent();
+
+ boolean cornerCase = false;
+ if (nextParent instanceof Group) {
+ // BEGIN: skip skins in between
+ Parent parentLookup = nextParent.getParent();
+ while (parentLookup != null
+ && !(parentLookup instanceof ScrollPane)) {
+ parentLookup = parentLookup.getParent();
+ }
+ // END: skip skins in between
+
+ // there is a corner case if:
+ // - a group is the direct content node of a scroll pane
+ if (parentLookup != null) {
+ ScrollPane potentialGroupParent =
+ (ScrollPane) parentLookup;
+ if (potentialGroupParent.getContent() == nextParent) {
+ cornerCase = true;
+ }
+ }
+ }
+
+ if (!cornerCase) {
+ nodeInScrollPaneContent = currentNode
+ .localToParent(nodeInScrollPaneContent);
+ }
+
+ currentNode = nextParent;
} while (currentNode != sPaneContent);
// determine left upper corner of node to scroll to
@@ -207,8 +232,10 @@ public class RobotJavaFXImpl implements IRobot {
final double nodeY = nodeInScrollPaneContent.getMinY();
// determine scrolling scaling factor - defaults to 1.0
- final double scaleH = sPane.getHmax() - sPane.getHmin();
- final double scaleV = sPane.getVmax() - sPane.getVmin();
+ double hmin = sPane.getHmin();
+ final double scaleH = sPane.getHmax() - hmin;
+ double vmin = sPane.getVmin();
+ final double scaleV = sPane.getVmax() - vmin;
// determine the actually scrollable distance in x and y direction
final Bounds viewPortBounds = sPane.getViewportBounds();
@@ -219,8 +246,10 @@ public class RobotJavaFXImpl implements IRobot {
contentBounds.getHeight() - viewPortBounds.getHeight();
// scroll ScrollPane programmatically
- sPane.setHvalue((nodeX / actuallyScrollableHDistance) * scaleH);
- sPane.setVvalue((nodeY / actuallyScrollableVDistance) * scaleV);
+ sPane.setHvalue(hmin
+ + (nodeX / actuallyScrollableHDistance) * scaleH);
+ sPane.setVvalue(vmin
+ + (nodeY / actuallyScrollableVDistance) * scaleV);
}
/**

Back to the top