]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #4362 + test case
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 17 Mar 2010 16:04:13 +0000 (16:04 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 17 Mar 2010 16:04:13 +0000 (16:04 +0000)
svn changeset:11939/svn branch:6.3

src/com/vaadin/terminal/gwt/client/ui/VWindow.java
tests/src/com/vaadin/tests/components/window/PositionedSubWindows.java [new file with mode: 0644]

index 78a9b9eda52878c5a3806ca5a635ef45ee0049fb..6005556fff601074de3919073903bda006ef4c33 100644 (file)
@@ -278,15 +278,16 @@ public class VWindow extends VOverlay implements Container, ScrollListener {
         setClosable(!uidl.getBooleanAttribute("readonly"));
 
         // Initialize the position form UIDL
-        try {
-            final int positionx = uidl.getIntVariable("positionx");
-            final int positiony = uidl.getIntVariable("positiony");
-            if (positionx >= 0 && positiony >= 0) {
-                setPopupPosition(positionx, positiony);
+        int positionx = uidl.getIntVariable("positionx");
+        int positiony = uidl.getIntVariable("positiony");
+        if (positionx >= 0 || positiony >= 0) {
+            if (positionx < 0) {
+                positionx = 0;
             }
-        } catch (final IllegalArgumentException e) {
-            // Silently ignored as positionx and positiony are not required
-            // parameters
+            if (positiony < 0) {
+                positiony = 0;
+            }
+            setPopupPosition(positionx, positiony);
         }
 
         if (uidl.hasAttribute("caption")) {
@@ -733,6 +734,8 @@ public class VWindow extends VOverlay implements Container, ScrollListener {
     @Override
     public void setPopupPosition(int left, int top) {
         if (top < 0) {
+            // ensure window is not moved out of browser window from top of the
+            // screen
             top = 0;
         }
         super.setPopupPosition(left, top);
diff --git a/tests/src/com/vaadin/tests/components/window/PositionedSubWindows.java b/tests/src/com/vaadin/tests/components/window/PositionedSubWindows.java
new file mode 100644 (file)
index 0000000..9fe44dd
--- /dev/null
@@ -0,0 +1,41 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Window;
+
+public class PositionedSubWindows extends TestBase {
+
+    @Override
+    protected String getDescription() {
+        return "Subwindows should obey setPositionX/Y methods also if only one is called";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 4362;
+    }
+
+    @Override
+    protected void setup() {
+        Window smallWindow = getSmallWindow("Top:200");
+
+        smallWindow.setPositionY(200);
+        getMainWindow().addWindow(smallWindow);
+        smallWindow = getSmallWindow("Left:200");
+        smallWindow.setPositionX(200);
+        getMainWindow().addWindow(smallWindow);
+
+        smallWindow = getSmallWindow("50/50");
+        smallWindow.setPositionX(50);
+        smallWindow.setPositionY(50);
+        getMainWindow().addWindow(smallWindow);
+
+    }
+
+    private Window getSmallWindow(String caption) {
+        Window window2 = new Window(caption);
+        window2.setWidth("100px");
+        window2.setHeight("50px");
+        return window2;
+    }
+}