diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-09-27 12:03:18 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-09-27 13:03:18 +0300 |
commit | 22566d5d9d3794edc1bad59a709f3a78b3a3ba28 (patch) | |
tree | ea1ac7cdb9e40d0f1b8b3f438f3e1d6dcbc3fb57 | |
parent | 367c7751a6ff9234fd47bc5a48e6ef9a4117a7a2 (diff) | |
download | vaadin-framework-22566d5d9d3794edc1bad59a709f3a78b3a3ba28.tar.gz vaadin-framework-22566d5d9d3794edc1bad59a709f3a78b3a3ba28.zip |
Convert Embedded not to be a LegacyComponent (#10088)
6 files changed, 203 insertions, 283 deletions
diff --git a/all/src/main/templates/release-notes.html b/all/src/main/templates/release-notes.html index 7087b6c46c..327dae38b3 100644 --- a/all/src/main/templates/release-notes.html +++ b/all/src/main/templates/release-notes.html @@ -108,6 +108,7 @@ <li><tt>BindingBuilder</tt> now works like a proper builder. Adding a converter will not mark Binding as <tt>bound</tt> allowing chaining to the same object.</li> <li><tt>ErrorLevel</tt> is removed from <tt>ErrorMessage</tt> and now <tt>com.vaadin.shared.ui.ErrorLevel</tt> should be used.</li> <li>Error indicators are now <tt><span class="v-errorindicator"></span></tt> elements.</li> + <li><tt>Embedded</tt> is not a <tt>LegacyComponent</tt> anymore.</li> <h2>For incompatible or behaviour-altering changes in 8.1, please see <a href="https://vaadin.com/download/release/8.1/8.1.0/release-notes.html#incompatible">8.1 release notes</a></h2> diff --git a/client/src/main/java/com/vaadin/client/ui/VEmbedded.java b/client/src/main/java/com/vaadin/client/ui/VEmbedded.java index 45037f72a8..5f4e801a44 100644 --- a/client/src/main/java/com/vaadin/client/ui/VEmbedded.java +++ b/client/src/main/java/com/vaadin/client/ui/VEmbedded.java @@ -32,7 +32,7 @@ import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.client.VConsole; import com.vaadin.client.WidgetUtil; -import com.vaadin.shared.ui.embedded.EmbeddedConstants; +import com.vaadin.shared.ui.embedded.EmbeddedState; public class VEmbedded extends HTML { public static String CLASSNAME = "v-embedded"; @@ -59,11 +59,14 @@ public class VEmbedded extends HTML { * <p> * For internal use only. May be removed or replaced in the future. * - * @param uidl - * The UIDL + * @param state + * The EmbeddedState + * @param src + * The src attribute * @return Tags concatenated into a string + * @since */ - public String createFlashEmbed(UIDL uidl) { + public String createFlashEmbed(EmbeddedState state, String src) { /* * To ensure cross-browser compatibility we are using the twice-cooked * method to embed flash i.e. we add a OBJECT tag for IE ActiveX and @@ -82,12 +85,9 @@ public class VEmbedded extends HTML { * http://kb2.adobe.com/cps/415/tn_4150.html. Allow user to override * this by setting his own classid. */ - if (uidl.hasAttribute("classid")) { - html.append( - "classid=\"" - + WidgetUtil.escapeAttribute( - uidl.getStringAttribute("classid")) - + "\" "); + if (state.classId != null) { + html.append("classid=\"" + WidgetUtil.escapeAttribute(state.classId) + + "\" "); } else { html.append( "classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "); @@ -101,12 +101,9 @@ public class VEmbedded extends HTML { * 6.0.0.0 and above. Allow user to override this by setting his own * codebase */ - if (uidl.hasAttribute("codebase")) { - html.append( - "codebase=\"" - + WidgetUtil.escapeAttribute( - uidl.getStringAttribute("codebase")) - + "\" "); + if (state.codebase != null) { + html.append("codebase=\"" + + WidgetUtil.escapeAttribute(state.codebase) + "\" "); } else { html.append( "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" "); @@ -123,39 +120,30 @@ public class VEmbedded extends HTML { html.append("type=\"application/x-shockwave-flash\" "); // Codetype - if (uidl.hasAttribute("codetype")) { - html.append( - "codetype=\"" - + WidgetUtil.escapeAttribute( - uidl.getStringAttribute("codetype")) - + "\" "); + if (state.codetype != null) { + html.append("codetype=\"" + + WidgetUtil.escapeAttribute(state.codetype) + "\" "); } // Standby - if (uidl.hasAttribute("standby")) { - html.append( - "standby=\"" - + WidgetUtil.escapeAttribute( - uidl.getStringAttribute("standby")) - + "\" "); + if (state.standby != null) { + html.append("standby=\"" + WidgetUtil.escapeAttribute(state.standby) + + "\" "); } // Archive - if (uidl.hasAttribute("archive")) { - html.append( - "archive=\"" - + WidgetUtil.escapeAttribute( - uidl.getStringAttribute("archive")) - + "\" "); + if (state.archive != null) { + html.append("archive=\"" + WidgetUtil.escapeAttribute(state.archive) + + "\" "); } // End object tag html.append(">"); // Ensure we have an movie parameter - Map<String, String> parameters = getParameters(uidl); + Map<String, String> parameters = state.parameters; if (parameters.get("movie") == null) { - parameters.put("movie", getSrc(uidl, client)); + parameters.put("movie", getSrc(src, client)); } // Add parameters to OBJECT @@ -169,7 +157,7 @@ public class VEmbedded extends HTML { // Build inner EMBED tag html.append("<embed "); - html.append("src=\"" + WidgetUtil.escapeAttribute(getSrc(uidl, client)) + html.append("src=\"" + WidgetUtil.escapeAttribute(getSrc(src, client)) + "\" "); html.append("width=\"" + WidgetUtil.escapeAttribute(width) + "\" "); html.append("height=\"" + WidgetUtil.escapeAttribute(height) + "\" "); @@ -186,9 +174,8 @@ public class VEmbedded extends HTML { // End embed tag html.append("></embed>"); - if (uidl.hasAttribute(EmbeddedConstants.ALTERNATE_TEXT)) { - html.append( - uidl.getStringAttribute(EmbeddedConstants.ALTERNATE_TEXT)); + if (state.altText != null) { + html.append(state.altText); } // End object tag @@ -232,12 +219,13 @@ public class VEmbedded extends HTML { * <p> * For internal use only. May be removed or replaced in the future. * - * @param uidl + * @param src + * the src attribute * @param client * @return */ - public String getSrc(UIDL uidl, ApplicationConnection client) { - String url = client.translateVaadinUri(uidl.getStringAttribute("src")); + public String getSrc(String src, ApplicationConnection client) { + String url = client.translateVaadinUri(src); if (url == null) { return ""; } 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 3564c1e058..dbc04941ba 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 @@ -27,9 +27,6 @@ import com.google.gwt.dom.client.ObjectElement; import com.google.gwt.dom.client.Style; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; -import com.vaadin.client.ApplicationConnection; -import com.vaadin.client.Paintable; -import com.vaadin.client.UIDL; import com.vaadin.client.VConsole; import com.vaadin.client.VTooltip; import com.vaadin.client.communication.StateChangeEvent; @@ -38,14 +35,12 @@ import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.client.ui.VEmbedded; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.Connect; -import com.vaadin.shared.ui.embedded.EmbeddedConstants; import com.vaadin.shared.ui.embedded.EmbeddedServerRpc; import com.vaadin.shared.ui.embedded.EmbeddedState; import com.vaadin.ui.Embedded; @Connect(Embedded.class) -public class EmbeddedConnector extends AbstractComponentConnector - implements Paintable { +public class EmbeddedConnector extends AbstractComponentConnector { private Element resourceElement; private ObjectElement objectElement; @@ -56,44 +51,16 @@ public class EmbeddedConnector extends AbstractComponentConnector super.onStateChanged(stateChangeEvent); // if theme has changed the resourceUrl may need to be updated updateResourceIfNecessary(); - } - - private void updateResourceIfNecessary() { - if (resourceElement != null || objectElement != null) { - String src = getResourceUrl("src"); - if (src != null && !src.isEmpty()) { - if (!src.equals(resourceUrl)) { - setResourceUrl(src); - } - } else if (resourceUrl != null && !resourceUrl.isEmpty()) { - setResourceUrl(""); - } - } - } - - private void setResourceUrl(String src) { - resourceUrl = src; - if (resourceElement != null) { - resourceElement.setAttribute("src", src); - } else if (objectElement != null) { - objectElement.setData(src); - } - } - - @Override - public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - if (!isRealUpdate(uidl)) { - return; - } // Save details - getWidget().client = client; + getWidget().client = getConnection(); boolean clearBrowserElement = true; clickEventHandler.handleEventHandlerRegistration(); - if (uidl.hasAttribute("type")) { + final EmbeddedState state = getState(); + if (state.type != Embedded.TYPE_OBJECT) { // remove old style name related to type if (getWidget().type != null) { getWidget().removeStyleName( @@ -104,7 +71,8 @@ public class EmbeddedConnector extends AbstractComponentConnector getWidget().removeStyleName( VEmbedded.CLASSNAME + "-" + getWidget().mimetype); } - getWidget().type = uidl.getStringAttribute("type"); + getWidget().type = state.type == Embedded.TYPE_IMAGE ? "image" + : "browser"; if (getWidget().type.equals("image")) { getWidget().addStyleName(VEmbedded.CLASSNAME + "-image"); Element el = null; @@ -128,17 +96,15 @@ public class EmbeddedConnector extends AbstractComponentConnector // Set attributes Style style = el.getStyle(); - style.setProperty("width", getState().width); - style.setProperty("height", getState().height); + style.setProperty("width", state.width); + style.setProperty("height", state.height); resourceElement = el; objectElement = null; setResourceUrl(getResourceUrl("src")); - if (uidl.hasAttribute(EmbeddedConstants.ALTERNATE_TEXT)) { - el.setPropertyString(EmbeddedConstants.ALTERNATE_TEXT, - uidl.getStringAttribute( - EmbeddedConstants.ALTERNATE_TEXT)); + if (state.altText != null) { + el.setPropertyString("alt", state.altText); } if (created) { @@ -158,7 +124,7 @@ public class EmbeddedConnector extends AbstractComponentConnector getWidget().setHTML( "<iframe width=\"100%\" height=\"100%\" frameborder=\"0\"" + " allowTransparency=\"true\" src=\"\"" - + " name=\"" + uidl.getId() + + " name=\"" + getConnectorId() + "\"></iframe>"); getWidget().browserElement = DOM .getFirstChild(getWidget().getElement()); @@ -171,7 +137,7 @@ public class EmbeddedConnector extends AbstractComponentConnector VConsole.error( "Unknown Embedded type '" + getWidget().type + "'"); } - } else if (uidl.hasAttribute("mimetype")) { + } else if (state.mimeType != null) { // remove old style name related to type if (getWidget().type != null) { getWidget().removeStyleName( @@ -182,18 +148,19 @@ public class EmbeddedConnector extends AbstractComponentConnector getWidget().removeStyleName( VEmbedded.CLASSNAME + "-" + getWidget().mimetype); } - final String mime = uidl.getStringAttribute("mimetype"); + final String mime = state.mimeType; if (mime.equals("application/x-shockwave-flash")) { getWidget().mimetype = "flash"; // Handle embedding of Flash getWidget().addStyleName(VEmbedded.CLASSNAME + "-flash"); - getWidget().setHTML(getWidget().createFlashEmbed(uidl)); + getWidget().setHTML(getWidget().createFlashEmbed(state, + getResourceUrl("src"))); } else if (mime.equals("image/svg+xml")) { getWidget().mimetype = "svg"; getWidget().addStyleName(VEmbedded.CLASSNAME + "-svg"); String data; - Map<String, String> parameters = VEmbedded.getParameters(uidl); + Map<String, String> parameters = state.parameters; ObjectElement obj = Document.get().createObjectElement(); resourceElement = null; if (parameters.get("data") == null) { @@ -213,30 +180,24 @@ public class EmbeddedConnector extends AbstractComponentConnector if (!isUndefinedHeight()) { obj.getStyle().setProperty("height", "100%"); } - if (uidl.hasAttribute("classid")) { - obj.setAttribute("classid", - uidl.getStringAttribute("classid")); + if (state.classId != null) { + obj.setAttribute("classid", state.classId); } - if (uidl.hasAttribute("codebase")) { - obj.setAttribute("codebase", - uidl.getStringAttribute("codebase")); + if (state.codebase != null) { + obj.setAttribute("codebase", state.codebase); } - if (uidl.hasAttribute("codetype")) { - obj.setAttribute("codetype", - uidl.getStringAttribute("codetype")); + if (state.codetype != null) { + obj.setAttribute("codetype", state.codetype); } - if (uidl.hasAttribute("archive")) { - obj.setAttribute("archive", - uidl.getStringAttribute("archive")); + if (state.archive != null) { + obj.setAttribute("archive", state.archive); } - if (uidl.hasAttribute("standby")) { - obj.setAttribute("standby", - uidl.getStringAttribute("standby")); + if (state.standby != null) { + obj.setAttribute("standby", state.standby); } getWidget().getElement().appendChild(obj); - if (uidl.hasAttribute(EmbeddedConstants.ALTERNATE_TEXT)) { - obj.setInnerText(uidl.getStringAttribute( - EmbeddedConstants.ALTERNATE_TEXT)); + if (state.altText != null) { + obj.setInnerText(state.altText); } } else { VConsole.error("Unknown Embedded mimetype '" + mime + "'"); @@ -250,6 +211,28 @@ public class EmbeddedConnector extends AbstractComponentConnector } } + private void updateResourceIfNecessary() { + if (resourceElement != null || objectElement != null) { + String src = getResourceUrl("src"); + if (src != null && !src.isEmpty()) { + if (!src.equals(resourceUrl)) { + setResourceUrl(src); + } + } else if (resourceUrl != null && !resourceUrl.isEmpty()) { + setResourceUrl(""); + } + } + } + + private void setResourceUrl(String src) { + resourceUrl = src; + if (resourceElement != null) { + resourceElement.setAttribute("src", src); + } else if (objectElement != null) { + objectElement.setData(src); + } + } + @Override public VEmbedded getWidget() { return (VEmbedded) super.getWidget(); diff --git a/server/src/main/java/com/vaadin/ui/Embedded.java b/server/src/main/java/com/vaadin/ui/Embedded.java index 1f6c15e0c6..92099b9e68 100644 --- a/server/src/main/java/com/vaadin/ui/Embedded.java +++ b/server/src/main/java/com/vaadin/ui/Embedded.java @@ -16,19 +16,13 @@ package com.vaadin.ui; -import java.util.HashMap; import java.util.Iterator; -import java.util.Map; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; -import com.vaadin.server.PaintException; -import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; import com.vaadin.shared.EventId; -import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.Registration; -import com.vaadin.shared.ui.embedded.EmbeddedConstants; import com.vaadin.shared.ui.embedded.EmbeddedServerRpc; import com.vaadin.shared.ui.embedded.EmbeddedState; @@ -52,7 +46,7 @@ import com.vaadin.shared.ui.embedded.EmbeddedState; * @since 3.0 */ @SuppressWarnings("serial") -public class Embedded extends AbstractComponent implements LegacyComponent { +public class Embedded extends AbstractComponent { /** * General object type. @@ -75,39 +69,8 @@ public class Embedded extends AbstractComponent implements LegacyComponent { @Deprecated public static final int TYPE_BROWSER = 2; - /** - * Type of the object. - */ - private int type = TYPE_OBJECT; - - /** - * Generic object attributes. - */ - private String mimeType = null; - - private String standby = null; - - /** - * Hash of object parameters. - */ - private final Map<String, String> parameters = new HashMap<>(); - - /** - * Applet or other client side runnable properties. - */ - private String codebase = null; - - private String codetype = null; - - private String classId = null; - - private String archive = null; - - private String altText; - - private EmbeddedServerRpc rpc = (MouseEventDetails mouseDetails) -> { - fireEvent(new ClickEvent(Embedded.this, mouseDetails)); - }; + private EmbeddedServerRpc rpc = mouseDetails -> fireEvent( + new ClickEvent(Embedded.this, mouseDetails)); /** * Creates a new empty Embedded object. @@ -141,59 +104,6 @@ public class Embedded extends AbstractComponent implements LegacyComponent { } /** - * Invoked when the component state should be painted. - */ - @Override - public void paintContent(PaintTarget target) throws PaintException { - - switch (type) { - case TYPE_IMAGE: - target.addAttribute("type", "image"); - break; - case TYPE_BROWSER: - target.addAttribute("type", "browser"); - break; - default: - break; - } - - if (getSource() != null) { - target.addAttribute("src", getSource()); - } - - if (mimeType != null && !mimeType.isEmpty()) { - target.addAttribute("mimetype", mimeType); - } - if (classId != null && !classId.isEmpty()) { - target.addAttribute("classid", classId); - } - if (codebase != null && !codebase.isEmpty()) { - target.addAttribute("codebase", codebase); - } - if (codetype != null && !codetype.isEmpty()) { - target.addAttribute("codetype", codetype); - } - if (standby != null && !standby.isEmpty()) { - target.addAttribute("standby", standby); - } - if (archive != null && !archive.isEmpty()) { - target.addAttribute("archive", archive); - } - if (altText != null && !altText.isEmpty()) { - target.addAttribute(EmbeddedConstants.ALTERNATE_TEXT, altText); - } - - // Params - for (final Iterator<String> i = getParameterNames(); i.hasNext();) { - target.startTag("embeddedparam"); - final String key = i.next(); - target.addAttribute("name", key); - target.addAttribute("value", getParameter(key)); - target.endTag("embeddedparam"); - } - } - - /** * Sets this component's "alt-text", that is, an alternate text that can be * presented instead of this component's normal content, for accessibility * purposes. Does not work when {@link #setType(int)} has been called with @@ -205,10 +115,10 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @since 6.8 */ public void setAlternateText(String altText) { - if (altText != this.altText - || (altText != null && !altText.equals(this.altText))) { - this.altText = altText; - markAsDirty(); + String oldAltText = getAlternateText(); + if (altText != oldAltText + || (altText != null && !altText.equals(oldAltText))) { + getState().altText = altText; } } @@ -218,7 +128,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @see #setAlternateText(String) */ public String getAlternateText() { - return altText; + return getState(false).altText; } /** @@ -233,8 +143,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * the value of the parameter. */ public void setParameter(String name, String value) { - parameters.put(name, value); - markAsDirty(); + getState().parameters.put(name, value); } /** @@ -245,7 +154,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @return the Value of parameter or null if not found. */ public String getParameter(String name) { - return parameters.get(name); + return getState(false).parameters.get(name); } /** @@ -255,8 +164,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * the name of the parameter to remove. */ public void removeParameter(String name) { - parameters.remove(name); - markAsDirty(); + getState().parameters.remove(name); } /** @@ -265,7 +173,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @return the Iterator of parameters names. */ public Iterator<String> getParameterNames() { - return parameters.keySet().iterator(); + return getState(false).parameters.keySet().iterator(); } /** @@ -276,7 +184,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @return the code base. */ public String getCodebase() { - return codebase; + return getState(false).codebase; } /** @@ -285,7 +193,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @return the MIME-Type of the code. */ public String getCodetype() { - return codetype; + return getState(false).codetype; } /** @@ -294,7 +202,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @return the MIME-Type of the object. */ public String getMimeType() { - return mimeType; + return getState(false).mimeType; } /** @@ -304,7 +212,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @return The text displayed when loading */ public String getStandby() { - return standby; + return getState(false).standby; } /** @@ -316,10 +224,10 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * The base path */ public void setCodebase(String codebase) { - if (codebase != this.codebase - || (codebase != null && !codebase.equals(this.codebase))) { - this.codebase = codebase; - markAsDirty(); + String oldCodebase = getCodebase(); + if (codebase != oldCodebase + || (codebase != null && !codebase.equals(oldCodebase))) { + getState().codebase = codebase; } } @@ -334,10 +242,10 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * the codetype to set. */ public void setCodetype(String codetype) { - if (codetype != this.codetype - || (codetype != null && !codetype.equals(this.codetype))) { - this.codetype = codetype; - markAsDirty(); + String oldCodetype = getCodetype(); + if (codetype != oldCodetype + || (codetype != null && !codetype.equals(oldCodetype))) { + getState().codetype = codetype; } } @@ -348,9 +256,10 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * the mimeType to set. */ public void setMimeType(String mimeType) { - if (mimeType != this.mimeType - || (mimeType != null && !mimeType.equals(this.mimeType))) { - this.mimeType = mimeType; + String oldMimeType = getMimeType(); + if (mimeType != oldMimeType + || (mimeType != null && !mimeType.equals(oldMimeType))) { + getState().mimeType = mimeType; if ("application/x-shockwave-flash".equals(mimeType)) { /* * Automatically add wmode transparent as we use lots of @@ -362,7 +271,6 @@ public class Embedded extends AbstractComponent implements LegacyComponent { setParameter("wmode", "transparent"); } } - markAsDirty(); } } @@ -374,10 +282,10 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * The text to display while loading */ public void setStandby(String standby) { - if (standby != this.standby - || (standby != null && !standby.equals(this.standby))) { - this.standby = standby; - markAsDirty(); + String oldStandby = getStandby(); + if (standby != oldStandby + || (standby != null && !standby.equals(oldStandby))) { + getState().standby = standby; } } @@ -388,7 +296,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @return the classid. */ public String getClassId() { - return classId; + return getState(false).classId; } /** @@ -399,10 +307,10 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * the classId to set. */ public void setClassId(String classId) { - if (classId != this.classId - || (classId != null && !classId.equals(this.classId))) { - this.classId = classId; - markAsDirty(); + String oldClassId = getClassId(); + if (classId != oldClassId + || (classId != null && !classId.equals(oldClassId))) { + getState().classId = classId; } } @@ -428,7 +336,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * @return the type. */ public int getType() { - return type; + return getState(false).type; } /** @@ -443,19 +351,18 @@ public class Embedded extends AbstractComponent implements LegacyComponent { setResource("src", source); final String mt = source.getMIMEType(); - if (mimeType == null) { - mimeType = mt; + if (getMimeType() == null) { + getState().mimeType = mt; } if (mt.equals("image/svg+xml")) { - type = TYPE_OBJECT; + getState().type = TYPE_OBJECT; } else if ((mt.substring(0, mt.indexOf('/')) .equalsIgnoreCase("image"))) { - type = TYPE_IMAGE; + getState().type = TYPE_IMAGE; } else { // Keep previous type } - markAsDirty(); } } @@ -477,9 +384,8 @@ public class Embedded extends AbstractComponent implements LegacyComponent { if (type != TYPE_OBJECT && type != TYPE_IMAGE && type != TYPE_BROWSER) { throw new IllegalArgumentException("Unsupported type"); } - if (type != this.type) { - this.type = type; - markAsDirty(); + if (type != getType()) { + getState().type = type; } } @@ -495,7 +401,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * object */ public String getArchive() { - return archive; + return getState(false).archive; } /** @@ -511,10 +417,10 @@ public class Embedded extends AbstractComponent implements LegacyComponent { * object */ public void setArchive(String archive) { - if (archive != this.archive - || (archive != null && !archive.equals(this.archive))) { - this.archive = archive; - markAsDirty(); + String oldArchive = getArchive(); + if (archive != oldArchive + || (archive != null && !archive.equals(oldArchive))) { + getState().archive = archive; } } @@ -553,11 +459,6 @@ public class Embedded extends AbstractComponent implements LegacyComponent { } @Override - public void changeVariables(Object source, Map<String, Object> variables) { - // TODO Remove once LegacyComponent is no longer implemented - } - - @Override protected EmbeddedState getState() { return (EmbeddedState) super.getState(); } diff --git a/shared/src/main/java/com/vaadin/shared/ui/embedded/EmbeddedConstants.java b/shared/src/main/java/com/vaadin/shared/ui/embedded/EmbeddedConstants.java deleted file mode 100644 index 6e0564f5b7..0000000000 --- a/shared/src/main/java/com/vaadin/shared/ui/embedded/EmbeddedConstants.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.shared.ui.embedded; - -import java.io.Serializable; - -@Deprecated -public class EmbeddedConstants implements Serializable { - @Deprecated - public static final String ALTERNATE_TEXT = "alt"; - -} diff --git a/shared/src/main/java/com/vaadin/shared/ui/embedded/EmbeddedState.java b/shared/src/main/java/com/vaadin/shared/ui/embedded/EmbeddedState.java index 726e021ed2..9476aabe46 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/embedded/EmbeddedState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/embedded/EmbeddedState.java @@ -15,10 +15,82 @@ */ package com.vaadin.shared.ui.embedded; +import java.util.HashMap; +import java.util.Map; + import com.vaadin.shared.ui.AbstractEmbeddedState; public class EmbeddedState extends AbstractEmbeddedState { { primaryStyleName = "v-embedded"; } + + /** + * The object type. + * + * @since + */ + public int type; + + /** + * The MIME-type of the object. + * + * @since + */ + public String mimeType; + + /** + * Specifies the base path used to resolve relative URIs specified by the + * classid, data, and archive attributes. + * + * @since + */ + public String codebase; + + /** + * The MIME-Type of the code. + * + * @since + */ + public String codetype; + + /** + * May be used to specify the location of an object's implementation via a + * URI. + * + * @since + */ + public String classId; + + /** + * May be used to specify a space-separated list of URIs for archives + * containing resources relevant to the object. + * + * @since + */ + public String archive; + + /** + * The component's "alt-text". + * + * @since + */ + public String altText; + + /** + * Specifies a message that a user agent may render while loading the + * object's implementation and data. + * + * @since + */ + public String standby; + + /** + * Object parameters. Parameters are optional information, and they are + * passed to the instantiated object. + * + * @since + */ + public final Map<String, String> parameters = new HashMap<>(); + } |