]> source.dussan.org Git - vaadin-framework.git/commitdiff
ThemeResource now works in Embedded
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 16 Nov 2007 13:42:51 +0000 (13:42 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 16 Nov 2007 13:42:51 +0000 (13:42 +0000)
svn changeset:2853/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java

index fe3715d08a14954b0f9b502853971285d5e8070c..3b4134ba20a81394c571566fb464b812559388a7 100644 (file)
@@ -8,44 +8,55 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class IEmbedded extends HTML implements Paintable {
 
-       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-               if (client.updateComponent(this, uidl, true)) {
-                       return;
-               }
-               String w = uidl.hasAttribute("width") ? uidl
-                               .getStringAttribute("width") : "100%";
-               String h = uidl.hasAttribute("height") ? uidl
-                               .getStringAttribute("height") : "100%";
-               DOM.setStyleAttribute(getElement(), "width", w);
-               DOM.setStyleAttribute(getElement(), "height", h);
+    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+        if (client.updateComponent(this, uidl, true)) {
+            return;
+        }
+        String w = uidl.hasAttribute("width") ? uidl
+                .getStringAttribute("width") : "100%";
+        String h = uidl.hasAttribute("height") ? uidl
+                .getStringAttribute("height") : "100%";
+        DOM.setStyleAttribute(getElement(), "width", w);
+        DOM.setStyleAttribute(getElement(), "height", h);
 
-               if (uidl.hasAttribute("type")) {
-                       String type = uidl.getStringAttribute("type");
-                       if (type.equals("image")) {
-                               setHTML("<img src=\"" + uidl.getStringAttribute("src") + "\"/>");
-                       } else if (type.equals("browser")) {
-                               setHTML("<iframe width=\"100%\" height=\"100%\" frameborder=\"0\" src=\""
-                                               + uidl.getStringAttribute("src") + "\"></iframe>");
-                       } else {
-                               ApplicationConnection.getConsole().log(
-                                               "Unknown Embedded type '" + type + "'");
-                       }
-               } else if (uidl.hasAttribute("mimetype")) {
-                       String mime = uidl.getStringAttribute("mimetype");
-                       if (mime.equals("application/x-shockwave-flash")) {
-                               setHTML("<object width=\"" + w + "\" height=\"" + h
-                                               + "\"><param name=\"movie\" value=\""
-                                               + uidl.getStringAttribute("src") + "\"><embed src=\""
-                                               + uidl.getStringAttribute("src") + "\" width=\"" + w
-                                               + "\" height=\"" + h + "\"></embed></object>");
-                       } else {
-                               ApplicationConnection.getConsole().log(
-                                               "Unknown Embedded mimetype '" + mime + "'");
-                       }
-               } else {
-                       ApplicationConnection.getConsole().log(
-                                       "Unknown Embedded; no type or mimetype attribute");
-               }
+        if (uidl.hasAttribute("type")) {
+            String type = uidl.getStringAttribute("type");
+            if (type.equals("image")) {
+                setHTML("<img src=\"" + getSrc(uidl, client) + "\"/>");
+            } else if (type.equals("browser")) {
+                setHTML("<iframe width=\"100%\" height=\"100%\" frameborder=\"0\" src=\""
+                        + getSrc(uidl, client) + "\"></iframe>");
+            } else {
+                ApplicationConnection.getConsole().log(
+                        "Unknown Embedded type '" + type + "'");
+            }
+        } else if (uidl.hasAttribute("mimetype")) {
+            String mime = uidl.getStringAttribute("mimetype");
+            if (mime.equals("application/x-shockwave-flash")) {
+                setHTML("<object width=\"" + w + "\" height=\"" + h
+                        + "\"><param name=\"movie\" value=\""
+                        + getSrc(uidl, client) + "\"><embed src=\""
+                        + getSrc(uidl, client) + "\" width=\"" + w
+                        + "\" height=\"" + h + "\"></embed></object>");
+            } else {
+                ApplicationConnection.getConsole().log(
+                        "Unknown Embedded mimetype '" + mime + "'");
+            }
+        } else {
+            ApplicationConnection.getConsole().log(
+                    "Unknown Embedded; no type or mimetype attribute");
+        }
 
-       }
+    }
+
+    /**
+     * Helper to return translated src attribute from embeddeds uidl
+     * 
+     * @param uidl
+     * @param client
+     * @return
+     */
+    private String getSrc(UIDL uidl, ApplicationConnection client) {
+        return client.translateToolkitUri(uidl.getStringAttribute("src"));
+    }
 }