]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added TYPE_HTML for embedding html (i.e iframe)
authorMarc Englund <marc.englund@itmill.com>
Fri, 9 Nov 2007 07:47:35 +0000 (07:47 +0000)
committerMarc Englund <marc.englund@itmill.com>
Fri, 9 Nov 2007 07:47:35 +0000 (07:47 +0000)
CHANGED: setSource() no longer reverts to TYPE_OBJECT if type can't be guessed, instead it keeps old type.

svn changeset:2765/svn branch:trunk

src/com/itmill/toolkit/ui/Embedded.java

index 9a51edf8c7d434ca779f14d5bae540f10c965d42..b68a1a73118d614faab16ffd7cc2735293e9aa5b 100644 (file)
@@ -56,6 +56,11 @@ public class Embedded extends AbstractComponent implements Sizeable {
         */
        public static final int TYPE_IMAGE = 1;
 
+       /**
+        * HTML types.
+        */
+       public static final int TYPE_HTML = 2;
+
        /**
         * Type of the object.
         */
@@ -87,7 +92,7 @@ public class Embedded extends AbstractComponent implements Sizeable {
        /**
         * Hash of object parameteres.
         */
-       private Hashtable parameters = new Hashtable();
+       private final Hashtable parameters = new Hashtable();
 
        /**
         * Applet or other client side runnable properties.
@@ -143,39 +148,55 @@ public class Embedded extends AbstractComponent implements Sizeable {
         */
        public void paintContent(PaintTarget target) throws PaintException {
 
-               if (type == TYPE_IMAGE) {
+               switch (type) {
+               case TYPE_IMAGE:
                        target.addAttribute("type", "image");
+                       break;
+               case TYPE_HTML:
+                       target.addAttribute("type", "html");
+                       break;
+               default:
+                       break;
                }
 
-               if (source != null)
+               if (source != null) {
                        target.addAttribute("src", source);
+               }
 
                // Dimensions
-               if (width > 0)
+               if (width > 0) {
                        target.addAttribute("width", "" + width
                                        + Sizeable.UNIT_SYMBOLS[this.widthUnits]);
-               if (height > 0)
+               }
+               if (height > 0) {
                        target.addAttribute("height", "" + height
                                        + Sizeable.UNIT_SYMBOLS[this.heightUnits]);
-               if (mimeType != null && !"".equals(mimeType))
+               }
+               if (mimeType != null && !"".equals(mimeType)) {
                        target.addAttribute("mimetype", mimeType);
-               if (classId != null && !"".equals(classId))
+               }
+               if (classId != null && !"".equals(classId)) {
                        target.addAttribute("classid", classId);
-               if (codebase != null && !"".equals(codebase))
+               }
+               if (codebase != null && !"".equals(codebase)) {
                        target.addAttribute("codebase", codebase);
-               if (codetype != null && !"".equals(codetype))
+               }
+               if (codetype != null && !"".equals(codetype)) {
                        target.addAttribute("codetype", codetype);
-               if (standby != null && !"".equals(standby))
+               }
+               if (standby != null && !"".equals(standby)) {
                        target.addAttribute("standby", standby);
-               if (archive != null && !"".equals(archive))
+               }
+               if (archive != null && !"".equals(archive)) {
                        target.addAttribute("archive", archive);
+               }
 
                // Params
                for (Iterator i = this.getParameterNames(); i.hasNext();) {
                        target.startTag("embeddedparam");
                        String key = (String) i.next();
                        target.addAttribute("name", key);
-                       target.addAttribute("value", (String) getParameter(key));
+                       target.addAttribute("value", getParameter(key));
                        target.endTag("embeddedparam");
                }
        }
@@ -431,7 +452,7 @@ public class Embedded extends AbstractComponent implements Sizeable {
                        if ((mt.substring(0, mt.indexOf("/")).equalsIgnoreCase("image"))) {
                                type = TYPE_IMAGE;
                        } else {
-                               type = TYPE_OBJECT;
+                               // Keep previous type
                        }
                        requestRepaint();
                }
@@ -451,8 +472,9 @@ public class Embedded extends AbstractComponent implements Sizeable {
         *            the type to set.
         */
        public void setType(int type) {
-               if (type != TYPE_OBJECT && type != TYPE_IMAGE)
+               if (type != TYPE_OBJECT && type != TYPE_IMAGE && type != TYPE_HTML) {
                        throw new IllegalArgumentException("Unsupported type");
+               }
                if (type != this.type) {
                        this.type = type;
                        requestRepaint();
@@ -530,6 +552,7 @@ public class Embedded extends AbstractComponent implements Sizeable {
 
        /*
         * (non-Javadoc)
+        * 
         * @see com.itmill.toolkit.terminal.Sizeable#setSizeFull()
         */
        public void setSizeFull() {
@@ -541,6 +564,7 @@ public class Embedded extends AbstractComponent implements Sizeable {
 
        /*
         * (non-Javadoc)
+        * 
         * @see com.itmill.toolkit.terminal.Sizeable#setSizeUndefined()
         */
        public void setSizeUndefined() {