]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge remote-tracking branch 'origin/6.8'
authorArtur Signell <artur@vaadin.com>
Fri, 23 Mar 2012 07:52:33 +0000 (09:52 +0200)
committerArtur Signell <artur@vaadin.com>
Fri, 23 Mar 2012 07:52:33 +0000 (09:52 +0200)
Conflicts:
src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java
tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java

1  2 
src/com/vaadin/terminal/gwt/client/ui/EmbeddedConnector.java
src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java
src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java
src/com/vaadin/ui/Button.java
src/com/vaadin/ui/Embedded.java
tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java

index d57f56d9efdc52fbd4cd50d0e3608a98d7e60cd5,0000000000000000000000000000000000000000..b724e8fe9ed277ce9a45dd7e7a48f73a2eda43e4
mode 100644,000000..100644
--- /dev/null
@@@ -1,185 -1,0 +1,186 @@@
 +/*
 +@VaadinApache2LicenseForJavaFiles@
 + */
 +
 +package com.vaadin.terminal.gwt.client.ui;
 +
 +import java.util.Map;
 +
 +import com.google.gwt.core.client.GWT;
 +import com.google.gwt.dom.client.Document;
 +import com.google.gwt.dom.client.Node;
 +import com.google.gwt.dom.client.NodeList;
 +import com.google.gwt.dom.client.ObjectElement;
 +import com.google.gwt.dom.client.Style;
 +import com.google.gwt.event.dom.client.DomEvent.Type;
 +import com.google.gwt.event.shared.EventHandler;
 +import com.google.gwt.event.shared.HandlerRegistration;
 +import com.google.gwt.user.client.DOM;
 +import com.google.gwt.user.client.Element;
 +import com.google.gwt.user.client.Event;
 +import com.google.gwt.user.client.ui.Widget;
 +import com.vaadin.terminal.gwt.client.ApplicationConnection;
 +import com.vaadin.terminal.gwt.client.UIDL;
 +import com.vaadin.terminal.gwt.client.VConsole;
 +import com.vaadin.terminal.gwt.client.VTooltip;
 +
 +public class EmbeddedConnector extends AbstractComponentConnector {
 +
 +    public static final String CLICK_EVENT_IDENTIFIER = "click";
++    public static final String ALTERNATE_TEXT = "alt";
 +
 +    @Override
 +    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
 +        super.updateFromUIDL(uidl, client);
 +        if (!isRealUpdate(uidl)) {
 +            return;
 +        }
 +
 +        // Save details
 +        getWidget().client = client;
 +
 +        boolean clearBrowserElement = true;
 +
 +        clickEventHandler.handleEventHandlerRegistration();
 +
 +        if (uidl.hasAttribute("type")) {
 +            getWidget().type = uidl.getStringAttribute("type");
 +            if (getWidget().type.equals("image")) {
 +                getWidget().addStyleName(VEmbedded.CLASSNAME + "-image");
 +                Element el = null;
 +                boolean created = false;
 +                NodeList<Node> nodes = getWidget().getElement().getChildNodes();
 +                if (nodes != null && nodes.getLength() == 1) {
 +                    Node n = nodes.getItem(0);
 +                    if (n.getNodeType() == Node.ELEMENT_NODE) {
 +                        Element e = (Element) n;
 +                        if (e.getTagName().equals("IMG")) {
 +                            el = e;
 +                        }
 +                    }
 +                }
 +                if (el == null) {
 +                    getWidget().setHTML("");
 +                    el = DOM.createImg();
 +                    created = true;
 +                    DOM.sinkEvents(el, Event.ONLOAD);
 +                }
 +
 +                // Set attributes
 +                Style style = el.getStyle();
 +                style.setProperty("width", getState().getWidth());
 +                style.setProperty("height", getState().getHeight());
 +
 +                DOM.setElementProperty(el, "src",
 +                        getWidget().getSrc(uidl, client));
 +
 +                if (created) {
 +                    // insert in dom late
 +                    getWidget().getElement().appendChild(el);
 +                }
 +
 +                /*
 +                 * Sink tooltip events so tooltip is displayed when hovering the
 +                 * image.
 +                 */
 +                getWidget().sinkEvents(VTooltip.TOOLTIP_EVENTS);
 +
 +            } else if (getWidget().type.equals("browser")) {
 +                getWidget().addStyleName(VEmbedded.CLASSNAME + "-browser");
 +                if (getWidget().browserElement == null) {
 +                    getWidget().setHTML(
 +                            "<iframe width=\"100%\" height=\"100%\" frameborder=\"0\""
 +                                    + " allowTransparency=\"true\" src=\"\""
 +                                    + " name=\"" + uidl.getId()
 +                                    + "\"></iframe>");
 +                    getWidget().browserElement = DOM.getFirstChild(getWidget()
 +                            .getElement());
 +                }
 +                DOM.setElementAttribute(getWidget().browserElement, "src",
 +                        getWidget().getSrc(uidl, client));
 +                clearBrowserElement = false;
 +            } else {
 +                VConsole.log("Unknown Embedded type '" + getWidget().type + "'");
 +            }
 +        } else if (uidl.hasAttribute("mimetype")) {
 +            final String mime = uidl.getStringAttribute("mimetype");
 +            if (mime.equals("application/x-shockwave-flash")) {
 +                // Handle embedding of Flash
 +                getWidget().addStyleName(VEmbedded.CLASSNAME + "-flash");
 +                getWidget().setHTML(getWidget().createFlashEmbed(uidl));
 +
 +            } else if (mime.equals("image/svg+xml")) {
 +                getWidget().addStyleName(VEmbedded.CLASSNAME + "-svg");
 +                String data;
 +                Map<String, String> parameters = VEmbedded.getParameters(uidl);
 +                if (parameters.get("data") == null) {
 +                    data = getWidget().getSrc(uidl, client);
 +                } else {
 +                    data = "data:image/svg+xml," + parameters.get("data");
 +                }
 +                getWidget().setHTML("");
 +                ObjectElement obj = Document.get().createObjectElement();
 +                obj.setType(mime);
 +                obj.setData(data);
 +                if (!isUndefinedWidth()) {
 +                    obj.getStyle().setProperty("width", "100%");
 +                }
 +                if (!isUndefinedHeight()) {
 +                    obj.getStyle().setProperty("height", "100%");
 +                }
 +                if (uidl.hasAttribute("classid")) {
 +                    obj.setAttribute("classid",
 +                            uidl.getStringAttribute("classid"));
 +                }
 +                if (uidl.hasAttribute("codebase")) {
 +                    obj.setAttribute("codebase",
 +                            uidl.getStringAttribute("codebase"));
 +                }
 +                if (uidl.hasAttribute("codetype")) {
 +                    obj.setAttribute("codetype",
 +                            uidl.getStringAttribute("codetype"));
 +                }
 +                if (uidl.hasAttribute("archive")) {
 +                    obj.setAttribute("archive",
 +                            uidl.getStringAttribute("archive"));
 +                }
 +                if (uidl.hasAttribute("standby")) {
 +                    obj.setAttribute("standby",
 +                            uidl.getStringAttribute("standby"));
 +                }
 +                getWidget().getElement().appendChild(obj);
 +
 +            } else {
 +                VConsole.log("Unknown Embedded mimetype '" + mime + "'");
 +            }
 +        } else {
 +            VConsole.log("Unknown Embedded; no type or mimetype attribute");
 +        }
 +
 +        if (clearBrowserElement) {
 +            getWidget().browserElement = null;
 +        }
 +    }
 +
 +    @Override
 +    protected Widget createWidget() {
 +        return GWT.create(VEmbedded.class);
 +    }
 +
 +    @Override
 +    public VEmbedded getWidget() {
 +        return (VEmbedded) super.getWidget();
 +    }
 +
 +    protected final ClickEventHandler clickEventHandler = new ClickEventHandler(
 +            this, CLICK_EVENT_IDENTIFIER) {
 +
 +        @Override
 +        protected <H extends EventHandler> HandlerRegistration registerHandler(
 +                H handler, Type<H> type) {
 +            return getWidget().addDomHandler(handler, type);
 +        }
 +
 +    };
 +
 +}
