From: Artur Signell Date: Sun, 22 Feb 2009 09:45:59 +0000 (+0000) Subject: Fix for #2662 - Form children size validation X-Git-Tag: 6.7.0.beta1~3095 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=50999ece982e2a8941386937d210ac9e13ab72ee;p=vaadin-framework.git Fix for #2662 - Form children size validation svn changeset:6929/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java b/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java index 523ed37cfb..7aeee6b10b 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java @@ -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 creationLocations = new HashMap(); private static Map widthLocations = new HashMap(); private static Map heightLocations = new HashMap();