From: Matti Tahvonen Date: Wed, 17 Mar 2010 16:04:13 +0000 (+0000) Subject: fixes #4362 + test case X-Git-Tag: 6.7.0.beta1~1904 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7f8a52344107eb6c0631f21039b9ee9b21bab6ea;p=vaadin-framework.git fixes #4362 + test case svn changeset:11939/svn branch:6.3 --- diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java index 78a9b9eda5..6005556fff 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@ -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 index 0000000000..9fe44dd7e8 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/window/PositionedSubWindows.java @@ -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; + } +}