diff options
author | Denis Anisimov <denis@vaadin.com> | 2016-09-21 10:41:28 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-09-22 12:55:13 +0000 |
commit | f12fbfb7044defc8442d05e6810c43875c04710c (patch) | |
tree | 26b47b9ddb48da84001ebb582a34acff5ef0042c /server/src | |
parent | ab1fd8a7be62a2381d2aa8c5434db9c39acaad9d (diff) | |
download | vaadin-framework-f12fbfb7044defc8442d05e6810c43875c04710c.tar.gz vaadin-framework-f12fbfb7044defc8442d05e6810c43875c04710c.zip |
Re-add back Form to compatibility package (#296).
Change-Id: Id187402e78e3c368ae6530f7b7ea68d2e6c4a6ca
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/main/java/com/vaadin/server/ComponentSizeValidator.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java index 241aea2078..fa3b269fae 100644 --- a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java +++ b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java @@ -36,6 +36,7 @@ import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.GridLayout.Area; +import com.vaadin.ui.HasComponents; import com.vaadin.ui.Panel; import com.vaadin.ui.TabSheet; import com.vaadin.ui.UI; @@ -89,11 +90,39 @@ public class ComponentSizeValidator implements Serializable { errors = validateComponentRelativeSizes(it.next(), errors, parent); } + } else if (isForm(component)) { + HasComponents form = (HasComponents) component; + for (Iterator<Component> iterator = form.iterator(); iterator + .hasNext();) { + Component child = iterator.next(); + errors = validateComponentRelativeSizes(child, errors, parent); + } } return errors; } + /** + * Comparability form component which is defined in the different jar. + * + * TODO : Normally this logic shouldn't be here. But it means that the whole + * this class has wrong design and impementation and should be refactored. + */ + private static boolean isForm(Component component) { + if (!(component instanceof HasComponents)) { + return false; + } + Class<?> clazz = component.getClass(); + while (clazz != null) { + if (component.getClass().getName() + .equals("com.vaadin.v7.ui.Form")) { + return true; + } + clazz = clazz.getSuperclass(); + } + return false; + } + private static void printServerError(String msg, Stack<ComponentInfo> attributes, boolean widthError, PrintStream errorStream) { @@ -448,6 +477,12 @@ public class ComponentSizeValidator implements Serializable { // Other components define row height return true; } + } else if (isForm(parent)) { + /* + * If some other part of the form is not relative it determines + * the component width + */ + return formHasNonRelativeWidthComponent(parent); } if (parent instanceof Panel || parent instanceof AbstractSplitPanel @@ -477,6 +512,24 @@ public class ComponentSizeValidator implements Serializable { } } + /** + * Comparability form component which is defined in the different jar. + * + * TODO : Normally this logic shouldn't be here. But it means that the whole + * this class has wrong design and impementation and should be refactored. + */ + private static boolean formHasNonRelativeWidthComponent(Component form) { + HasComponents parent = (HasComponents) form; + for (Iterator<Component> iterator = parent.iterator(); iterator + .hasNext();) { + if (!hasRelativeWidth(iterator.next())) { + return true; + } + } + + return false; + } + private static boolean hasRelativeHeight(Component component) { return (component.getHeightUnits() == Unit.PERCENTAGE && component.getHeight() > 0); |