diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-12-15 06:26:31 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-12-15 06:26:31 +0000 |
commit | 422543e2492bad6766bba1578f2913f505b296a0 (patch) | |
tree | 4ce0e94fc34df35690958c0e110cc9278b65ee57 /src/com/itmill/toolkit/terminal/gwt/server | |
parent | 0c013cb8370717d42b13345f71071fda3ee8c115 (diff) | |
download | vaadin-framework-422543e2492bad6766bba1578f2913f505b296a0.tar.gz vaadin-framework-422543e2492bad6766bba1578f2913f505b296a0.zip |
added try catch block to rel size checks to avoid total crash in paint method, see #2338
svn changeset:6206/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/terminal/gwt/server')
-rw-r--r-- | src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java | 203 |
1 files changed, 106 insertions, 97 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java b/src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java index 471f48f923..ce70dea3d1 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/DebugUtilities.java @@ -82,133 +82,142 @@ public class DebugUtilities { } public static boolean checkHeights(Component component) { - if (component instanceof Window) { - return true; - } - - Component parent = component.getParent(); String msg = null; - Stack<ComponentInfo> attributes = null; + try { + if (component instanceof Window) { + return true; + } + + Component parent = component.getParent(); + Stack<ComponentInfo> attributes = null; - if (hasRelativeHeight(component) && hasUndefinedHeight(parent)) { - if (parent instanceof AbstractOrderedLayout) { - AbstractOrderedLayout ol = (AbstractOrderedLayout) parent; - boolean vertical = false; + if (hasRelativeHeight(component) && hasUndefinedHeight(parent)) { + if (parent instanceof AbstractOrderedLayout) { + AbstractOrderedLayout ol = (AbstractOrderedLayout) parent; + boolean vertical = false; - if (ol instanceof OrderedLayout) { - if (((OrderedLayout) ol).getOrientation() == OrderedLayout.ORIENTATION_VERTICAL) { + if (ol instanceof OrderedLayout) { + if (((OrderedLayout) ol).getOrientation() == OrderedLayout.ORIENTATION_VERTICAL) { + vertical = true; + } + } else if (ol instanceof VerticalLayout) { vertical = true; } - } else if (ol instanceof VerticalLayout) { - vertical = true; - } - if (vertical) { - msg = "Relative height for component inside non sized vertical ordered layout."; - attributes = getHeightAttributes(component); - } else if (!hasNonRelativeHeightComponent(ol)) { - msg = "At least one of horizontal orderedlayout's components must have non relative height if layout has no height defined"; - attributes = getHeightAttributes(component); - } else { - // valid situation, other components defined height - } - } else if (parent instanceof GridLayout) { - - GridLayout gl = (GridLayout) parent; - Area componentArea = gl.getComponentArea(component); - boolean rowHasHeight = false; - for (int row = componentArea.getRow1(); !rowHasHeight - && row <= componentArea.getRow2(); row++) { - for (int column = 0; !rowHasHeight - && column < gl.getColumns(); column++) { - Component c = gl.getComponent(column, row); - if (c != null) { - rowHasHeight = !hasRelativeHeight(c); + if (vertical) { + msg = "Relative height for component inside non sized vertical ordered layout."; + attributes = getHeightAttributes(component); + } else if (!hasNonRelativeHeightComponent(ol)) { + msg = "At least one of horizontal orderedlayout's components must have non relative height if layout has no height defined"; + attributes = getHeightAttributes(component); + } else { + // valid situation, other components defined height + } + } else if (parent instanceof GridLayout) { + + GridLayout gl = (GridLayout) parent; + Area componentArea = gl.getComponentArea(component); + boolean rowHasHeight = false; + for (int row = componentArea.getRow1(); !rowHasHeight + && row <= componentArea.getRow2(); row++) { + for (int column = 0; !rowHasHeight + && column < gl.getColumns(); column++) { + Component c = gl.getComponent(column, row); + if (c != null) { + rowHasHeight = !hasRelativeHeight(c); + } } } - } - if (!rowHasHeight) { - msg = "At least one component in each row should have non relative height in GridLayout with undefined height."; + if (!rowHasHeight) { + msg = "At least one component in each row should have non relative height in GridLayout with undefined height."; + attributes = getHeightAttributes(component); + } + } else if (!(parent instanceof CustomLayout)) { + // default error for non sized parent issue + msg = "Relative height component's parent should not have undefined height."; attributes = getHeightAttributes(component); } - } else if (!(parent instanceof CustomLayout)) { - // default error for non sized parent issue - msg = "Relative height component's parent should not have undefined height."; - attributes = getHeightAttributes(component); } - } - if (msg != null) { - showError(msg, attributes, false); + if (msg != null) { + showError(msg, attributes, false); + } + } catch (Exception e) { + e.printStackTrace(); } return (msg == null); - } public static boolean checkWidths(Component component) { - if (component instanceof Window) { - return true; - } - - Component parent = component.getParent(); String msg = null; - Stack<ComponentInfo> attributes = null; + try { + if (component instanceof Window) { + return true; + } + + Component parent = component.getParent(); + Stack<ComponentInfo> attributes = null; - if (hasRelativeWidth(component) && hasUndefinedWidth(parent)) { - if (parent instanceof AbstractOrderedLayout) { - AbstractOrderedLayout ol = (AbstractOrderedLayout) parent; - boolean horizontal = true; + if (hasRelativeWidth(component) && hasUndefinedWidth(parent)) { + if (parent instanceof AbstractOrderedLayout) { + AbstractOrderedLayout ol = (AbstractOrderedLayout) parent; + boolean horizontal = true; - if (ol instanceof OrderedLayout) { - if (((OrderedLayout) ol).getOrientation() == OrderedLayout.ORIENTATION_VERTICAL) { + if (ol instanceof OrderedLayout) { + if (((OrderedLayout) ol).getOrientation() == OrderedLayout.ORIENTATION_VERTICAL) { + horizontal = false; + } + } else if (ol instanceof VerticalLayout) { horizontal = false; } - } else if (ol instanceof VerticalLayout) { - horizontal = false; - } - if (horizontal) { - msg = "Relative width for component inside non sized horizontal ordered layout."; - attributes = getWidthAttributes(component); - } else if (!hasNonRelativeWidthComponent(ol)) { - msg = "At least one of vertical orderedlayout's components must have non relative width if layout has no width defined"; - attributes = getWidthAttributes(component); - } else { - // valid situation, other components defined width - } - } else if (parent instanceof GridLayout) { - GridLayout gl = (GridLayout) parent; - Area componentArea = gl.getComponentArea(component); - boolean columnHasWidth = false; - for (int col = componentArea.getColumn1(); !columnHasWidth - && col <= componentArea.getColumn2(); col++) { - for (int row = 0; !columnHasWidth && row < gl.getRows(); row++) { - Component c = gl.getComponent(col, row); - if (c != null) { - columnHasWidth = !hasRelativeWidth(c); + if (horizontal) { + msg = "Relative width for component inside non sized horizontal ordered layout."; + attributes = getWidthAttributes(component); + } else if (!hasNonRelativeWidthComponent(ol)) { + msg = "At least one of vertical orderedlayout's components must have non relative width if layout has no width defined"; + attributes = getWidthAttributes(component); + } else { + // valid situation, other components defined width + } + } else if (parent instanceof GridLayout) { + GridLayout gl = (GridLayout) parent; + Area componentArea = gl.getComponentArea(component); + boolean columnHasWidth = false; + for (int col = componentArea.getColumn1(); !columnHasWidth + && col <= componentArea.getColumn2(); col++) { + for (int row = 0; !columnHasWidth && row < gl.getRows(); row++) { + Component c = gl.getComponent(col, row); + if (c != null) { + columnHasWidth = !hasRelativeWidth(c); + } } } - } - if (!columnHasWidth) { - msg = "At least one component in each column should have non relative width in GridLayout with undefined width."; - attributes = getWidthAttributes(component); - } + if (!columnHasWidth) { + msg = "At least one component in each column should have non relative width in GridLayout with undefined width."; + attributes = getWidthAttributes(component); + } - } else if (!(parent instanceof CustomLayout)) { - // CustomLayout's and Panels are omitted. Width can be defined - // by layout or by caption in Window - if (!(parent instanceof Panel && parent.getCaption() != null && !parent - .getCaption().equals(""))) { - // default error for non sized parent issue - msg = "Relative width component's parent should not have undefined width."; - attributes = getWidthAttributes(component); + } else if (!(parent instanceof CustomLayout)) { + // CustomLayout's and Panels are omitted. Width can be + // defined + // by layout or by caption in Window + if (!(parent instanceof Panel + && parent.getCaption() != null && !parent + .getCaption().equals(""))) { + // default error for non sized parent issue + msg = "Relative width component's parent should not have undefined width."; + attributes = getWidthAttributes(component); + } } } - } - if (msg != null) { - showError(msg, attributes, true); + if (msg != null) { + showError(msg, attributes, true); + } + } catch (Exception e) { + e.printStackTrace(); } return (msg == null); |