]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test case and fix for #2478 - Label wrapping inconsistency in IOrderedLayout
authorArtur Signell <artur.signell@itmill.com>
Sun, 25 Jan 2009 17:04:30 +0000 (17:04 +0000)
committerArtur Signell <artur.signell@itmill.com>
Sun, 25 Jan 2009 17:04:30 +0000 (17:04 +0000)
svn changeset:6637/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/layout/ChildComponentContainer.java
src/com/itmill/toolkit/tests/components/label/LabelWrapping.java [new file with mode: 0644]

index f875fee46564c874df8f3e3db2ca4c85db9ab84d..c7ad11f7f88bf026e85b6960da5973eb6dda86a6 100644 (file)
@@ -730,6 +730,9 @@ public class IOrderedLayout extends CellBasedLayout {
             ChildComponentContainer componentContainer = getComponentContainer((Widget) p);\r
             if (isDynamicWidth()) {\r
                 componentContainer.setUnlimitedContainerWidth();\r
+            } else {\r
+                componentContainer.setLimitedContainerWidth(activeLayoutSize\r
+                        .getWidth());\r
             }\r
 \r
             componentContainer.updateWidgetSize();\r
index 6367c03a3e7133a13ddca0071381c0a0d35c87e0..fe8ba6497e366b00341b4bca6a87a2301af7b4ff 100644 (file)
@@ -172,7 +172,7 @@ public class ChildComponentContainer extends Panel {
          * is automatically calculated correctly (e.g. for Labels).
          */
         if (fixedWidth > 0) {
-            containerDIV.getStyle().setProperty("width", fixedWidth + "px");
+            setLimitedContainerWidth(fixedWidth);
         } else {
             setUnlimitedContainerWidth();
         }
@@ -181,7 +181,11 @@ public class ChildComponentContainer extends Panel {
     }
 
     public void setUnlimitedContainerWidth() {
-        containerDIV.getStyle().setProperty("width", "1000000px");
+        setLimitedContainerWidth(1000000);
+    }
+
+    public void setLimitedContainerWidth(int width) {
+        containerDIV.getStyle().setProperty("width", width + "px");
     }
 
     public void updateWidgetSize() {
diff --git a/src/com/itmill/toolkit/tests/components/label/LabelWrapping.java b/src/com/itmill/toolkit/tests/components/label/LabelWrapping.java
new file mode 100644 (file)
index 0000000..0ced6cc
--- /dev/null
@@ -0,0 +1,46 @@
+package com.itmill.toolkit.tests.components.label;\r
+\r
+import com.itmill.toolkit.tests.components.TestBase;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.HorizontalLayout;\r
+import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.Button.ClickEvent;\r
+\r
+public class LabelWrapping extends TestBase {\r
+\r
+    @Override\r
+    protected String getDescription() {\r
+        return "A label inside a limited HorizontalLayout should strive to be as wide as possible and only wrap when the size of the layout is reached. The label should look the same if it is rendered initially with the layout or updated later on.";\r
+    }\r
+\r
+    @Override\r
+    protected Integer getTicketNumber() {\r
+        return 2478;\r
+    }\r
+\r
+    @Override\r
+    protected void setup() {\r
+        HorizontalLayout hl = new HorizontalLayout();\r
+        hl.setWidth("250px");\r
+\r
+        final String longString = "this is a somewhat long string.";\r
+        final Label longLabel = new Label(longString);\r
+\r
+        Button changeLength = new Button("Change length");\r
+        changeLength.addListener(new Button.ClickListener() {\r
+            public void buttonClick(ClickEvent event) {\r
+                if (longLabel.getValue().equals(longString)) {\r
+                    longLabel.setValue("");\r
+                } else {\r
+                    longLabel.setValue(longString);\r
+                }\r
+            }\r
+        });\r
+\r
+        hl.addComponent(longLabel);\r
+        hl.addComponent(changeLength);\r
+\r
+        addComponent(hl);\r
+    }\r
+\r
+}\r