summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2009-05-06 13:11:00 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2009-05-06 13:11:00 +0000
commit930d1feaf3667659525746c777b7b6f78cf54c1b (patch)
treeba1551336574d9d2580772aa45abd99138fddaee
parent75fa978fa8059c432755a01aca2eac192c45c21a (diff)
downloadvaadin-framework-930d1feaf3667659525746c777b7b6f78cf54c1b.tar.gz
vaadin-framework-930d1feaf3667659525746c777b7b6f78cf54c1b.zip
selenium locator now works with subwindows
svn changeset:7639/svn branch:6.0
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java22
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java30
2 files changed, 41 insertions, 11 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java b/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java
index c4f44c9440..fee12345aa 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java
@@ -1,5 +1,6 @@
package com.itmill.toolkit.terminal.gwt.client;
+import java.util.ArrayList;
import java.util.Iterator;
import com.google.gwt.user.client.DOM;
@@ -7,6 +8,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ui.IView;
+import com.itmill.toolkit.terminal.gwt.client.ui.IWindow;
import com.itmill.toolkit.terminal.gwt.client.ui.SubPartAware;
/**
@@ -217,6 +219,12 @@ public class ComponentLocator {
if (w instanceof IView) {
return "";
+ } else if (w instanceof IWindow) {
+ IWindow win = (IWindow) w;
+ ArrayList<IWindow> subWindowList = client.getView()
+ .getSubWindowList();
+ int indexOfSubWindow = subWindowList.indexOf(win);
+ return PARENTCHILD_SEPARATOR + "IWindow[" + indexOfSubWindow + "]";
}
Widget parent = w.getParent();
@@ -225,7 +233,7 @@ public class ComponentLocator {
String simpleName = Util.getSimpleName(w);
- Iterator i = ((HasWidgets) parent).iterator();
+ Iterator<Widget> i = ((HasWidgets) parent).iterator();
int pos = 0;
while (i.hasNext()) {
Object child = i.next();
@@ -262,12 +270,16 @@ public class ComponentLocator {
} else if (w instanceof HasWidgets) {
HasWidgets parent = (HasWidgets) w;
- String simpleName = Util.getSimpleName(parent);
+ String[] split = part.split("\\[");
- Iterator i = parent.iterator();
+ Iterator<? extends Widget> i;
+ if (split[0].equals("IWindow")) {
+ i = client.getView().getSubWindowList().iterator();
+ } else {
+ i = parent.iterator();
+ }
boolean ok = false;
- String[] split = part.split("\\[");
int pos = Integer.parseInt(split[1].substring(0, split[1]
.length() - 1));
// ApplicationConnection.getConsole().log(
@@ -275,7 +287,7 @@ public class ComponentLocator {
while (i.hasNext()) {
// ApplicationConnection.getConsole().log("- child found");
- Widget child = (Widget) i.next();
+ Widget child = i.next();
String simpleName2 = Util.getSimpleName(child);
if (split[0].equals(simpleName2)) {
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
index 0c22da4a1e..b30a1eb8af 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
@@ -4,8 +4,10 @@
package com.itmill.toolkit.terminal.gwt.client.ui;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.Set;
import com.google.gwt.dom.client.DivElement;
@@ -44,7 +46,7 @@ public class IView extends SimplePanel implements Container,
private Paintable layout;
- private final HashSet subWindows = new HashSet();
+ private final LinkedHashSet<IWindow> subWindows = new LinkedHashSet<IWindow>();
private String id;
@@ -231,7 +233,8 @@ public class IView extends SimplePanel implements Container,
layout.updateFromUIDL(childUidl, client);
// Update subwindows
- final HashSet removedSubWindows = new HashSet(subWindows);
+ final HashSet<IWindow> removedSubWindows = new HashSet<IWindow>(
+ subWindows);
// Open new windows
while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) {
@@ -240,7 +243,7 @@ public class IView extends SimplePanel implements Container,
if (subWindows.contains(w)) {
removedSubWindows.remove(w);
} else {
- subWindows.add(w);
+ subWindows.add((IWindow) w);
}
w.updateFromUIDL(childUidl, client);
} else if ("actions".equals(childUidl.getTag())) {
@@ -282,8 +285,9 @@ public class IView extends SimplePanel implements Container,
}
// Close old windows
- for (final Iterator rem = removedSubWindows.iterator(); rem.hasNext();) {
- final IWindow w = (IWindow) rem.next();
+ for (final Iterator<IWindow> rem = removedSubWindows.iterator(); rem
+ .hasNext();) {
+ final IWindow w = rem.next();
client.unregisterPaintable(w);
subWindows.remove(w);
w.hide();
@@ -551,7 +555,21 @@ public class IView extends SimplePanel implements Container,
}
public void updateCaption(Paintable component, UIDL uidl) {
- // TODO Auto-generated method stub
+ // NOP Subwindows never draw caption for their first child (layout)
+ }
+
+ /**
+ * Return an iterator for current subwindows. This method is meant for
+ * testing purposes only.
+ *
+ * @return
+ */
+ public ArrayList<IWindow> getSubWindowList() {
+ ArrayList<IWindow> windows = new ArrayList<IWindow>(subWindows.size());
+ for (IWindow widget : subWindows) {
+ windows.add(widget);
+ }
+ return windows;
}
}