summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2008-12-23 07:15:05 +0000
committerArtur Signell <artur.signell@itmill.com>2008-12-23 07:15:05 +0000
commit003a2b804b9fef4693503a453789e4ac5b0cfb2a (patch)
treea934e67ce8ef708f624ed1aef1b37849df112af9 /src
parent4e2dfc48a87652b3e2f27ab295c62aba90f99424 (diff)
downloadvaadin-framework-003a2b804b9fef4693503a453789e4ac5b0cfb2a.tar.gz
vaadin-framework-003a2b804b9fef4693503a453789e4ac5b0cfb2a.zip
Test case and fix for #2405 - Dynamic height related issues in OrderedLayout and Embedded
svn changeset:6337/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java28
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java13
-rw-r--r--src/com/itmill/toolkit/tests/tickets/Ticket2405.java78
3 files changed, 111 insertions, 8 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
index 5598552dbb..dc8e9c4343 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
index 7256727cb3..a628c3f8b1 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
@@ -688,10 +688,9 @@ public class IOrderedLayout extends CellBasedLayout {
* sizes
*/
updateWidgetSizes();
- calculateContainerSize();
- /* Finally calculate new layout height */
- calculateLayoutDimensions();
+ /* Update layout dimensions based on widget sizes */
+ recalculateLayout();
}
recalculateComponentSizesAndAlignments();
@@ -780,6 +779,14 @@ public class IOrderedLayout extends CellBasedLayout {
/* Must inform child components about possible size updates */
client.runDescendentsLayout(this);
}
+ /*
+ * If the height changes as a consequence of this we must inform the
+ * parent also
+ */
+ if (isDynamicHeight() && sizeBefore.getHeight() != activeLayoutSize.getHeight()) {
+ Util.notifyParentOfSizeChange(this, false);
+ }
+
}
}
diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2405.java b/src/com/itmill/toolkit/tests/tickets/Ticket2405.java
new file mode 100644
index 0000000000..6d0ac22745
--- /dev/null
+++ b/src/com/itmill/toolkit/tests/tickets/Ticket2405.java
@@ -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);
+
+ }
+
+}