From 9cfca00027b228290d252b91e1274438f01ea140 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Fri, 31 Oct 2008 10:24:43 +0000 Subject: [PATCH] Minor fix for igridlayout svn changeset:5782/svn branch:trunk --- .../terminal/gwt/client/ui/IGridLayout.java | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java index e3ab4caa2e..0cadee9e73 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java @@ -527,6 +527,10 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { if (cc != null) { cc.updateCaption(uidl, client); } + if (!rendering) { + // ensure rel size details are updated + paintableToCell.get(component).updateRelSizeStatus(uidl); + } } public boolean requestLayout(final Set changedChildren) { @@ -673,7 +677,9 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { Cell cell = cells[i][j]; - if (cell.hasRelativeHeight() || cell.hasRelativeWidth()) { + if (cell != null + && (cell.hasRelativeHeight() || cell + .hasRelativeWidth())) { client.handleComponentRelativeSize(cell.cc.getWidget()); } } @@ -699,6 +705,9 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { * Private helper class. */ private class Cell { + private boolean relHeight = false; + private boolean relWidth = false; + public Cell(UIDL c) { row = c.getIntAttribute("y"); col = c.getIntAttribute("x"); @@ -706,13 +715,7 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { } public boolean hasRelativeHeight() { - if (childUidl != null && childUidl.hasAttribute("height")) { - String w = childUidl.getStringAttribute("height"); - if (w.contains("%")) { - return true; - } - } - return false; + return relHeight; } public RenderSpace getAllocatedSpace() { @@ -783,14 +786,8 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { } } - private boolean hasRelativeWidth() { - if (childUidl != null && childUidl.hasAttribute("width")) { - String w = childUidl.getStringAttribute("width"); - if (w.contains("%")) { - return true; - } - } - return false; + protected boolean hasRelativeWidth() { + return relWidth; } protected void render() { @@ -867,6 +864,24 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { } } childUidl = c; + updateRelSizeStatus(c); + } + + protected void updateRelSizeStatus(UIDL uidl) { + if (uidl != null && !uidl.getBooleanAttribute("cached")) { + if (uidl.hasAttribute("height") + && uidl.getStringAttribute("height").contains("%")) { + relHeight = true; + } else { + relHeight = false; + } + if (uidl.hasAttribute("width") + && uidl.getStringAttribute("width").contains("%")) { + relWidth = true; + } else { + relWidth = false; + } + } } } -- 2.39.5