changeset 58:c86f0c7ecdc4

JemmyFX: ComboBoxWrap minor fixes
author Oleg Barbashov <oleg.barbashov@oracle.com>
date Wed, 18 Jul 2012 17:42:11 +0400
parents 7844f43c4834
children 41815a2a941f
files tools/Jemmy/JemmyFX/src/org/jemmy/fx/control/ComboBoxWrap.java tools/Jemmy/JemmyFX/test/org/jemmy/fx/control/ComboBoxApp.java
diffstat 2 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/tools/Jemmy/JemmyFX/src/org/jemmy/fx/control/ComboBoxWrap.java	Mon Jul 16 20:11:41 2012 +0400
+++ b/tools/Jemmy/JemmyFX/src/org/jemmy/fx/control/ComboBoxWrap.java	Wed Jul 18 17:42:11 2012 +0400
@@ -27,16 +27,16 @@
 import java.util.ArrayList;
 import java.util.List;
 import javafx.scene.Node;
+import javafx.scene.Scene;
 import javafx.scene.control.ComboBox;
 import javafx.scene.control.ListView;
 import javafx.scene.control.TextField;
-import javafx.stage.PopupWindow;
 import org.jemmy.action.Action;
 import org.jemmy.action.GetAction;
 import org.jemmy.control.*;
 import org.jemmy.env.Environment;
+import org.jemmy.fx.ByObject;
 import org.jemmy.fx.ByStyleClass;
-import org.jemmy.fx.ByWindowType;
 import org.jemmy.fx.Root;
 import org.jemmy.input.SelectionText;
 import org.jemmy.interfaces.Focus;
@@ -44,6 +44,7 @@
 import org.jemmy.interfaces.Selectable;
 import org.jemmy.interfaces.Selector;
 import org.jemmy.lookup.Lookup;
+import org.jemmy.lookup.LookupCriteria;
 import org.jemmy.timing.State;
 
 @ControlType(ComboBox.class)
@@ -51,6 +52,7 @@
         encapsulates={Object.class})
 @MethodProperties("getValue")
 public class ComboBoxWrap<T extends ComboBox> extends ControlWrap<T> {
+    private final static String COMBO_BOX_STYLE_CLASS = "combo-box-popup";
 
     private Focus focus = Root.ROOT.getThemeFactory().comboBoxFocuser(this);
     private Selectable selectable = null;
@@ -117,9 +119,11 @@
             if (!isShowing()) {
                 ComboBoxWrap.this.as(Parent.class, Node.class).lookup(new ByStyleClass<Node>("arrow-button")).wrap().mouse().click();
             }
-            Parent<Node> popupContainer =
-                    Root.ROOT.lookup(new ByWindowType(PopupWindow.class)).
-                    as(Parent.class, Node.class);
+            Parent<Node> popupContainer = Root.ROOT.lookup(new LookupCriteria<Scene>() {
+                public boolean check(Scene cntrl) {
+                    return Root.ROOT.lookup(new ByObject<Scene>(cntrl)).wrap().as(Parent.class, Node.class).lookup(new ByStyleClass(COMBO_BOX_STYLE_CLASS)).size() == 1;
+                }
+            }).as(Parent.class, Node.class);
 
             Wrap<? extends ListView> list = popupContainer.lookup(ListView.class).wrap();
             list.as(Selectable.class, type).selector().select(state);
--- a/tools/Jemmy/JemmyFX/test/org/jemmy/fx/control/ComboBoxApp.java	Mon Jul 16 20:11:41 2012 +0400
+++ b/tools/Jemmy/JemmyFX/test/org/jemmy/fx/control/ComboBoxApp.java	Wed Jul 18 17:42:11 2012 +0400
@@ -29,6 +29,7 @@
 import javafx.scene.Scene;
 import javafx.scene.control.ComboBox;
 import javafx.scene.layout.VBox;
+import javafx.stage.Popup;
 import javafx.stage.Stage;
 //import org.jemmy.fx.Browser;
 
@@ -60,6 +61,7 @@
 //            }
 //        });
 
+
         ComboBox combo = new ComboBox();
         for (int i = 0; i < 20; i++) {
             combo.getItems().add("Item " + i);
@@ -67,7 +69,11 @@
 
         combo.setEditable(true);
 
-        box.getChildren().add(combo);
+        Popup popup = new Popup();
+        popup.getContent().add(combo);
+
+       
+        //box.getChildren().add(combo);
 
         stage.setScene(scene);
 
@@ -75,5 +81,7 @@
         stage.setHeight(300);
 
         stage.show();
+
+        popup.show(scene.getWindow());
     }
 }
\ No newline at end of file