]> source.dussan.org Git - vaadin-framework.git/commitdiff
#8852 Applied Sami's patch with minor changes to comments and the test
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>
Thu, 14 Jun 2012 13:11:37 +0000 (13:11 +0000)
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>
Thu, 14 Jun 2012 13:11:37 +0000 (13:11 +0000)
svn changeset:23938/svn branch:6.8

src/com/vaadin/terminal/gwt/client/ui/VForm.java
src/com/vaadin/terminal/gwt/client/ui/VWindow.java
tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html [new file with mode: 0644]
tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java [new file with mode: 0644]

index c0a6e5b275a734ba10adecc15c5bbc3511571aee..546f90a39b250a32286ad7d5880109b64e46516b 100644 (file)
@@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.client.ui;
 
 import java.util.Set;
 
-import com.google.gwt.dom.client.Style.Display;
 import com.google.gwt.event.dom.client.KeyDownEvent;
 import com.google.gwt.event.dom.client.KeyDownHandler;
 import com.google.gwt.event.shared.HandlerRegistration;
@@ -39,7 +38,6 @@ public class VForm extends ComplexPanel implements Container, KeyDownHandler {
     private Container lo;
     private Element legend = DOM.createLegend();
     private Element caption = DOM.createSpan();
-    private Element errorIndicatorElement = DOM.createDiv();
     private Element desc = DOM.createDiv();
     private Icon icon;
     private VErrorMessage errorMessage = new VErrorMessage();
@@ -70,9 +68,6 @@ public class VForm extends ComplexPanel implements Container, KeyDownHandler {
         setStyleName(CLASSNAME);
         fieldSet.appendChild(legend);
         legend.appendChild(caption);
-        errorIndicatorElement.setClassName("v-errorindicator");
-        errorIndicatorElement.getStyle().setDisplay(Display.NONE);
-        errorIndicatorElement.setInnerText(" "); // needed for IE
         desc.setClassName("v-form-description");
         fieldSet.appendChild(desc); // Adding description for initial padding
                                     // measurements, removed later if no
index 2355a9c65a1808d989b7bee52fca717297a97f12..2384ee7ddd07fbac2838d6e70c148fa2934e30f6 100644 (file)
@@ -390,6 +390,17 @@ public class VWindow extends VOverlay implements Container,
         layoutRelativeWidth = uidl.hasAttribute("layoutRelativeWidth");
         layoutRelativeHeight = uidl.hasAttribute("layoutRelativeHeight");
 
+        // Ticket #8852: We have to override min height if height of both window
+        // and layout have undefined height. 0 is used to as undefined value and
+        // replacing it with 30 will lead to calculation errors (as browser
+        // takes care of height modifications).
+        if (dynamicHeight && !layoutRelativeHeight
+                && !childUidl.hasAttribute("height")) {
+            renderSpace.setHeight(0);
+        } else if (renderSpace.getHeight() < MIN_CONTENT_AREA_HEIGHT) {
+            renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT);
+        }
+
         if (dynamicWidth && layoutRelativeWidth) {
             /*
              * Relative layout width, fix window width before rendering (width
@@ -1161,12 +1172,17 @@ public class VWindow extends VOverlay implements Container,
             return;
         }
         if (height == null || "".equals(height)) {
+
             getElement().getStyle().clearHeight();
             contentPanel.getElement().getStyle().clearHeight();
-            // Reset to default, the exact value does not actually
-            // matter as an undefined-height parent should not have
-            // a relative-height child anyway.
-            renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT);
+
+            // If content and window both have undefined height do not set min
+            // height to render space
+            if (renderSpace.getHeight() != 0 || !dynamicHeight
+                    || layoutRelativeHeight) {
+                renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT);
+            }
+
         } else {
             getElement().getStyle().setProperty("height", height);
             int contentHeight = getElement().getOffsetHeight()
diff --git a/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html
new file mode 100644 (file)
index 0000000..a3b56cd
--- /dev/null
@@ -0,0 +1,57 @@
+<?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>UndefinedHeightSubWindowAndContent</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">UndefinedHeightSubWindowAndContent</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.window.UndefinedHeightSubWindowAndContent?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+       <td>52,11</td>
+</tr>
+<tr>
+       <td>enterCharacter</td>
+       <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+       <td>invalid</td>
+</tr>
+<tr>
+       <td>pressSpecialKey</td>
+       <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+       <td>enter</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>form_full_width_1_error</td>
+</tr>
+<tr>
+       <td>enterCharacter</td>
+       <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+       <td>valid</td>
+</tr>
+<tr>
+       <td>pressSpecialKey</td>
+       <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+       <td>enter</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>form_full_width_2_valid</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java
new file mode 100644 (file)
index 0000000..ed259b2
--- /dev/null
@@ -0,0 +1,58 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.data.Validator;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class UndefinedHeightSubWindowAndContent extends TestBase {
+
+    @Override
+    protected void setup() {
+        Window subWindow = new Window("No scrollbars!");
+        subWindow.setWidth("300px");
+        subWindow.center();
+        subWindow.setModal(true);
+        VerticalLayout layout = new VerticalLayout();
+        layout.setWidth("100%");
+        subWindow.setContent(layout);
+
+        final Form form = new Form();
+        form.setImmediate(true);
+        form.setValidationVisible(true);
+        form.setCaption("This is a form");
+        form.setDescription("How do you do?");
+        final TextField field1 = new TextField("Write here");
+        field1.setImmediate(true);
+        field1.addValidator(new Validator() {
+
+            public void validate(Object value) throws InvalidValueException {
+                if (!isValid(value)) {
+                    throw new InvalidValueException("FAIL!");
+                }
+            }
+
+            public boolean isValid(Object value) {
+                return field1.getValue().equals("valid");
+            }
+        });
+        form.addField("Field 1", field1);
+        layout.addComponent(form);
+
+        getMainWindow().addWindow(subWindow);
+        subWindow.bringToFront();
+    }
+
+    @Override
+    protected String getDescription() {
+        return "When both window and its content have undefined height, window must not reserve space for a scroll bar when it is not needed.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 8852;
+    }
+
+}