diff options
author | Jouni Koivuviita <jouni.koivuviita@itmill.com> | 2008-04-02 07:28:01 +0000 |
---|---|---|
committer | Jouni Koivuviita <jouni.koivuviita@itmill.com> | 2008-04-02 07:28:01 +0000 |
commit | 17e1e59fdf57076e0efdc1bd158dabdbb3023dbe (patch) | |
tree | df8f0fe4a725cb9c40edf19898134396740d19d5 /src/com/itmill/toolkit/terminal | |
parent | ede743dbbef26b6d2d795034e5f0a2cfe86837b6 (diff) | |
download | vaadin-framework-17e1e59fdf57076e0efdc1bd158dabdbb3023dbe.tar.gz vaadin-framework-17e1e59fdf57076e0efdc1bd158dabdbb3023dbe.zip |
Fix: IEmbedded won't through exceptions for null-source values.
Fix: IOrderedLayout now handles component additions in between old components with captions (previously the insertion index was calculated wrong because of the caption elements were included in the index).
Small fixes to TestBench.
svn changeset:4107/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/terminal')
3 files changed, 38 insertions, 7 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java index 0bcdea61c0..d6e74fe5b3 100755 --- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java @@ -121,7 +121,7 @@ public class ApplicationConnection { initializeClientHooks(); - // TODO remove hardcoded id name + // TODO remove hard coded id name view = new IView("itmill-ajax-window"); makeUidlRequest("repaintAll=1"); @@ -758,6 +758,9 @@ public class ApplicationConnection { * @return translated URI ready for browser */ public String translateToolkitUri(String toolkitUri) { + if (toolkitUri == null) { + return null; + } if (toolkitUri.startsWith("theme://")) { final String themeUri = getThemeUri(); if (themeUri == null) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java index 09c1a2ee87..50b3c3cfe4 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java @@ -73,7 +73,11 @@ public class IEmbedded extends HTML implements Paintable { * @return */ private String getSrc(UIDL uidl, ApplicationConnection client) { - return client.translateToolkitUri(uidl.getStringAttribute("src")); + String url = client.translateToolkitUri(uidl.getStringAttribute("src")); + if (url == null) { + return ""; + } + return url; } public void setWidth(String width) { 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 0874a38e6e..851e6c5628 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java @@ -140,7 +140,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { // TODO this might be optimized by moving only container element // to correct position removeCaption(child); - int index = getWidgetIndex(oldChild); + int index = getPaintableIndex(oldChild); if (componentToCaption.containsKey(oldChild)) { index--; } @@ -148,7 +148,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { this.insert(child, index); } else { // insert new child before old one - final int index = getWidgetIndex(oldChild); + final int index = getPaintableIndex(oldChild); // TODO this returns wrong value if captions are used insert(child, index); } ((Paintable) child).updateFromUIDL(childUidl, client); @@ -215,7 +215,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { remove(c); componentToCaption.remove(c); } - final int index = getWidgetIndex(from); + final int index = getPaintableIndex(from); if (index >= 0) { remove(index); insert(to, index); @@ -240,7 +240,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { } public boolean hasChildComponent(Widget component) { - return getWidgetIndex(component) >= 0; + return getPaintableIndex(component) >= 0; } public void updateCaption(Paintable component, UIDL uidl) { @@ -249,7 +249,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { if (Caption.isNeeded(uidl)) { if (c == null) { - final int index = getWidgetIndex((Widget) component); + final int index = getPaintableIndex((Widget) component); c = new Caption(component, client); insert(c, index); componentToCaption.put(component, c); @@ -305,6 +305,30 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { return getChildren().indexOf(child); } + public int getPaintableCount() { + int size = 0; + for(Iterator it = getChildren().iterator(); it.hasNext();) { + Widget w = (Widget) it.next(); + if (!(w instanceof Caption)) { + size++; + } + } + return size; + } + + public int getPaintableIndex(Widget child) { + int i = 0; + for(Iterator it = getChildren().iterator(); it.hasNext();) { + Widget w = (Widget) it.next(); + if (w == child) { + return i; + } else if (!(w instanceof Caption)) { + i++; + } + } + return -1; + } + protected void handleMargins(UIDL uidl) { final MarginInfo margins = new MarginInfo(uidl .getIntAttribute("margins")); |