]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge from 5.3 to 6.0:
authorHenri Sara <henri.sara@itmill.com>
Wed, 25 Mar 2009 07:40:58 +0000 (07:40 +0000)
committerHenri Sara <henri.sara@itmill.com>
Wed, 25 Mar 2009 07:40:58 +0000 (07:40 +0000)
[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

build/build.xml
src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
src/com/itmill/toolkit/tests/tickets/Ticket2742.java [new file with mode: 0644]

index ffd4fdfac6ad8d59699ba102d95b86429e5f8c24..1935364d6b412127cc2bfc42a83c155333848a8b 100644 (file)
     <!-- Initialize a nightly build. -->
     <target name="nightly-init" depends="">
 
+        <!-- Mandatory parameters. -->
         <fail unless="version.minor" message="The version.minor property must be defined."/>
         <fail unless="build.number" message="The build.number property must be defined."/>
         <fail unless="nightly.publish" message="The nightly.publish property must be defined."/>
 
+        <!-- Optional parameters. -->
+        <property name="build.tag" value="dev"/>
+
         <!-- We need to create a symlink to the GWT directory, because we   -->
         <!-- are building automatically.                                    -->
         <property name="gwt.link.target" value="../../gwt-1.5"/>
         <!-- Create the link unless it already exists. -->
         <available file="gwt" property="gwt.link.available"/> 
                <if>
-            <isset property="gwt.link.available"/>
+            <not>
+                <isset property="gwt.link.available"/>
+            </not>
                        <then>
                 <echo>${gwt.link.available}</echo>
                 <symlink link="gwt" resource="${gwt.link.target}" failonerror="false"/>
         <tstamp>
             <format property="nightly.date" pattern="yyyyMMdd"/>
         </tstamp>
-        <property name="version" value="${version.minor}-nightly-${nightly.date}-b${build.number}"/>
+        <property name="version" value="${version.minor}-${build.tag}-${nightly.date}-b${build.number}"/>
         <echo>##teamcity[buildNumber '${version}']</echo>
     </target>
 
index 536ed15de6d34a6211077bb6af25f76ddff347c1..5c7c3b9f1f001f77e765e684b3080f2cc72c78c4 100644 (file)
@@ -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
index 915f4b521e439b15ef248215fc715a93670514b7..764e400df9fd633bbf4bd44a44c40df03eb00042 100644 (file)
@@ -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<Paintable> 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 (file)
index 0000000..77ab797
--- /dev/null
@@ -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