]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #2662 - Form children size validation
authorArtur Signell <artur.signell@itmill.com>
Sun, 22 Feb 2009 09:45:59 +0000 (09:45 +0000)
committerArtur Signell <artur.signell@itmill.com>
Sun, 22 Feb 2009 09:45:59 +0000 (09:45 +0000)
svn changeset:6929/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java

index 523ed37cfb7b8cc2c02d47e7ade2c70d7865c238..7aeee6b10bc09bab10f464bd16895e78f0047446 100644 (file)
@@ -15,7 +15,9 @@ import com.itmill.toolkit.ui.AbstractOrderedLayout;
 import com.itmill.toolkit.ui.Component;
 import com.itmill.toolkit.ui.ComponentContainer;
 import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Form;
 import com.itmill.toolkit.ui.GridLayout;
+import com.itmill.toolkit.ui.Layout;
 import com.itmill.toolkit.ui.OrderedLayout;
 import com.itmill.toolkit.ui.Panel;
 import com.itmill.toolkit.ui.SplitPanel;
@@ -68,6 +70,14 @@ public class ComponentSizeValidator {
                 errors = validateComponentRelativeSizes((Component) it.next(),
                         errors, parent);
             }
+        } else if (component instanceof Form) {
+            Form form = (Form) component;
+            if (form.getLayout() != null)
+                errors = validateComponentRelativeSizes(form.getLayout(),
+                        errors, parent);
+            if (form.getFooter() != null)
+                errors = validateComponentRelativeSizes(form.getFooter(),
+                        errors, parent);
         }
 
         return errors;
@@ -541,9 +551,18 @@ public class ComponentSizeValidator {
                     // Other components define column width
                     return true;
                 }
+            } else if (parent instanceof Form) {
+                /*
+                 * If some other part of the form is not relative it determines
+                 * the component width
+                 */
+                return hasNonRelativeWidthComponent((Form) parent);
             } else if (parent instanceof SplitPanel
                     || parent instanceof TabSheet
                     || parent instanceof CustomComponent) {
+                // FIXME Could we use com.itmill.toolkit package name here and
+                // fail for all component containers? 
+                // FIXME Actually this should be moved to containers so it can be implemented for custom containers
                 // TODO vertical splitpanel with another non relative component?
                 return false;
             } else if (parent instanceof Window) {
@@ -573,6 +592,20 @@ public class ComponentSizeValidator {
 
     }
 
+    private static boolean hasNonRelativeWidthComponent(Form form) {
+        Layout layout = form.getLayout();
+        Layout footer = form.getFooter();
+
+        if (layout != null && !hasRelativeWidth(layout)) {
+            return true;
+        }
+        if (footer != null && !hasRelativeWidth(footer)) {
+            return true;
+        }
+
+        return false;
+    }
+
     private static Map<Object, FileLocation> creationLocations = new HashMap<Object, FileLocation>();
     private static Map<Object, FileLocation> widthLocations = new HashMap<Object, FileLocation>();
     private static Map<Object, FileLocation> heightLocations = new HashMap<Object, FileLocation>();