]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test case and fix for #2405 - Dynamic height related issues in OrderedLayout and...
authorArtur Signell <artur.signell@itmill.com>
Tue, 23 Dec 2008 07:15:05 +0000 (07:15 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 23 Dec 2008 07:15:05 +0000 (07:15 +0000)
svn changeset:6337/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
src/com/itmill/toolkit/tests/tickets/Ticket2405.java [new file with mode: 0644]

index 5598552dbbe7dd53a598dfc5275425b6ce36c441..dc8e9c434395d63b1b9abc0344eb5700af952c18 100644 (file)
@@ -16,7 +16,7 @@ import com.itmill.toolkit.terminal.gwt.client.Util;
 public class IEmbedded extends HTML implements Paintable {
     private static String CLASSNAME = "i-embedded";
 
-    private String heigth;
+    private String height;
     private String width;
     private Element browserElement;
 
@@ -76,11 +76,11 @@ public class IEmbedded extends HTML implements Paintable {
         } else if (uidl.hasAttribute("mimetype")) {
             final String mime = uidl.getStringAttribute("mimetype");
             if (mime.equals("application/x-shockwave-flash")) {
-                setHTML("<object width=\"" + width + "\" height=\"" + heigth
+                setHTML("<object width=\"" + width + "\" height=\"" + height
                         + "\"><param name=\"movie\" value=\""
                         + getSrc(uidl, client) + "\"><embed src=\""
                         + getSrc(uidl, client) + "\" width=\"" + width
-                        + "\" height=\"" + heigth + "\"></embed></object>");
+                        + "\" height=\"" + height + "\"></embed></object>");
             } else {
                 ApplicationConnection.getConsole().log(
                         "Unknown Embedded mimetype '" + mime + "'");
@@ -113,11 +113,29 @@ public class IEmbedded extends HTML implements Paintable {
 
     public void setWidth(String width) {
         this.width = width;
-        super.setWidth(width);
+        if (isDynamicHeight()) {
+            int oldHeight = getOffsetHeight();
+            super.setWidth(width);
+            int newHeight = getOffsetHeight();
+            /*
+             * Must notify parent if the height changes as a result of a width
+             * change
+             */
+            if (oldHeight != newHeight) {
+                Util.notifyParentOfSizeChange(this, false);
+            }
+        } else {
+            super.setWidth(width);
+        }
+
+    }
+
+    private boolean isDynamicHeight() {
+        return height == null || height.equals("");
     }
 
     public void setHeight(String height) {
-        heigth = height;
+        this.height = height;
         super.setHeight(height);
     }
 
index 7256727cb3adab75e667a00a994965d281189244..a628c3f8b1bc25ab00f6ac3fdd0e7d166ec2f12c 100644 (file)
@@ -688,10 +688,9 @@ public class IOrderedLayout extends CellBasedLayout {
              * sizes\r
              */\r
             updateWidgetSizes();\r
-            calculateContainerSize();\r
 \r
-            /* Finally calculate new layout height */\r
-            calculateLayoutDimensions();\r
+            /* Update layout dimensions based on widget sizes */\r
+            recalculateLayout();\r
         }\r
 \r
         recalculateComponentSizesAndAlignments();\r
@@ -780,6 +779,14 @@ public class IOrderedLayout extends CellBasedLayout {
                 /* Must inform child components about possible size updates */\r
                 client.runDescendentsLayout(this);\r
             }\r
+            /*\r
+             * If the height changes as a consequence of this we must inform the\r
+             * parent also\r
+             */\r
+            if (isDynamicHeight() && sizeBefore.getHeight() != activeLayoutSize.getHeight()) {\r
+                Util.notifyParentOfSizeChange(this, false);\r
+            }\r
+\r
         }\r
     }\r
 \r
diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2405.java b/src/com/itmill/toolkit/tests/tickets/Ticket2405.java
new file mode 100644 (file)
index 0000000..6d0ac22
--- /dev/null
@@ -0,0 +1,78 @@
+package com.itmill.toolkit.tests.tickets;
+
+import com.itmill.toolkit.Application;
+import com.itmill.toolkit.terminal.ExternalResource;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.Embedded;
+import com.itmill.toolkit.ui.HorizontalLayout;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.SplitPanel;
+import com.itmill.toolkit.ui.TextField;
+import com.itmill.toolkit.ui.VerticalLayout;
+import com.itmill.toolkit.ui.Window;
+
+public class Ticket2405 extends Application {
+
+    private Label label;
+    private SplitPanel split;
+
+    @Override
+    public void init() {
+
+        final Window root = new Window("ToolkitTunes");
+        root.setWidth("90%");
+        root.setHeight("90%");
+        root.center();
+
+        // We'll attach the window to the browser view already here, so we won't
+        // forget it later.
+        // browser.addWindow(root);
+        setMainWindow(root);
+
+        root.getLayout().setSizeFull();
+        root.getLayout().setMargin(false);
+
+        // Top area, containing playback and volume controls, play status, view
+        // modes and search
+        HorizontalLayout top = new HorizontalLayout();
+        // GridLayout top = new GridLayout(1, 1);
+        top.setWidth("100%");
+        top.setMargin(false);
+        top.setSpacing(false);
+
+        // Let's attach that one straight away too
+        root.addComponent(top);
+
+        label = new Label(
+                "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent porttitor porta lacus. Nulla tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin mollis turpis in mauris faucibus posuere. Nullam rutrum, nisi a fermentum tempus, lacus metus rutrum massa, a condimentum mauris justo a tortor. Mauris aliquet, ante quis ultricies posuere, sapien libero laoreet sem, a accumsan diam metus sed elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Curabitur vehicula metus nec turpis dignissim cursus. Suspendisse potenti. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam feugiat orci eget risus. Vestibulum at sem. ");
+        label.setWidth("100%");
+        top.addComponent(label);
+        split = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
+        split.setHeight("100%");
+        Embedded image = new Embedded("An image", new ExternalResource(
+                "http://dev.itmill.com/chrome/site/toolkit-logo.png"));
+        image.setWidth("100%");
+        root.addComponent(split);
+        ((VerticalLayout) root.getLayout()).setExpandRatio(split, 1.0f);
+        VerticalLayout vl = new VerticalLayout();
+        split.addComponent(vl);
+
+        vl.addComponent(new TextField("abc"));
+        vl.addComponent(image);
+        vl.setExpandRatio(image, 1.0f);
+        vl.setComponentAlignment(image, "bottom center");
+        vl.setHeight("100%");
+        // We'll need one splitpanel to separate the sidebar and track listing
+        Button bottomButton = new Button("Filler");
+        bottomButton.setSizeFull();
+        // root.addComponent(bottomButton);
+
+        // The splitpanel is by default 100% x 100%, but we'll need to adjust
+        // our main window layout to accomodate the height
+        root.getLayout().setHeight("100%");
+        // ((VerticalLayout) root.getLayout()).setExpandRatio(bottomButton,
+        // 1.0F);
+
+    }
+
+}