]> source.dussan.org Git - vaadin-framework.git/commitdiff
cross plat improvementes for html5 drags
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 16 Mar 2010 15:08:15 +0000 (15:08 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 16 Mar 2010 15:08:15 +0000 (15:08 +0000)
svn changeset:11917/svn branch:6.3

src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java
tests/src/com/vaadin/tests/dd/DragDropPane.java

index e35eec9799fef094a210f2246e0fd9fd262abb4c..6e076ff255e517e84b51608dbf18645852447860 100644 (file)
@@ -204,8 +204,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements
         for (int i = 0; i < types.length(); i++) {
             String type = types.get(i);
             ApplicationConnection.getConsole().log("Type: " + type);
-            if ("Text".equals(type) || "Url".equals(type)
-                    || "text/html".equals(type)) {
+            if (isAcceptedType(type)) {
                 String data = event.getDataAsText(type);
                 if (data != null) {
                     ApplicationConnection.getConsole().log(type + " : " + data);
@@ -240,6 +239,18 @@ public class VDragAndDropWrapper extends VCustomComponent implements
         return false;
     }
 
+    protected String[] acceptedTypes = new String[] { "Text", "Url",
+            "text/html", "text/plain", "text/rtf" };
+
+    private boolean isAcceptedType(String type) {
+        for (String t : acceptedTypes) {
+            if (t.equals(type)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     static class ExtendedXHR extends XMLHttpRequest {
 
         protected ExtendedXHR() {
index 82401a99f70119b16f75cb8c1264c3c80835a490..cd7a372d2e6b100e8057a69feae937e66b2ef5a9 100644 (file)
@@ -114,12 +114,18 @@ public class DragDropPane extends DragAndDropWrapper implements DropHandler {
             WrapperTransferable wtr = (WrapperTransferable) ctr;
 
             String object = (String) ctr.getData("Text");
+            if (object == null) {
+                object = (String) ctr.getData("text/plain");
+            }
             String html = (String) ctr.getData("Html");
             String url = (String) ctr.getData("Url");
 
             final Label l = new Label();
             l.setCaption("Generated from HTML5 drag:");
             if (object != null) {
+                if (object.length() > 80) {
+                    object = object.substring(0, 79);
+                }
                 l.setValue(object);
             } else {
                 l.setValue("HTML5 dd");