From: Henri Sara Date: Wed, 25 Mar 2009 07:40:58 +0000 (+0000) Subject: Merge from 5.3 to 6.0: X-Git-Tag: 6.7.0.beta1~3050 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ec748e17c33c19a9e17e70423dc25333c7efce58;p=vaadin-framework.git Merge from 5.3 to 6.0: [7150] Undefined-sized window now resizes if needed. Fixes #2738. [7161] NativeSelect width updated lazily in IE6. Fixes #2742. [7165] Fixed gwt link creation in the 'night' target (for TeamCity building). svn changeset:7171/svn branch:6.0 --- diff --git a/build/build.xml b/build/build.xml index ffd4fdfac6..1935364d6b 100644 --- a/build/build.xml +++ b/build/build.xml @@ -1369,10 +1369,14 @@ + + + + @@ -1380,7 +1384,9 @@ - + + + ${gwt.link.available} @@ -1391,7 +1397,7 @@ - + ##teamcity[buildNumber '${version}'] diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java index 536ed15de6..5c7c3b9f1f 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java @@ -8,7 +8,9 @@ import java.util.Iterator; import java.util.Vector; import com.google.gwt.user.client.ui.Widget; +import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; import com.itmill.toolkit.terminal.gwt.client.UIDL; +import com.itmill.toolkit.terminal.gwt.client.Util; public class INativeSelect extends IOptionGroupBase implements Field { @@ -51,7 +53,11 @@ public class INativeSelect extends IOptionGroupBase implements Field { select.insertItem("", null, 0); select.setItemSelected(0, true); } - + if (BrowserInfo.get().isIE6()) { + // lazy size change - IE6 uses naive dropdown that does not have a + // proper size yet + Util.notifyParentOfSizeChange(this, true); + } } @Override diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java index 915f4b521e..764e400df9 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java @@ -115,6 +115,16 @@ public class IWindow extends IToolkitOverlay implements Container, private boolean readonly; + boolean dynamicWidth = false; + boolean dynamicHeight = false; + boolean layoutRelativeWidth = false; + boolean layoutRelativeHeight = false; + + // If centered (via UIDL), the window should stay in the centered -mode + // until a position is received from the server, or the user moves or + // resizes the window. + boolean centered = false; + private RenderSpace renderSpace = new RenderSpace(MIN_WIDTH, MIN_HEIGHT, true); @@ -304,20 +314,17 @@ public class IWindow extends IToolkitOverlay implements Container, layout = lo; } - boolean dynamicWidth = !uidl.hasAttribute("width"); - boolean dynamicHeight = !uidl.hasAttribute("height"); - boolean widthHasBeenFixed = false; + dynamicWidth = !uidl.hasAttribute("width"); + dynamicHeight = !uidl.hasAttribute("height"); - boolean layoutRelativeWidth = uidl.hasAttribute("layoutRelativeWidth"); - boolean layoutRelativeHeight = uidl - .hasAttribute("layoutRelativeHeight"); + layoutRelativeWidth = uidl.hasAttribute("layoutRelativeWidth"); + layoutRelativeHeight = uidl.hasAttribute("layoutRelativeHeight"); if (dynamicWidth && layoutRelativeWidth) { /* * Relative layout width, fix window width before rendering (width * according to caption) */ - widthHasBeenFixed = true; setNaturalWidth(); } @@ -335,9 +342,8 @@ public class IWindow extends IToolkitOverlay implements Container, * No explicit width is set and the layout does not have relative width * so fix the size according to the layout. */ - if (dynamicWidth && !widthHasBeenFixed) { + if (dynamicWidth && !layoutRelativeWidth) { setNaturalWidth(); - widthHasBeenFixed = true; } if (dynamicHeight && layoutRelativeHeight) { @@ -402,7 +408,12 @@ public class IWindow extends IToolkitOverlay implements Container, // This has to be here because we might not know the content size before // everything is painted into the window if (uidl.getBooleanAttribute("center")) { + // mark as centered - this is unset on move/resize + centered = true; center(); + } else { + // don't try to center the window anymore + centered = false; } updateShadowSizeAndPosition(); @@ -444,7 +455,12 @@ public class IWindow extends IToolkitOverlay implements Container, naturalWidth = getElement().getOffsetWidth(); headerText.getStyle().setProperty("width", headerW); } else { - naturalWidth = getElement().getOffsetWidth(); + // use max(layout width, window width) + // i.e layout content width or caption width + int lowidth = contentPanel.getElement().getScrollWidth() + + borderWidth; // layout does not know about border + int elwidth = getElement().getOffsetWidth(); + naturalWidth = (lowidth > elwidth ? lowidth : elwidth); } setWidth(naturalWidth + "px"); @@ -711,6 +727,7 @@ public class IWindow extends IToolkitOverlay implements Container, resizing = false; case Event.ONMOUSEMOVE: if (resizing) { + centered = false; setSize(event, false); event.preventDefault(); } @@ -859,6 +876,7 @@ public class IWindow extends IToolkitOverlay implements Container, break; case Event.ONMOUSEMOVE: if (dragging) { + centered = false; final int x = DOM.eventGetScreenX(event) - startX + origX; final int y = DOM.eventGetScreenY(event) - startY + origY; setPopupPosition(x, y); @@ -962,6 +980,12 @@ public class IWindow extends IToolkitOverlay implements Container, } public boolean requestLayout(Set child) { + if (dynamicWidth && !layoutRelativeWidth) { + setNaturalWidth(); + } + if (centered) { + center(); + } updateShadowSizeAndPosition(); return true; } diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2742.java b/src/com/itmill/toolkit/tests/tickets/Ticket2742.java new file mode 100644 index 0000000000..77ab797035 --- /dev/null +++ b/src/com/itmill/toolkit/tests/tickets/Ticket2742.java @@ -0,0 +1,42 @@ +/** + * + */ +package com.itmill.toolkit.tests.tickets; + +import com.itmill.toolkit.Application; +import com.itmill.toolkit.ui.HorizontalLayout; +import com.itmill.toolkit.ui.NativeSelect; +import com.itmill.toolkit.ui.Window; + +/** + * @author Risto Yrjänä / IT Mill Ltd. + * + */ +public class Ticket2742 extends Application { + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.Application#init() + */ + @Override + public void init() { + Window mainWindow = new Window(); + setMainWindow(mainWindow); + + String shortString = "Short"; + String longString = "Very, very long"; + + HorizontalLayout hl = new HorizontalLayout(); + + for (int i = 0; i < 2; i++) { + NativeSelect ns = new NativeSelect(shortString); + ns.addItem(longString); + ns.setNullSelectionAllowed(false); + ns.select(longString); + hl.addComponent(ns); + } + mainWindow.addComponent(hl); + } + +} \ No newline at end of file