summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-05-11 16:49:19 +0300
committerPekka Hyvönen <pekka@vaadin.com>2017-05-11 16:49:19 +0300
commitbda8acb85610f1532b9f11a8a9530c694051c2d9 (patch)
treec541bf0a3a12989e12c8a840bb001c671f77ab4a /server
parent8591ce8debbdd56c0f52b9fcca4346922282d5f7 (diff)
downloadvaadin-framework-bda8acb85610f1532b9f11a8a9530c694051c2d9.tar.gz
vaadin-framework-bda8acb85610f1532b9f11a8a9530c694051c2d9.zip
Poll server for changes at the end of each file upload (#9300)
* Poll server for changes at the end of each file upload
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/FileDropTarget.java34
1 files changed, 21 insertions, 13 deletions
diff --git a/server/src/main/java/com/vaadin/ui/FileDropTarget.java b/server/src/main/java/com/vaadin/ui/FileDropTarget.java
index 654563dbd0..831d6723d9 100644
--- a/server/src/main/java/com/vaadin/ui/FileDropTarget.java
+++ b/server/src/main/java/com/vaadin/ui/FileDropTarget.java
@@ -30,6 +30,7 @@ import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.ui.dnd.FileDropTargetClientRpc;
import com.vaadin.shared.ui.dnd.FileDropTargetRpc;
import com.vaadin.shared.ui.dnd.FileDropTargetState;
+import com.vaadin.shared.ui.dnd.FileParameters;
/**
* Extension to add drop target functionality to a widget for accepting and
@@ -68,24 +69,31 @@ public class FileDropTarget<T extends AbstractComponent> extends
protected void registerDropTargetRpc(T target) {
super.registerDropTargetRpc(target);
- registerRpc((FileDropTargetRpc) fileParams -> {
+ registerRpc(new FileDropTargetRpc() {
+ @Override
+ public void drop(Map<String, FileParameters> fileParams) {
+ List<Html5File> files = new ArrayList<>();
+ Map<String, String> urls = new HashMap<>();
- List<Html5File> files = new ArrayList<>();
- Map<String, String> urls = new HashMap<>();
+ fileParams.forEach((id, fileParameters) -> {
+ Html5File html5File = new Html5File(fileParameters.getName(),
+ fileParameters.getSize(), fileParameters.getMime());
+ String url = createUrl(html5File, id);
- fileParams.forEach((id, fileParameters) -> {
- Html5File html5File = new Html5File(fileParameters.getName(),
- fileParameters.getSize(), fileParameters.getMime());
- String url = createUrl(html5File, id);
+ files.add(html5File);
+ urls.put(id, url);
+ });
- files.add(html5File);
- urls.put(id, url);
- });
+ getRpcProxy(FileDropTargetClientRpc.class).sendUploadUrl(urls);
- getRpcProxy(FileDropTargetClientRpc.class).sendUploadUrl(urls);
+ FileDropEvent<T> event = new FileDropEvent<>(target, files);
+ fileDropHandler.drop(event);
+ }
- FileDropEvent<T> event = new FileDropEvent<>(target, files);
- fileDropHandler.drop(event);
+ @Override
+ public void poll() {
+ // Polling server for changes after upload finished
+ }
});
}