diff options
-rw-r--r-- | src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java | 19 | ||||
-rw-r--r-- | src/com/itmill/toolkit/ui/AbstractComponent.java | 27 |
2 files changed, 26 insertions, 20 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java b/src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java index d32ceae436..83f3de331c 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java @@ -32,12 +32,7 @@ public class DebugUtilities { public static boolean validateComponentRelativeSizes(Component component, boolean recursive) { - boolean valid = true; - - if (!(component instanceof Window)) { - valid = valid && checkWidths(component); - valid = valid && checkHeights(component); - } + boolean valid = checkWidths(component) && checkHeights(component); if (recursive) { if (component instanceof Panel) { @@ -86,7 +81,11 @@ public class DebugUtilities { } - private static boolean checkHeights(Component component) { + public static boolean checkHeights(Component component) { + if (component instanceof Window) { + return true; + } + Component parent = component.getParent(); String msg = null; Stack<ComponentInfo> attributes = null; @@ -146,7 +145,11 @@ public class DebugUtilities { } - private static boolean checkWidths(Component component) { + public static boolean checkWidths(Component component) { + if (component instanceof Window) { + return true; + } + Component parent = component.getParent(); String msg = null; Stack<ComponentInfo> attributes = null; diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java index 48717c4bc2..5a692736e7 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponent.java +++ b/src/com/itmill/toolkit/ui/AbstractComponent.java @@ -609,20 +609,23 @@ public abstract class AbstractComponent implements Component, MethodEventSource // Only paint content of visible components. if (isVisible()) { + boolean validHeight = true; + boolean validWidth = true; - // TODO split this method - if (getApplication() != null - && getApplication().isDebugMode() - && !DebugUtilities.validateComponentRelativeSizes(this, - false)) { + if (getApplication() != null && getApplication().isDebugMode()) { + validHeight = DebugUtilities.checkHeights(this); + validWidth = DebugUtilities.checkWidths(this); + } + if (!validHeight || !validWidth) { addStyleName("invalidlayout"); - } else { - if (getHeight() >= 0) { - target.addAttribute("height", "" + getCSSHeight()); - } - if (getWidth() >= 0) { - target.addAttribute("width", "" + getCSSWidth()); - } + } + + if (validHeight && getHeight() >= 0) { + target.addAttribute("height", "" + getCSSHeight()); + } + + if (validWidth && getWidth() >= 0) { + target.addAttribute("width", "" + getCSSWidth()); } if (styles != null && styles.size() > 0) { target.addAttribute("style", getStyle()); |