Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2018-02-02 02:17:31 -0500
committerMarvin Mueller2018-02-06 08:33:25 -0500
commit30d83f9b2ee91e7ad21494f181eac3416324b538 (patch)
tree87b9bef0b05286ed0077d2e48d4354e3d5f1c616
parent41e60b4a905f643e86fe1372716bab6da1ca811d (diff)
downloadorg.eclipse.jubula.core-30d83f9b2ee91e7ad21494f181eac3416324b538.tar.gz
org.eclipse.jubula.core-30d83f9b2ee91e7ad21494f181eac3416324b538.tar.xz
org.eclipse.jubula.core-30d83f9b2ee91e7ad21494f181eac3416324b538.zip
Fix for problem in javafx list with selection
if the cell which should be selected is not completly visible (e.g. because it is the first entry in the list and not properly scrolled to) we are now calculating the correct height of the cell Change-Id: I02a3e0dd04b655f97a827635c14178bab7769b82
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ListViewAdapter.java33
1 files changed, 29 insertions, 4 deletions
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ListViewAdapter.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ListViewAdapter.java
index e3669ae82..36b0a6104 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ListViewAdapter.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ListViewAdapter.java
@@ -30,6 +30,7 @@ import org.eclipse.jubula.rc.javafx.tester.util.NodeTraverseHelper;
import org.eclipse.jubula.rc.javafx.tester.util.Rounding;
import org.eclipse.jubula.tools.internal.objects.event.EventFactory;
import org.eclipse.jubula.tools.internal.objects.event.TestErrorEvent;
+import org.eclipse.jubula.tools.internal.utils.TimeUtil;
import javafx.collections.ObservableList;
import javafx.scene.control.ListCell;
@@ -98,7 +99,28 @@ public class ListViewAdapter<T extends ListView<?>> extends
EventFactory
.createActionError(TestErrorEvent.INVALID_INDEX));
}
+ EventThreadQueuerJavaFXImpl.invokeAndWait("scrollIndexVisible", //$NON-NLS-1$
+ new Callable<Rectangle>() {
+ public Rectangle call() throws Exception {
+ final T listView = getRealComponent();
+ listView.layout();
+ listView.scrollTo(index.intValue());
+ return null;
+ }
+ });
+ TimeUtil.delay(100); // wait a little bit for layout to be done
+ Rectangle r = scrollToAndGetRectangle(index);
+ getRobot().click(getRealComponent(), r,
+ co.setClickType(ClickOptions.ClickType.RELEASED));
+ }
+
+ /**
+ * scrolls to the specified intex and returns the target {@link Rectangle}
+ * @param index the index
+ * @return the target {@link Rectangle}
+ */
+ private Rectangle scrollToAndGetRectangle(final Integer index) {
Rectangle r = EventThreadQueuerJavaFXImpl.invokeAndWait(
"scrollIndexVisible", //$NON-NLS-1$
new Callable<Rectangle>() {
@@ -131,20 +153,23 @@ public class ListViewAdapter<T extends ListView<?>> extends
if (StringUtils.isBlank(cell.getText())) {
widthOfClickableRectangle = b.getWidth();
}
+ double bHeight = b.getHeight();
+ if ((b.y - tableB.y) < 0) {
+ // calculate height of the cell if its at the beginning of the list
+ bHeight = b.getHeight() + (tableB.y - b.y);
+ }
return new Rectangle(Math.abs(tableB.x - b.x),
Math.abs(tableB.y - b.y),
Rounding.round(
widthOfClickableRectangle),
- Rounding.round(b.getHeight()));
+ Rounding.round(bHeight));
}
}
return null;
}
});
-
- getRobot().click(getRealComponent(), r,
- co.setClickType(ClickOptions.ClickType.RELEASED));
+ return r;
}
/** {@inheritDoc} **/

Back to the top