Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2018-02-19 09:52:42 -0500
committerMarvin Mueller2018-02-19 09:52:44 -0500
commit1f4b7d05420970e24c5f17aec9df6cc781400052 (patch)
tree2284f83f73f4d2d5641d842291175d93ac8eb1a1
parent60e137fd5a0c2806bbff570278868e621dc77700 (diff)
downloadorg.eclipse.jubula.core-1f4b7d05420970e24c5f17aec9df6cc781400052.tar.gz
org.eclipse.jubula.core-1f4b7d05420970e24c5f17aec9df6cc781400052.tar.xz
org.eclipse.jubula.core-1f4b7d05420970e24c5f17aec9df6cc781400052.zip
Workarounds for Bug 462674
some internal API has been moved to standard API Change-Id: I9e155708ae2592067b4ddc62c1101ffd2b49651f
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/CurrentStages.java2
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/driver/RobotJavaFXImpl.java2
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TableTester.java6
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TooltipTester.java2
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ChoiceBoxAdapter.java2
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ComboBoxAdapter.java24
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/JavaFXComponentAdapter.java2
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/SliderAdapter.java116
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java22
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/TreeTableOperationContext.java20
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/ComboBoxUtils.java116
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/KeyCodeUtil.java (renamed from org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/KeyCodeUtil.java)2
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/TableUtils.java95
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/WindowsUtil.java (renamed from org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/WindowsUtil.java)2
14 files changed, 232 insertions, 181 deletions
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/CurrentStages.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/CurrentStages.java
index ce3534bb5..c8d80f7af 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/CurrentStages.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/CurrentStages.java
@@ -14,7 +14,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.jubula.rc.javafx.tester.util.WindowsUtil;
+import org.eclipse.jubula.rc.javafx.tester.util.compatibility.WindowsUtil;
import org.eclipse.jubula.tools.internal.utils.EnvironmentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 6296e8349..ca7c4699a 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
@@ -70,9 +70,9 @@ import org.eclipse.jubula.rc.common.util.PointUtil;
import org.eclipse.jubula.rc.common.util.PropertyUtil;
import org.eclipse.jubula.rc.javafx.components.CurrentStages;
import org.eclipse.jubula.rc.javafx.listener.ComponentHandler;
-import org.eclipse.jubula.rc.javafx.tester.util.KeyCodeUtil;
import org.eclipse.jubula.rc.javafx.tester.util.NodeBounds;
import org.eclipse.jubula.rc.javafx.tester.util.Rounding;
+import org.eclipse.jubula.rc.javafx.tester.util.compatibility.KeyCodeUtil;
import org.eclipse.jubula.toolkit.enums.ValueSets;
import org.eclipse.jubula.toolkit.enums.ValueSets.InteractionMode;
import org.eclipse.jubula.tools.internal.i18n.I18n;
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TableTester.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TableTester.java
index 3f5f3f695..6f0da01cb 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TableTester.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TableTester.java
@@ -44,8 +44,6 @@ 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.EnvironmentUtils;
-import com.sun.javafx.scene.control.skin.TableHeaderRow;
-
import javafx.event.EventHandler;
import javafx.geometry.Point2D;
import javafx.scene.Node;
@@ -397,8 +395,8 @@ public class TableTester extends AbstractTableTester {
// Update the layout coordinates otherwise
// we would get old position values
table.layout();
- Parent header = (Parent) table.lookup(
- TableHeaderRow.class.getSimpleName());
+ Parent header = (Parent) table.lookup("TableHeaderRow"); //$NON-NLS-1$
+ // using the String because of different package in java 8/9
return NodeBounds.checkIfContains(pos, header);
}
});
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TooltipTester.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TooltipTester.java
index e7da3d5ea..d6c98985e 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TooltipTester.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/TooltipTester.java
@@ -15,7 +15,7 @@ import java.util.concurrent.Callable;
import org.eclipse.jubula.rc.common.tester.AbstractTooltipTester;
import org.eclipse.jubula.rc.javafx.driver.EventThreadQueuerJavaFXImpl;
-import org.eclipse.jubula.rc.javafx.tester.util.WindowsUtil;
+import org.eclipse.jubula.rc.javafx.tester.util.compatibility.WindowsUtil;
import javafx.scene.control.Tooltip;
import javafx.stage.Window;
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ChoiceBoxAdapter.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ChoiceBoxAdapter.java
index 5be482e50..d1d017909 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ChoiceBoxAdapter.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/ChoiceBoxAdapter.java
@@ -31,7 +31,7 @@ import org.eclipse.jubula.rc.common.tester.adapter.interfaces.IMenuItemComponent
import org.eclipse.jubula.rc.common.util.IndexConverter;
import org.eclipse.jubula.rc.javafx.driver.EventThreadQueuerJavaFXImpl;
import org.eclipse.jubula.rc.javafx.tester.MenuTester;
-import org.eclipse.jubula.rc.javafx.tester.util.WindowsUtil;
+import org.eclipse.jubula.rc.javafx.tester.util.compatibility.WindowsUtil;
import org.eclipse.jubula.tools.internal.constants.TimeoutConstants;
/**
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 50daa2454..2c4d7b38c 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,7 +10,6 @@
*******************************************************************************/
package org.eclipse.jubula.rc.javafx.tester.adapter;
-import java.lang.reflect.Field;
import java.util.List;
import java.util.concurrent.Callable;
@@ -23,19 +22,16 @@ import org.eclipse.jubula.rc.common.tester.adapter.interfaces.IComponent;
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ITextComponent;
import org.eclipse.jubula.rc.javafx.driver.EventThreadQueuerJavaFXImpl;
import org.eclipse.jubula.rc.javafx.tester.util.NodeTraverseHelper;
+import org.eclipse.jubula.rc.javafx.tester.util.compatibility.ComboBoxUtils;
import org.eclipse.jubula.toolkit.enums.ValueSets;
import org.eclipse.jubula.tools.internal.objects.event.EventFactory;
import org.eclipse.jubula.tools.internal.utils.TimeUtil;
-import com.sun.javafx.scene.control.skin.ComboBoxBaseSkin;
-import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin;
-
import javafx.collections.ObservableList;
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 javafx.scene.control.TextField;
/**
@@ -197,10 +193,7 @@ public class ComboBoxAdapter<T extends ComboBox<?>> extends
}
// If there is not exactly one list inside the combo box,
// then use internal API
- ComboBoxListViewSkin<?> comboBoxListViewSkin =
- (ComboBoxListViewSkin<?>) comboBox.getSkin();
- return (ListView<?>)comboBoxListViewSkin
- .getPopupContent();
+ return ComboBoxUtils.getPopUpContent(comboBox);
}
});
}
@@ -225,17 +218,6 @@ public class ComboBoxAdapter<T extends ComboBox<?>> extends
* 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;
+ return ComboBoxUtils.getArrowButton(comboBox);
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/JavaFXComponentAdapter.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/JavaFXComponentAdapter.java
index 4bf01e525..35dccca2f 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/JavaFXComponentAdapter.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/JavaFXComponentAdapter.java
@@ -41,7 +41,7 @@ import org.eclipse.jubula.rc.javafx.driver.EventThreadQueuerJavaFXImpl;
import org.eclipse.jubula.rc.javafx.tester.MenuTester;
import org.eclipse.jubula.rc.javafx.tester.util.NodeBounds;
import org.eclipse.jubula.rc.javafx.tester.util.Rounding;
-import org.eclipse.jubula.rc.javafx.tester.util.WindowsUtil;
+import org.eclipse.jubula.rc.javafx.tester.util.compatibility.WindowsUtil;
import org.eclipse.jubula.toolkit.enums.ValueSets;
import org.eclipse.jubula.tools.internal.constants.TimeoutConstants;
import org.eclipse.jubula.tools.internal.objects.event.EventFactory;
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/SliderAdapter.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/SliderAdapter.java
index a217dc0a9..e64eeb4bf 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/SliderAdapter.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/SliderAdapter.java
@@ -10,18 +10,8 @@
*******************************************************************************/
package org.eclipse.jubula.rc.javafx.tester.adapter;
-import java.awt.Rectangle;
-import java.lang.reflect.Field;
import java.util.concurrent.Callable;
-import javafx.geometry.Orientation;
-import javafx.scene.Node;
-import javafx.scene.control.Slider;
-import javafx.util.StringConverter;
-
-import org.eclipse.jubula.rc.common.driver.ClickOptions;
-import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
-import org.eclipse.jubula.rc.common.driver.IRobot;
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ISliderComponent;
import org.eclipse.jubula.rc.common.util.MatchUtil;
@@ -29,11 +19,11 @@ import org.eclipse.jubula.rc.javafx.driver.EventThreadQueuerJavaFXImpl;
import org.eclipse.jubula.toolkit.enums.ValueSets;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.sun.javafx.scene.control.skin.SliderSkin;
+import javafx.scene.control.Slider;
+import javafx.util.StringConverter;
/**
* Slider Adapter
@@ -78,102 +68,6 @@ public class SliderAdapter extends
});
}
- /**
- * tries to set the position via drag & drop
- * @param units the units (percent or value)
- * @param value the value
- */
- private void setPositionViaDragAndDrop(String units, Double value) {
- Slider slider = getRealComponent();
- double min = slider.getMin();
- double max = slider.getMax();
- double currentRelPos = 100 * (slider.getValue() - min) / (max - min);
- double futureRelPos = value;
- if (ValueSets.Measure.value.rcValue().equalsIgnoreCase(units)) {
- futureRelPos = 100 * (value - min) / (max - min);
- }
- final DragAndDropHelper dndHelper = DragAndDropHelper.getInstance();
- int mouseButton = ValueSets.InteractionMode.primary.rcIntValue();
- dndHelper.setMouseButton(mouseButton);
- final IRobot<Rectangle> robot = getRobot();
- boolean horizontal = slider.getOrientation().equals(
- Orientation.HORIZONTAL);
- if (horizontal) {
- moveHorizontal(currentRelPos, mouseButton);
- } else {
- moveVertical(currentRelPos, mouseButton);
- }
- robot.mousePress(null, null, mouseButton);
- try {
- if (horizontal) {
- // This is a workaround for problems which lead to leaving behind the button
- moveHorizontal(futureRelPos - 2.0, mouseButton);
- TimeUtil.delay(200);
- moveHorizontal(futureRelPos, mouseButton);
- TimeUtil.delay(200);
- moveHorizontal(futureRelPos + 2.0, mouseButton);
- TimeUtil.delay(200);
- moveHorizontal(futureRelPos, mouseButton);
- } else {
- moveVertical(futureRelPos - 2.0, mouseButton);
- TimeUtil.delay(200);
- moveVertical(futureRelPos, mouseButton);
- TimeUtil.delay(200);
- moveVertical(futureRelPos + 2.0, mouseButton);
- TimeUtil.delay(200);
- moveVertical(futureRelPos, mouseButton);
- }
- TimeUtil.delay(200);
- } finally {
- getRobot().mouseRelease(null, null, mouseButton);
- }
- }
-
- /**
- *
- * @param targetPos target position
- * @param mouseButton mouse Button
- */
- private void moveHorizontal(double targetPos, int mouseButton) {
- getRobot().click(
- getTrack(),
- null,
- ClickOptions.create().setClickCount(0)
- .setMouseButton(mouseButton),
- (int)Math.round(targetPos), false, 50, false);
- }
-
- /**
- *
- * @param targetPos target position
- * @param mouseButton mouse Button
- */
- private void moveVertical(double targetPos, int mouseButton) {
- getRobot().click(
- getTrack(),
- null,
- ClickOptions.create().setClickCount(0)
- .setMouseButton(mouseButton),
- 50, false, 100 - (int)Math.round(targetPos), false);
- }
-
- /**
- * @return the track of the slider
- */
- private Node getTrack() {
- SliderSkin skin = (SliderSkin)getRealComponent().getSkin();
- try {
- Field trackField = skin.getClass().getDeclaredField("track"); //$NON-NLS-1$
- trackField.setAccessible(true);
- Node track = (Node) trackField.get(skin);
- return track;
- } catch (NoSuchFieldException | SecurityException
- | IllegalArgumentException | IllegalAccessException e) {
- throw new StepExecutionException("Track not found", //$NON-NLS-1$
- EventFactory.createActionError(
- TestErrorEvent.NOT_FOUND));
- }
- }
/** {@inheritDoc} */
public void setPosition(String position, String operator,
@@ -220,11 +114,7 @@ public class SliderAdapter extends
}
}
}
- try {
- setPositionViaDragAndDrop(units, value);
- } catch (StepExecutionException ste) {
- setValueProgrammatically(units, value);
- }
+ setValueProgrammatically(units, value);
}
/** throws message that input was invalid */
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java
index c8fc01181..ca5caaeea 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java
@@ -31,14 +31,12 @@ import org.eclipse.jubula.rc.javafx.tester.util.GenericTraverseHelper;
import org.eclipse.jubula.rc.javafx.tester.util.NodeBounds;
import org.eclipse.jubula.rc.javafx.tester.util.NodeTraverseHelper;
import org.eclipse.jubula.rc.javafx.tester.util.Rounding;
+import org.eclipse.jubula.rc.javafx.tester.util.compatibility.TableUtils;
import org.eclipse.jubula.tools.internal.constants.TestDataConstants;
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.StringParsing;
-import com.sun.javafx.scene.control.skin.TableColumnHeader;
-import com.sun.javafx.scene.control.skin.TableHeaderRow;
-
import javafx.collections.ObservableList;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
@@ -382,22 +380,8 @@ public class TableAdapter extends JavaFXComponentAdapter<TableView<?>>
table.scrollToColumn(col);
// Update the layout coordinates otherwise
// we would get old position values
- table.layout();
- // DEPENDENCY TO INTERNAL API
- // This should only be one node, but who knows what
- // people do
- List<? extends TableHeaderRow> headerRow =
- NodeTraverseHelper.getInstancesOf(
- table, TableHeaderRow.class);
- TableColumnHeader colH = null;
- for (TableHeaderRow tableHeaderRow : headerRow) {
- colH = tableHeaderRow.getColumnHeaderFor(col);
- if (colH != null) {
- return NodeBounds.getRelativeBounds(colH,
- tableHeaderRow);
- }
- }
- return null;
+ return TableUtils.getNodeBoundsofHeader(table, column,
+ true);
}
});
return result;
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/TreeTableOperationContext.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/TreeTableOperationContext.java
index 3bb4d08eb..0ae2ba82b 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/TreeTableOperationContext.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/TreeTableOperationContext.java
@@ -34,14 +34,12 @@ import org.eclipse.jubula.rc.common.util.IndexConverter;
import org.eclipse.jubula.rc.common.util.MatchUtil;
import org.eclipse.jubula.rc.common.util.SelectionUtil;
import org.eclipse.jubula.rc.javafx.driver.EventThreadQueuerJavaFXImpl;
+import org.eclipse.jubula.rc.javafx.tester.util.compatibility.TableUtils;
import org.eclipse.jubula.tools.internal.constants.TestDataConstants;
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.StringParsing;
-import com.sun.javafx.scene.control.skin.TableColumnHeader;
-import com.sun.javafx.scene.control.skin.TableHeaderRow;
-
import javafx.collections.ObservableList;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableCell;
@@ -860,20 +858,8 @@ public class TreeTableOperationContext
// Update the layout coordinates otherwise
// we would get old position values
treeTable.layout();
- // DEPENDENCY TO INTERNAL API
- // This should only be one node, but who knows what
- // people do
- List<? extends TableHeaderRow> headerRow =
- NodeTraverseHelper.getInstancesOf(treeTable,
- TableHeaderRow.class);
- TableColumnHeader colH = null;
- for (TableHeaderRow tableHeaderRow : headerRow) {
- colH = tableHeaderRow.getColumnHeaderFor(col);
- if (colH != null) {
- break;
- }
- }
- Rectangle b = NodeBounds.getAbsoluteBounds(colH);
+ Rectangle b = TableUtils.getNodeBoundsofHeader(
+ treeTable, column, false);
Rectangle tableB = NodeBounds
.getAbsoluteBounds(treeTable);
return new Rectangle(Math.abs(tableB.x - b.x),
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/ComboBoxUtils.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/ComboBoxUtils.java
new file mode 100644
index 000000000..b62be3298
--- /dev/null
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/ComboBoxUtils.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2018 BREDEX GmbH. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: BREDEX GmbH - initial API and implementation and/or initial
+ * documentation
+ *******************************************************************************/
+
+package org.eclipse.jubula.rc.javafx.tester.util.compatibility;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javafx.scene.Node;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.ListView;
+import javafx.scene.control.Skin;
+
+/**
+ * Utils class to encapsulate the differences between java8/9
+ * @author BREDEX GmbH
+ *
+ */
+public class ComboBoxUtils {
+
+ /** java 8 ComboBoxBaseSkin */
+ private static final String JAVA8_COMBO_BASESKIN =
+ "com.sun.javafx.scene.control.skin.ComboBoxBaseSkin"; //$NON-NLS-1$
+ /** java 9 ComboBoxBaseSkin */
+ private static final String JAVA9_COMBO_BASESKIN =
+ "javafx.scene.control.skin.ComboBoxBaseSkin"; //$NON-NLS-1$
+ /** java8 ComboBoxListViewSkin */
+ private static final String JAVA8_COMBO_LISTVIEWSKIN =
+ "com.sun.javafx.scene.control.skin.ComboBoxListViewSkin"; //$NON-NLS-1$
+ /** java 9 ComboBoxListViewSkin */
+ private static final String JAVA9_COMBO_LISTVIEWSKIN =
+ "javafx.scene.control.skin.ComboBoxListViewSkin"; //$NON-NLS-1$
+ /** the name of the arrow button field of a combo box skin */
+ private static final String ARROW_BUTTON_FIELD_NAME = "arrowButton"; //$NON-NLS-1$
+ /** get poput content method name */
+ private static final String GET_POPUP_CONTENT = "getPopupContent"; //$NON-NLS-1$
+
+ /** logger */
+ private static Logger log = LoggerFactory.getLogger(ComboBoxUtils.class);
+
+ /** */
+ private ComboBoxUtils() {
+ // Utility
+ }
+
+ /**
+ * @param combobox the combobox
+ * @return a {@link ListView} which is the list of the {@link ComboBox}
+ */
+ public static ListView<?> getPopUpContent(ComboBox<?> combobox) {
+ Class<?> clazz = null;
+ try {
+ clazz = Class.forName(JAVA8_COMBO_LISTVIEWSKIN);
+ } catch (ClassNotFoundException e) {
+ try {
+ clazz = Class.forName(JAVA9_COMBO_LISTVIEWSKIN);
+ } catch (ClassNotFoundException e2) {
+ throw new RuntimeException(e2);
+ }
+ }
+ try {
+ Method method = clazz.getMethod(GET_POPUP_CONTENT);
+ Object o = method.invoke(combobox);
+ if (o instanceof ListView<?>) {
+ return (ListView<?>) o;
+ }
+ } catch (NoSuchMethodException | SecurityException
+ | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param combobox the {@link ComboBox}
+ * @return either the {@link ComboBox} or the arrow Button of the
+ * {@link ComboBox}
+ */
+ public static Node getArrowButton(ComboBox<?> combobox) {
+ Skin<?> skin = combobox.getSkin();
+ Class<?> clazz = null;
+ try {
+ clazz = Class.forName(JAVA8_COMBO_BASESKIN);
+ } catch (ClassNotFoundException e) {
+ try {
+ clazz = Class.forName(JAVA9_COMBO_BASESKIN);
+ } catch (ClassNotFoundException e2) {
+ log.warn("ComboBox base skins not found"); //$NON-NLS-1$
+ return combobox;
+ }
+ }
+ try {
+ Field declaredField =
+ clazz.getDeclaredField(ARROW_BUTTON_FIELD_NAME);
+ declaredField.setAccessible(true);
+ return (Node) declaredField.get(skin);
+ } catch (IllegalArgumentException | IllegalAccessException
+ | NoSuchFieldException | SecurityException e) {
+ // ignore
+ }
+ return combobox;
+ }
+}
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/KeyCodeUtil.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/KeyCodeUtil.java
index e22b20c57..ae559853c 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/KeyCodeUtil.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/KeyCodeUtil.java
@@ -10,7 +10,7 @@
/**
*
*/
-package org.eclipse.jubula.rc.javafx.tester.util;
+package org.eclipse.jubula.rc.javafx.tester.util.compatibility;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/TableUtils.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/TableUtils.java
new file mode 100644
index 000000000..59fc2ba36
--- /dev/null
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/TableUtils.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2018 BREDEX GmbH. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: BREDEX GmbH - initial API and implementation and/or initial
+ * documentation
+ *******************************************************************************/
+
+package org.eclipse.jubula.rc.javafx.tester.util.compatibility;
+
+import java.awt.Rectangle;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.eclipse.jubula.rc.javafx.tester.util.NodeBounds;
+import org.eclipse.jubula.rc.javafx.tester.util.NodeTraverseHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javafx.scene.Node;
+import javafx.scene.Parent;
+import javafx.scene.control.TableView;
+
+/**
+ * {@link TableUtils} is to resolve the problems between the changes of Java 8 and Java 9 fore tables
+ * @author BREDEX GmbH
+ *
+ */
+public class TableUtils {
+
+ /** getColumHeader method name */
+ private static final String GET_COLUMN_HEADER_FOR = "getColumnHeaderFor"; //$NON-NLS-1$
+ /** Java 8 */
+ private static final String JAVA9_TABLE_HEADER_ROW = "javafx.scene.control.skin.TableHeaderRow"; //$NON-NLS-1$
+ /** Java 9 */
+ private static final String JAVA8_TABLE_HEADER_ROW = "com.sun.javafx.scene.control.skin.TableHeaderRow"; //$NON-NLS-1$
+ /** for log messages */
+ private static Logger log = LoggerFactory.getLogger(TableUtils.class);
+
+ /** */
+ private TableUtils() {
+ // utils class
+ }
+
+ /**
+ *
+ * @param table the {@link TableView}
+ * @param column the column number
+ * @param relative should the calculation be relative or absolute
+ * @return the {@link Rectangle} or null if it is not found
+ */
+ public static Rectangle getNodeBoundsofHeader(Parent table,
+ int column, boolean relative) {
+ Class<?> clazz = null;
+ try {
+ clazz = Class.forName(
+ JAVA8_TABLE_HEADER_ROW);
+ } catch (ClassNotFoundException e) {
+ // ignore maybe its java 8
+ try {
+ clazz = Class
+ .forName(JAVA9_TABLE_HEADER_ROW);
+ } catch (ClassNotFoundException e2) {
+ String message = "neither " + JAVA8_TABLE_HEADER_ROW //$NON-NLS-1$
+ + " nor " + JAVA9_TABLE_HEADER_ROW + " found"; //$NON-NLS-1$//$NON-NLS-2$
+ log.error(message, e2);
+ throw new RuntimeException(message, e2);
+ }
+ }
+ try {
+ List<?> headerRow = NodeTraverseHelper.getInstancesOf(table, clazz);
+ Object colH = null;
+ for (Object tableHeaderRow : headerRow) {
+ Method method =
+ clazz.getMethod(GET_COLUMN_HEADER_FOR, Integer.class);
+ colH = method.invoke(tableHeaderRow, column);
+ if (colH != null) {
+ if (relative) {
+ return NodeBounds.getRelativeBounds((Node) colH,
+ (Node) tableHeaderRow);
+ }
+ return NodeBounds.getAbsoluteBounds((Node) colH);
+ }
+ }
+ } catch (IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException | NoSuchMethodException
+ | SecurityException e) {
+ log.error("Error occured", e); //$NON-NLS-1$
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/WindowsUtil.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/WindowsUtil.java
index f83e41df6..ae8d9dcb9 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/WindowsUtil.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/util/compatibility/WindowsUtil.java
@@ -10,7 +10,7 @@
/**
*
*/
-package org.eclipse.jubula.rc.javafx.tester.util;
+package org.eclipse.jubula.rc.javafx.tester.util.compatibility;
import java.lang.reflect.Method;
import java.util.Iterator;

Back to the top