summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-09-07 10:16:25 +0000
committerLeif Åstrand <leif@vaadin.com>2011-09-07 10:16:25 +0000
commitf65e90d979d1ebacbef35d058b0bbf8e0349d0e3 (patch)
treef56fc04c777906418099bc93bebfab049abd3ac0
parent841e99e80fc6edd9059c66e5fee72c7e11c21b05 (diff)
downloadvaadin-framework-f65e90d979d1ebacbef35d058b0bbf8e0349d0e3.tar.gz
vaadin-framework-f65e90d979d1ebacbef35d058b0bbf8e0349d0e3.zip
#7326 Width recalculation does not work for GridLayout inside CustomComponent
svn changeset:20901/svn branch:6.7
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java9
-rw-r--r--tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.html32
-rw-r--r--tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.java42
3 files changed, 83 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java b/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java
index 35ed2c5fed..a95f399855 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java
@@ -123,6 +123,15 @@ public class VCustomComponent extends SimplePanel implements Container {
}
public boolean requestLayout(Set<Paintable> child) {
+ // If a child grows in size, it will not necessarily be calculated
+ // correctly unless we remove previous size definitions
+ if (isDynamicWidth()) {
+ getElement().getStyle().setProperty("width", "");
+ }
+ if (isDynamicHeight()) {
+ getElement().getStyle().setProperty("width", "");
+ }
+
return !updateDynamicSize();
}
diff --git a/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.html b/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.html
new file mode 100644
index 0000000000..8687057e64
--- /dev/null
+++ b/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.html
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.layouts.CustomComponentWithGridLayout?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestslayoutsCustomComponentWithGridLayout::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.java b/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.java
new file mode 100644
index 0000000000..9a559f7414
--- /dev/null
+++ b/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.java
@@ -0,0 +1,42 @@
+package com.vaadin.tests.components.customcomponent;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+
+public class CustomComponentGrowingContent extends TestBase {
+ @Override
+ protected void setup() {
+ final Label label = new Label("Short content");
+ label.setWidth(null);
+
+ addComponent(new CustomComponent() {
+ {
+ GridLayout mainLayout = new GridLayout(1, 1);
+ mainLayout.addComponent(label);
+ mainLayout.setSizeUndefined();
+ setSizeUndefined();
+ setCompositionRoot(mainLayout);
+ }
+ });
+
+ addComponent(new Button("Set long content", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ label.setValue("Longer content that should be fully visible");
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The width of the custom component should increase when its content grows";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(7326);
+ }
+} \ No newline at end of file