From 1dd08efcc3774906fba450cdcee446a400edbc8e Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 7 Aug 2007 12:44:36 +0000 Subject: [PATCH] Still some modifications to get make captions work. svn changeset:1963/svn branch:trunk --- .../gwt/client/ui/IVerticalLayout.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java index b22e94cf21..ab002dfe28 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java @@ -31,7 +31,6 @@ public class IVerticalLayout extends VerticalPanel implements Paintable, Layout for (Iterator it = uidl.getChildIterator(); it.hasNext();) { UIDL uidlForChild = (UIDL) it.next(); Widget child = client.getWidget(uidlForChild); - ((Paintable)child).updateFromUIDL(uidlForChild, client); uidlWidgets.add(child); } @@ -39,10 +38,12 @@ public class IVerticalLayout extends VerticalPanel implements Paintable, Layout Iterator oldIt = oldWidgets.iterator(); Iterator newIt = uidlWidgets.iterator(); + Iterator newUidl = uidl.getChildIterator(); Widget oldChild = null; while(newIt.hasNext()) { Widget child = (Widget) newIt.next(); + UIDL childUidl = (UIDL) newUidl.next(); if(oldChild == null && oldIt.hasNext()) { // search for next old Paintable which still exists in layout // and delete others @@ -60,17 +61,19 @@ public class IVerticalLayout extends VerticalPanel implements Paintable, Layout if(oldChild == null) { // we are adding components to layout add(child); - continue; - } - if(child == oldChild) { + } else if(child == oldChild) { // child already attached and updated oldChild = null; - continue; - } - if(hasChildComponent(child)) { - // current child has been moved - this.insert(child, getWidgetIndex(oldChild)); + } else if(hasChildComponent(child)) { + // current child has been moved, re-insert before current oldChild + removeCaption(child); + int index = getWidgetIndex(oldChild); + if(componentToCaption.containsKey(oldChild)) + index--; + this.insert(child, index); } + ((Paintable)child).updateFromUIDL(childUidl, client); + } // remove possibly remaining old Paintable object which were not updated while(oldIt.hasNext()) { @@ -146,6 +149,12 @@ public class IVerticalLayout extends VerticalPanel implements Paintable, Layout } } + public void removeCaption(Widget w) { + Caption c = (Caption) componentToCaption.get(w); + if(c != null) { + this.remove(c); + componentToCaption.remove(w); + } + } - } -- 2.39.5