index 71240d9c1d7a225d084a618f9e6010c54a88b0e5,2783db99d1a5ab1d8493436aaf6c3c03bba32422..26b45d10e1c1f1537cf8ff40c364a27958f21d7e
@@@ -152,6 -313,10 +152,11 @@@ public class VEmbedded extends HTML 
          // End embed tag
          html.append("></embed>");
  
 -        if (uidl.hasAttribute(ALTERNATE_TEXT)) {
 -            html.append(uidl.getStringAttribute(ALTERNATE_TEXT));
++        if (uidl.hasAttribute(EmbeddedConnector.ALTERNATE_TEXT)) {
++            html.append(uidl
++                    .getStringAttribute(EmbeddedConnector.ALTERNATE_TEXT));
+         }
          // End object tag
          html.append("</object>");
  
index 2e23d4ae74f1acc44e996c4022edaf5cbd68c9e0,3c9978459269d528ab0cf480f19b10b950286ce4..dbebd9200c663edf64fe42ac1efd634824fae01a
@@@ -306,10 -512,20 +306,21 @@@ public class Button extends AbstractCom
       *            the Listener to be removed.
       */
      public void removeListener(ClickListener listener) {
 -        removeListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD);
 +        removeListener(ClickEvent.class, listener,
 +                ClickListener.BUTTON_CLICK_METHOD);
      }
  
+     /**
+      * Simulates a button click, notifying all server-side listeners.
+      * 
+      * No action is taken is the button is disabled.
+      */
+     public void click() {
+         if (isEnabled() && !isReadOnly()) {
+             fireClick();
+         }
+     }
      /**
       * Fires a click event to all listeners without any event details.
       * 
index bc4c2a3ff4d70e31823326ff6e24f732b20efdf5,181cbbfb96e20be69edaafa76f8a6604e8aba19c..906f1ca1edd5dcbe982d5da0564748dff3183b3b
@@@ -146,6 -148,9 +148,9 @@@ public class Embedded extends AbstractC
          if (archive != null && !"".equals(archive)) {
              target.addAttribute("archive", archive);
          }
 -            target.addAttribute(VEmbedded.ALTERNATE_TEXT, altText);
+         if (altText != null && !"".equals(altText)) {
++            target.addAttribute(EmbeddedConnector.ALTERNATE_TEXT, altText);
+         }
  
          // Params
          for (final Iterator<String> i = getParameterNames(); i.hasNext();) {
index e551e153db0af1af5b9724f3b9320819127a72d1,320df648b19df8a5ca586c0b46816a1f0d81aa7a..d507cebebc74f7e1acd50309192dd43e5f176d02
@@@ -26,7 -28,13 +28,13 @@@ public class EmbeddedPdf extends TestBa
          player.setSource(new ClassResource(getClass(), "test.pdf", this));
          addComponent(player);
  
 -        player.getWindow().addWindow(new Window("Testwindow"));
+         addComponent(new Button("Remove pdf", new Button.ClickListener() {
+             public void buttonClick(ClickEvent event) {
+                 removeComponent(player);
+             }
+         }));
 +        player.getRoot().addWindow(new Window("Testwindow"));
      }
  
  }