From 8bd73e9e9f732758fbfd0c2ead2b3a0aad3d6d23 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 2 Dec 2008 10:04:01 +0000 Subject: [PATCH] Fixed FormLayout handling of relative sized fields svn changeset:6065/svn branch:trunk --- .../terminal/gwt/client/ui/IFormLayout.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java index 05b42e89cf..fd8abd0dd2 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java @@ -45,8 +45,8 @@ public class IFormLayout extends SimplePanel implements Container { public class IFormLayoutTable extends FlexTable { - private HashMap componentToCaption = new HashMap(); - private HashMap componentToError = new HashMap(); + private HashMap componentToCaption = new HashMap(); + private HashMap componentToError = new HashMap(); public IFormLayoutTable() { DOM.setElementProperty(getElement(), "cellPadding", "0"); @@ -76,12 +76,12 @@ public class IFormLayout extends SimplePanel implements Container { prepareCell(i, 1); final UIDL childUidl = (UIDL) it.next(); final Paintable p = client.getPaintable(childUidl); - Caption caption = (Caption) componentToCaption.get(p); + Caption caption = componentToCaption.get(p); if (caption == null) { caption = new Caption(p, client); componentToCaption.put(p, caption); } - ErrorFlag error = (ErrorFlag) componentToError.get(p); + ErrorFlag error = componentToError.get(p); if (error == null) { error = new ErrorFlag(); componentToError.put(p, error); @@ -124,6 +124,13 @@ public class IFormLayout extends SimplePanel implements Container { removeRow(i); } + /* + * Must update relative sized fields last when it is clear how much + * space they are allowed to use + */ + for (Paintable p : componentToCaption.keySet()) { + client.handleComponentRelativeSize((Widget) p); + } } public void replaceChildComponent(Widget oldComponent, @@ -146,11 +153,11 @@ public class IFormLayout extends SimplePanel implements Container { } public void updateCaption(Paintable component, UIDL uidl) { - final Caption c = (Caption) componentToCaption.get(component); + final Caption c = componentToCaption.get(component); if (c != null) { c.updateCaption(uidl); } - final ErrorFlag e = (ErrorFlag) componentToError.get(component); + final ErrorFlag e = componentToError.get(component); if (e != null) { e.updateFromUIDL(uidl, component); } @@ -158,8 +165,8 @@ public class IFormLayout extends SimplePanel implements Container { } public int getAllocatedWidth(Widget child, int availableWidth) { - Caption caption = (Caption) componentToCaption.get(child); - ErrorFlag error = (ErrorFlag) componentToError.get(child); + Caption caption = componentToCaption.get(child); + ErrorFlag error = componentToError.get(child); int width = availableWidth; if (caption != null) { -- 2.39.5