From 218dd33abb35e167ef0e05829ba6a6dec6a07f95 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 20 Oct 2008 10:01:58 +0000 Subject: [PATCH] Fixed relative size related OrderedLayout problem svn changeset:5673/svn branch:trunk --- .../toolkit/terminal/gwt/client/Util.java | 41 +++++++++++++------ .../gwt/client/ui/IOrderedLayout.java | 13 +++--- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Util.java b/src/com/itmill/toolkit/terminal/gwt/client/Util.java index 64ff918a12..69b62ede74 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/Util.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/Util.java @@ -290,24 +290,41 @@ public class Util { } + /** + * Parses the UIDL parameter and fetches the relative size of the component. + * If a dimension is not specified as relative it will return -1. If the + * UIDL does not contain width or height specifications this will return + * null. + * + * @param uidl + * @return + */ public static FloatSize parseRelativeSize(UIDL uidl) { - String w = uidl.hasAttribute("width") ? uidl - .getStringAttribute("width") : ""; + boolean hasAttribute = false; + String w = ""; + String h = ""; + if (uidl.hasAttribute("width")) { + hasAttribute = true; + w = uidl.getStringAttribute("width"); + } + if (uidl.hasAttribute("height")) { + hasAttribute = true; + h = uidl.getStringAttribute("height"); + } - String h = uidl.hasAttribute("height") ? uidl - .getStringAttribute("height") : ""; + if (!hasAttribute) { + return null; + } float relativeWidth = Util.parseRelativeSize(w); float relativeHeight = Util.parseRelativeSize(h); - if (relativeHeight >= 0.0 || relativeWidth >= 0.0) { - // One or both is relative - FloatSize relativeSize = new FloatSize(relativeWidth, - relativeHeight); - return relativeSize; - } else { - return null; - } + FloatSize relativeSize = new FloatSize(relativeWidth, relativeHeight); + return relativeSize; + + } + public static boolean isCached(UIDL uidl) { + return uidl.getBooleanAttribute("cached"); } } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java index 5a8fd0f1df..1cdc5ff760 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java @@ -31,9 +31,6 @@ public class IOrderedLayout extends CellBasedLayout { */ private Size activeLayoutSize = new Size(0, 0); - // private int spaceForExpansion = 0; - private int spaceNobodyWantedToUse = 0; - private boolean isRendering = false; @Override @@ -100,10 +97,12 @@ public class IOrderedLayout extends CellBasedLayout { * the layout are rendered later when it is clear how much space * they can use */ - FloatSize relativeSize = Util.parseRelativeSize(childUIDL); - childComponentContainer.setRelativeSize(relativeSize); + if (!Util.isCached(childUIDL)) { + FloatSize relativeSize = Util.parseRelativeSize(childUIDL); + childComponentContainer.setRelativeSize(relativeSize); + } - if (hasRelativeSize(relativeSize, orientation)) { + if (childComponentContainer.isComponentRelativeSized(orientation)) { relativeSizeComponents.add(childComponentContainer); relativeSizeComponentUIDL.add(childUIDL); relativeSizeWidgets.add(widget); @@ -330,6 +329,8 @@ public class IOrderedLayout extends CellBasedLayout { remainingSpace = 0; } + // ApplicationConnection.getConsole().log( + // "Layout size: " + activeLayoutSize); return remainingSpace; } -- 2.39.5