Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Struckmann2014-03-28 09:53:40 -0400
committerSebastian Struckmann2014-03-28 09:56:49 -0400
commitdb64f504a3a181b21371a8b6052ae46017aa14bf (patch)
treebab369a8804190e84855ef4b725c87879052b085
parent4e3b7a3257d21d654f5429f804c20ca2488bc21d (diff)
downloadorg.eclipse.jubula.core-db64f504a3a181b21371a8b6052ae46017aa14bf.tar.gz
org.eclipse.jubula.core-db64f504a3a181b21371a8b6052ae46017aa14bf.tar.xz
org.eclipse.jubula.core-db64f504a3a181b21371a8b6052ae46017aa14bf.zip
Non-sprint task - Improvements for object mapping in JavaFX; see https://bugs.eclipse.org/431325.
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/ParentGetter.java14
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/listener/ComponentHandler.java30
2 files changed, 27 insertions, 17 deletions
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/ParentGetter.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/ParentGetter.java
index 69e2ff389..4b247b8f4 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/ParentGetter.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/components/ParentGetter.java
@@ -14,7 +14,6 @@ import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Menu;
-import javafx.stage.Stage;
import javafx.stage.Window;
/**
@@ -48,8 +47,6 @@ public class ParentGetter {
result = getFrom((Menu) o);
} else if (o instanceof Node) {
result = getFrom((Node) o);
- } else if (o instanceof Stage) {
- result = getFrom((Stage) o);
} else if (o instanceof Scene) {
result = getFrom((Scene) o);
} else if (o instanceof ContextMenu) {
@@ -78,17 +75,6 @@ public class ParentGetter {
}
/**
- * A stage can optionally have an owner Window.
- *
- * @param stage
- * the Stage
- * @return the owner Window or null
- */
- private static Window getFrom(Stage stage) {
- return stage.getOwner();
- }
-
- /**
*
* @param node
* the Node
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/listener/ComponentHandler.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/listener/ComponentHandler.java
index f5f214515..3b6990faf 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/listener/ComponentHandler.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/listener/ComponentHandler.java
@@ -173,12 +173,36 @@ public class ComponentHandler implements ListChangeListener<Stage>,
*/
private static Node filterMatches(List<Node> matches) {
- Node youngesCommonAncestor = findFirstCommonAncestor(matches);
+ List<Node> filteredMatches = filterOutUnfocussedNodes(matches);
+ if (filteredMatches.size() == 1) {
+ return filteredMatches.get(0);
+ }
+
+ Node firstCommonAncestor = findFirstCommonAncestor(filteredMatches);
/* Always of type Parent */
- return topMostDescendant((Parent)youngesCommonAncestor, matches);
+ if (firstCommonAncestor != null) {
+ return topMostDescendant(
+ (Parent)firstCommonAncestor, filteredMatches);
+ }
+ return null;
}
/**
+ * Filters out nodes from unfocused windows from a given list
+ * @param matches the list
+ * @return list containing only the nodes of focused window
+ */
+ private static List<Node> filterOutUnfocussedNodes(List<Node> matches) {
+ List<Node> filteredMatches = new ArrayList<Node>();
+ for (Node match : matches) {
+ if (match.getScene().getWindow().isFocused()) {
+ filteredMatches.add(match);
+ }
+ }
+ return filteredMatches;
+ }
+
+ /**
* Returns all instances of the type Node from a given list which are
* descendants of a given parent node
* @param parent the parent
@@ -247,7 +271,7 @@ public class ComponentHandler implements ListChangeListener<Stage>,
* @return the first common ancestor
*/
private static Node findFirstCommonAncestor(List<Node> nodelist) {
- if (nodelist.size() <= 0) {
+ if (nodelist == null || nodelist.size() <= 0) {
return null;
} else if (nodelist.size() == 1) {
return nodelist.get(0);

Back to the top