]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge of (#10073) to Vaadin 7. 06/606/1
authorAnna Koskinen <anna@vaadin.com>
Wed, 9 Jan 2013 13:03:31 +0000 (15:03 +0200)
committerAnna Koskinen <anna@vaadin.com>
Wed, 9 Jan 2013 13:03:31 +0000 (15:03 +0200)
DragDropWrapper does not work correctly with multiple batch uploads.

Change-Id: Ib576ebf6f687c2b2ebda86e6ad1003408250140c

client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java
server/src/com/vaadin/ui/DragAndDropWrapper.java

index 91edcc4db11299fa1d8064d099873d98b6e069c3..f23bf88969e6ef9a5c0d06a73b046c49d37fa24c 100644 (file)
@@ -373,6 +373,8 @@ public class VDragAndDropWrapper extends VCustomComponent implements
                 for (int i = 0; i < fileCount; i++) {
                     final int fileId = filecounter++;
                     final VHtml5File file = event.getFile(i);
+                    VConsole.log("Preparing to upload file " + file.getName()
+                            + " with id " + fileId);
                     transferable.setData("fi" + i, "" + fileId);
                     transferable.setData("fn" + i, file.getName());
                     transferable.setData("ft" + i, file.getType());
index 60b969032150641ce6aaa0835b113ad595fe0935..f659e72e78cd0e65e0a29860dfda85837e82a486 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Set;
 import com.vaadin.client.ApplicationConnection;
 import com.vaadin.client.Paintable;
 import com.vaadin.client.UIDL;
+import com.vaadin.client.VConsole;
 import com.vaadin.client.ui.VDragAndDropWrapper;
 import com.vaadin.client.ui.customcomponent.CustomComponentConnector;
 import com.vaadin.shared.ui.Connect;
@@ -61,6 +62,17 @@ public class DragAndDropWrapperConnector extends CustomComponentConnector
                             getWidget().fileIds.remove(indexOf);
                         }
                     } else {
+                        if (getWidget().fileIdToReceiver.containsKey(fileId)
+                                && receiverUrl != null
+                                && !receiverUrl
+                                        .equals(getWidget().fileIdToReceiver
+                                                .get(fileId))) {
+                            VConsole.error("Overwriting file receiver mapping for fileId "
+                                    + fileId
+                                    + " . Old receiver URL: "
+                                    + getWidget().fileIdToReceiver.get(fileId)
+                                    + " New receiver URL: " + receiverUrl);
+                        }
                         getWidget().fileIdToReceiver.put(fileId, receiverUrl);
                     }
                 }
index 23641f285e7d754b7bdd8db72fe79cff4ffcff88..6c6aa3c3f47d5c7afe6f89fa3828345c4861035c 100644 (file)
@@ -58,7 +58,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
                             (String) rawVariables.get("ft" + i)); // mime
                     String id = (String) rawVariables.get("fi" + i);
                     files[i] = file;
-                    receivers.put(id, file);
+                    receivers.put(id, new ProxyReceiver(id, file));
                     markAsDirty(); // paint Receivers
                 }
             }
@@ -106,7 +106,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
 
     }
 
-    private Map<String, Html5File> receivers = new HashMap<String, Html5File>();
+    private Map<String, ProxyReceiver> receivers = new HashMap<String, ProxyReceiver>();
 
     public class WrapperTargetDetails extends TargetDetailsImpl {
 
@@ -222,11 +222,12 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
             getDropHandler().getAcceptCriterion().paint(target);
         }
         if (receivers != null && receivers.size() > 0) {
-            for (Iterator<Entry<String, Html5File>> it = receivers.entrySet()
-                    .iterator(); it.hasNext();) {
-                Entry<String, com.vaadin.ui.Html5File> entry = it.next();
+            for (Iterator<Entry<String, ProxyReceiver>> it = receivers
+                    .entrySet().iterator(); it.hasNext();) {
+                Entry<String, ProxyReceiver> entry = it.next();
                 String id = entry.getKey();
-                Html5File html5File = entry.getValue();
+                ProxyReceiver proxyReceiver = entry.getValue();
+                Html5File html5File = proxyReceiver.file;
                 if (html5File.getStreamVariable() != null) {
                     target.addVariable(this, "rec-" + id, new ProxyReceiver(id,
                             html5File));