Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Struckmann2015-09-16 05:48:57 -0400
committerSebastian Struckmann2015-09-16 05:48:57 -0400
commitdf4bd4956ad959440a96e4dea7e99994e81ddf8b (patch)
treec71a55623effdce87bd8d140482cf1ba1009b6a5
parentd32373ab15ce803a7fc6c76918766752e5bb078a (diff)
downloadorg.eclipse.jubula.core-df4bd4956ad959440a96e4dea7e99994e81ddf8b.tar.gz
org.eclipse.jubula.core-df4bd4956ad959440a96e4dea7e99994e81ddf8b.tar.xz
org.eclipse.jubula.core-df4bd4956ad959440a96e4dea7e99994e81ddf8b.zip
Sprint task - Change way of opening combo boxes in JavaFX toolkit to use arrow button; see http://eclip.se/474884
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/driver/RobotJavaFXImpl.java7
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ComboBoxAdapter.java29
2 files changed, 33 insertions, 3 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 81d62d543..4c9fdcd17 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
@@ -643,8 +643,11 @@ public class RobotJavaFXImpl implements IRobot<Rectangle> {
@Override
public Rectangle call() throws Exception {
- node.getParent().requestLayout();
- node.getParent().layout();
+ Parent parent = node.getParent();
+ if (parent != null) {
+ parent.requestLayout();
+ parent.layout();
+ }
return NodeBounds.getAbsoluteBounds(node);
}
});
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ComboBoxAdapter.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ComboBoxAdapter.java
index e5e5d2618..c99712bab 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ComboBoxAdapter.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ComboBoxAdapter.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jubula.rc.javafx.tester.adapter;
+import java.lang.reflect.Field;
import java.util.List;
import java.util.concurrent.Callable;
@@ -18,6 +19,7 @@ import javafx.scene.Node;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
+import javafx.scene.control.Skin;
import org.eclipse.jubula.rc.common.driver.ClickOptions;
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
@@ -25,6 +27,7 @@ import org.eclipse.jubula.rc.common.tester.adapter.interfaces.IComboComponent;
import org.eclipse.jubula.rc.javafx.driver.EventThreadQueuerJavaFXImpl;
import org.eclipse.jubula.rc.javafx.util.NodeTraverseHelper;
+import com.sun.javafx.scene.control.skin.ComboBoxBaseSkin;
import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin;
/**
@@ -37,6 +40,10 @@ import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin;
*/
public class ComboBoxAdapter<T extends ComboBox<?>> extends
JavaFXComponentAdapter<T> implements IComboComponent {
+
+ /** the name of the arrow button field of a combo box skin */
+ private static final String ARROW_BUTTON_FIELD_NAME = "arrowButton"; //$NON-NLS-1$
+
/**
* Creates an object with the adapted Label.
*
@@ -168,8 +175,28 @@ public class ComboBoxAdapter<T extends ComboBox<?>> extends
*/
private void setOpenedStatus(T comboBox, boolean openStatus) {
if (comboBox.isShowing() != openStatus) {
- getRobot().click(comboBox, null,
+ getRobot().click(getArrowButton(comboBox), null,
ClickOptions.create().setClickCount(1).setMouseButton(1));
}
}
+
+ /**
+ * @param comboBox combo box
+ * @return the arrow button of the combo box or the combo box itself
+ * if the arrow was not found
+ */
+ private Node getArrowButton(T comboBox) {
+ Skin<?> skin = comboBox.getSkin();
+ if (skin instanceof ComboBoxBaseSkin) {
+ try {
+ Field arrowButton = ComboBoxBaseSkin.class
+ .getDeclaredField(ARROW_BUTTON_FIELD_NAME);
+ arrowButton.setAccessible(true);
+ return (Node) arrowButton.get(skin);
+ } catch (Exception e) {
+ // ignore, return combo box
+ }
+ }
+ return comboBox;
+ }
} \ No newline at end of file

Back to the top