]> source.dussan.org Git - vaadin-framework.git/commitdiff
Label supports now multiple content modes
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Thu, 14 Jun 2007 13:54:02 +0000 (13:54 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Thu, 14 Jun 2007 13:54:02 +0000 (13:54 +0000)
svn changeset:1725/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/UIDL.java
src/com/itmill/toolkit/terminal/gwt/client/ui/TkLabel.java

index 4c50eabd022d34a41dcd2b234e6087359c104fee..43abb38ff72d7c9fb496f69f9fc6491eb34bb616 100644 (file)
@@ -146,7 +146,10 @@ public class UIDL {
 
                for (Iterator i = getAttributeNames().iterator(); i.hasNext();) {
                        String name = i.next().toString();
-                       s += " " + name + "=" + ((JSONObject) json.get(1)).get(name);
+                       s += " " + name + "=";
+                       JSONValue v = ((JSONObject) json.get(1)).get(name);
+                       if (v.isString() != null) s += v;
+                       else s += "\"" + v + "\"";
                }
 
                s += ">\n";
@@ -162,6 +165,16 @@ public class UIDL {
                return s;
        }
 
+       public String getChildrenAsXML() {
+               String s="";
+               Iterator i = getChildIterator();
+               while (i.hasNext()) {
+                       Object c = i.next();
+                       s += c.toString();
+               }
+               return s;
+       }
+       
        public UIDLBrowser print_r() {
                return new UIDLBrowser();
        }
index 9004f6fd18d284da7e0e8d3c2da635234359a068..af89f6eff4744f2f518cf52c0d5e0f6e3e7f03df 100644 (file)
@@ -1,11 +1,12 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
 
+import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.Label;
 import com.itmill.toolkit.terminal.gwt.client.Client;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
-public class TkLabel extends Label implements Paintable {
+public class TkLabel extends HTML implements Paintable {
 
        public void updateFromUIDL(UIDL uidl, Client client) {
 
@@ -13,11 +14,21 @@ public class TkLabel extends Label implements Paintable {
                        return;
                client.delegateCaptionToParent(this, uidl);
 
-               try {
+               String mode = uidl.getStringAttribute("mode");
+               if (mode == null || "text".equals(mode))
                        setText(uidl.getChildString(0));
-               } catch (Exception e) {
+               else if ("pre".equals(mode)) {
+                       setHTML(uidl.getChildrenAsXML());
+               } else if ("uidl".equals(mode)) {
+                       setHTML(uidl.getChildrenAsXML());
+               } else if ("xhtml".equals(mode)) {
+                       setHTML(uidl.getChildUIDL(0).getChildUIDL(0).getChildString(0));
+               } else if ("xml".equals(mode)) {
+                       setHTML(uidl.getChildUIDL(0).getChildString(0));
+               } else if ("raw".equals(mode)) {
+                       setHTML(uidl.getChildUIDL(0).getChildString(0));
+               } else {
                        setText("");
-
                }
        }
 }