From 496dd015643a175d746baad418f3e9865e6fd8e4 Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Fri, 9 Nov 2007 08:11:52 +0000 Subject: [PATCH] Embedded TYPE_HTML -> TYPE_BROWSER, IEmbedded updated svn changeset:2770/svn branch:trunk --- .../terminal/gwt/client/ui/IEmbedded.java | 54 ++++++++++++------- src/com/itmill/toolkit/ui/Embedded.java | 10 ++-- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java index b0677746ca..56006f23fc 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java @@ -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(""); - } 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(""); + if (uidl.hasAttribute("type")) { + String type = uidl.getStringAttribute("type"); + if (type.equals("image")) { + setHTML(""); + } else if (type.equals("browser")) { + setHTML(""); + } 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(""); + } 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"); } + } } diff --git a/src/com/itmill/toolkit/ui/Embedded.java b/src/com/itmill/toolkit/ui/Embedded.java index b68a1a7311..6a2a93cd26 100644 --- a/src/com/itmill/toolkit/ui/Embedded.java +++ b/src/com/itmill/toolkit/ui/Embedded.java @@ -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) { -- 2.39.5