]> source.dussan.org Git - vaadin-framework.git/commitdiff
Embedded TYPE_HTML -> TYPE_BROWSER, IEmbedded updated
authorMarc Englund <marc.englund@itmill.com>
Fri, 9 Nov 2007 08:11:52 +0000 (08:11 +0000)
committerMarc Englund <marc.englund@itmill.com>
Fri, 9 Nov 2007 08:11:52 +0000 (08:11 +0000)
svn changeset:2770/svn branch:trunk

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

index b0677746ca6125850b299bf5629881bb21cd83cb..56006f23fcca2de99f03dcc05149e0c847cfb0d0 100644 (file)
@@ -1,5 +1,6 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
 
+import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.ui.HTML;
 import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
@@ -8,27 +9,44 @@ 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))
+               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")
-                               && uidl.getStringAttribute("type").equals("image")) {
-                       setHTML("<img src=\"" + uidl.getStringAttribute("src") + "\"/>");
-               } else if (uidl.hasAttribute("mimetype")
-                               && uidl.getStringAttribute("mimetype").equals(
-                                               "application/x-shockwave-flash")) {
-                       String w = uidl.hasAttribute("width") ? uidl
-                                       .getStringAttribute("width") : "100";
-                       String h = uidl.hasAttribute("height") ? uidl
-                                       .getStringAttribute("height") : "100";
-
-                       setHTML("<object width=\"" + w + "\" height=\"" + h
-                                       + "\"><param name=\"movie\" value=\""
-                                       + uidl.getStringAttribute("src") + "\"><embed src=\""
-                                       + uidl.getStringAttribute("src") + "\" width=\"" + w
-                                       + "\" height=\"" + h + "\"></embed></object>");
+               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 style=\"width:" + w + ";height:" + h
+                                               + ";border: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 {
-                       setText("Terminal don't know how ty handle this type of embed");
+                       ApplicationConnection.getConsole().log(
+                                       "Unknown Embedded; no type or mimetype attribute");
                }
+
        }
 }
index b68a1a73118d614faab16ffd7cc2735293e9aa5b..6a2a93cd262b1cec0c44994d4f28186d9d03f70b 100644 (file)
@@ -57,9 +57,9 @@ public class Embedded extends AbstractComponent implements Sizeable {
        public static final int TYPE_IMAGE = 1;
 
        /**
-        * HTML types.
+        * Browser ("iframe") type.
         */
-       public static final int TYPE_HTML = 2;
+       public static final int TYPE_BROWSER = 2;
 
        /**
         * Type of the object.
@@ -152,8 +152,8 @@ public class Embedded extends AbstractComponent implements Sizeable {
                case TYPE_IMAGE:
                        target.addAttribute("type", "image");
                        break;
-               case TYPE_HTML:
-                       target.addAttribute("type", "html");
+               case TYPE_BROWSER:
+                       target.addAttribute("type", "browser");
                        break;
                default:
                        break;
@@ -472,7 +472,7 @@ public class Embedded extends AbstractComponent implements Sizeable {
         *            the type to set.
         */
        public void setType(int type) {
-               if (type != TYPE_OBJECT && type != TYPE_IMAGE && type != TYPE_HTML) {
+               if (type != TYPE_OBJECT && type != TYPE_IMAGE && type != TYPE_BROWSER) {
                        throw new IllegalArgumentException("Unsupported type");
                }
                if (type != this.type) {