From: Matti Tahvonen Date: Thu, 20 Sep 2007 06:49:32 +0000 (+0000) Subject: removed some logic (template cannot change) and added simple "flow rendering" when... X-Git-Tag: 6.7.0.beta1~5977 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=35e3d63000b7c1b5b082279d98be36c915766a9f;p=vaadin-framework.git removed some logic (template cannot change) and added simple "flow rendering" when template file is missing svn changeset:2343/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java index 4acc843749..04f8330bc9 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java @@ -64,7 +64,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container // If no given location is found in the layout, and exception is throws Element elem = (Element) locationToElement.get(location); - if (elem == null) { + if (elem == null && hasTemplate()) { throw new IllegalArgumentException("No location " + location + " found"); } @@ -75,6 +75,10 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container if (previous == widget) return; remove(previous); + + // if template is missing add element in order + if(!hasTemplate()) + elem = getElement(); // Add widget to location super.add(widget, elem); @@ -91,8 +95,10 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container // Update PID pid = uidl.getId(); - // Update HTML template if needed - updateHTML(uidl, client); + if(!hasTemplate()) { + // Update HTML template only once + initializeHTML(uidl, client); + } // For all contained widgets for (Iterator i = uidl.getChildIterator(); i.hasNext();) { @@ -111,18 +117,15 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container } } - /** Update implementing HTML-layout if needed. */ - private void updateHTML(UIDL uidl, ApplicationConnection client) { + /** Initialize HTML-layout. */ + private void initializeHTML(UIDL uidl, ApplicationConnection client) { - // Update only if style has changed String newTemplate = uidl.getStringAttribute("template"); - if (currentTemplate != null && currentTemplate.equals(newTemplate)) - return; // Get the HTML-template from client String template = client.getResource("layouts/" + newTemplate + ".html"); if (template == null) { - template = "Layout file layouts/" + newTemplate + ".html is missing."; + template = "Layout file layouts/" + newTemplate + ".html is missing. Components will be drawn for debug purposes."; } else { currentTemplate = newTemplate; } @@ -144,6 +147,13 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container prefixImgSrcs(getElement(), "../ITK-INF/themes/" + ((IView) parent).getTheme() + "/layouts/"); } + + private boolean hasTemplate() { + if(currentTemplate == null) + return false; + else + return true; + } /** Collect locations from template */ private void scanForLocations(Element elem) {