diff options
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/embedded/EmbeddedConnector.java | 132 |
1 files changed, 69 insertions, 63 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/embedded/EmbeddedConnector.java b/client/src/main/java/com/vaadin/client/ui/embedded/EmbeddedConnector.java index cfb067ca87..c04cb44542 100644 --- a/client/src/main/java/com/vaadin/client/ui/embedded/EmbeddedConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/embedded/EmbeddedConnector.java @@ -144,69 +144,7 @@ public class EmbeddedConnector extends AbstractComponentConnector { .severe("Unknown Embedded type '" + widget.type + "'"); } } else if (state.mimeType != null) { - // remove old style name related to type - if (widget.type != null) { - widget.removeStyleName(VEmbedded.CLASSNAME + "-" + widget.type); - } - // remove old style name related to mime type - if (widget.mimetype != null) { - widget.removeStyleName( - VEmbedded.CLASSNAME + "-" + widget.mimetype); - } - final String mime = state.mimeType; - if (mime.equals("application/x-shockwave-flash")) { - widget.mimetype = "flash"; - // Handle embedding of Flash - widget.addStyleName(VEmbedded.CLASSNAME + "-flash"); - widget.setHTML( - widget.createFlashEmbed(state, getResourceUrl("src"))); - - } else if (mime.equals("image/svg+xml")) { - widget.mimetype = "svg"; - widget.addStyleName(VEmbedded.CLASSNAME + "-svg"); - String data; - Map<String, String> parameters = state.parameters; - ObjectElement obj = Document.get().createObjectElement(); - resourceElement = null; - if (parameters.get("data") == null) { - objectElement = obj; - data = getResourceUrl("src"); - setResourceUrl(data); - } else { - objectElement = null; - data = "data:image/svg+xml," + parameters.get("data"); - obj.setData(data); - } - widget.setHTML(""); - obj.setType(mime); - if (!isUndefinedWidth()) { - obj.getStyle().setProperty("width", "100%"); - } - if (!isUndefinedHeight()) { - obj.getStyle().setProperty("height", "100%"); - } - if (state.classId != null) { - obj.setAttribute("classid", state.classId); - } - if (state.codebase != null) { - obj.setAttribute("codebase", state.codebase); - } - if (state.codetype != null) { - obj.setAttribute("codetype", state.codetype); - } - if (state.archive != null) { - obj.setAttribute("archive", state.archive); - } - if (state.standby != null) { - obj.setAttribute("standby", state.standby); - } - widget.getElement().appendChild(obj); - if (state.altText != null) { - obj.setInnerText(state.altText); - } - } else { - getLogger().severe("Unknown Embedded mimetype '" + mime + "'"); - } + handleMimeType(); } else { getLogger() .severe("Unknown Embedded; no type or mimetype attribute"); @@ -217,6 +155,74 @@ public class EmbeddedConnector extends AbstractComponentConnector { } } + private void handleMimeType() { + VEmbedded widget = getWidget(); + + // remove old style name related to type + if (widget.type != null) { + widget.removeStyleName(VEmbedded.CLASSNAME + "-" + widget.type); + } + // remove old style name related to mime type + if (widget.mimetype != null) { + widget.removeStyleName(VEmbedded.CLASSNAME + "-" + widget.mimetype); + } + EmbeddedState state = getState(); + final String mime = state.mimeType; + if (mime.equals("application/x-shockwave-flash")) { + widget.mimetype = "flash"; + // Handle embedding of Flash + widget.addStyleName(VEmbedded.CLASSNAME + "-flash"); + widget.setHTML( + widget.createFlashEmbed(state, getResourceUrl("src"))); + + } else if (mime.equals("image/svg+xml")) { + widget.mimetype = "svg"; + widget.addStyleName(VEmbedded.CLASSNAME + "-svg"); + String data; + Map<String, String> parameters = state.parameters; + ObjectElement obj = Document.get().createObjectElement(); + resourceElement = null; + if (parameters.get("data") == null) { + objectElement = obj; + data = getResourceUrl("src"); + setResourceUrl(data); + } else { + objectElement = null; + data = "data:image/svg+xml," + parameters.get("data"); + obj.setData(data); + } + widget.setHTML(""); + obj.setType(mime); + if (!isUndefinedWidth()) { + obj.getStyle().setProperty("width", "100%"); + } + if (!isUndefinedHeight()) { + obj.getStyle().setProperty("height", "100%"); + } + if (state.classId != null) { + obj.setAttribute("classid", state.classId); + } + if (state.codebase != null) { + obj.setAttribute("codebase", state.codebase); + } + if (state.codetype != null) { + obj.setAttribute("codetype", state.codetype); + } + if (state.archive != null) { + obj.setAttribute("archive", state.archive); + } + if (state.standby != null) { + obj.setAttribute("standby", state.standby); + } + widget.getElement().appendChild(obj); + if (state.altText != null) { + obj.setInnerText(state.altText); + } + } else { + getLogger().severe("Unknown Embedded mimetype '" + mime + "'"); + } + } + private void updateResourceIfNecessary() { if (resourceElement != null || objectElement != null) { String src = getResourceUrl("src"); |