aboutsummaryrefslogtreecommitdiffstats
path: root/shared/src/main/java/com/vaadin
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-05-11 13:13:10 +0300
committerPekka Hyvönen <pekka@vaadin.com>2017-05-11 13:13:10 +0300
commite2e3058a497f43f34f2fcfadf6b63de9211be659 (patch)
tree265632d4dfce4edb0fc15365e4f0339333dbcce3 /shared/src/main/java/com/vaadin
parenta4ffc1e1597e2ce3a3ac2977458c8df25e112c88 (diff)
downloadvaadin-framework-e2e3058a497f43f34f2fcfadf6b63de9211be659.tar.gz
vaadin-framework-e2e3058a497f43f34f2fcfadf6b63de9211be659.zip
Make it possible to upload files by dropping them onto a drop target (#9277)
Fixes #8891
Diffstat (limited to 'shared/src/main/java/com/vaadin')
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetClientRpc.java37
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetRpc.java37
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetState.java26
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/dnd/FileParameters.java110
4 files changed, 210 insertions, 0 deletions
diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetClientRpc.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetClientRpc.java
new file mode 100644
index 0000000000..479e026cf7
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetClientRpc.java
@@ -0,0 +1,37 @@
+/*
+ * 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.dnd;
+
+import java.util.Map;
+
+import com.vaadin.shared.communication.ClientRpc;
+
+/**
+ * RPC for sending the upload URLs to the client for uploading files.
+ *
+ * @author Vaadin Ltd
+ * @since 8.1
+ */
+public interface FileDropTargetClientRpc extends ClientRpc {
+
+ /**
+ * Sends the of upload URLs mapped to the generated file ID.
+ *
+ * @param urls
+ * File IDs and URLs for uploading files to the server.
+ */
+ void sendUploadUrl(Map<String, String> urls);
+}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetRpc.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetRpc.java
new file mode 100644
index 0000000000..fd290a41f5
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetRpc.java
@@ -0,0 +1,37 @@
+/*
+ * 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.dnd;
+
+import java.util.Map;
+
+import com.vaadin.shared.communication.ServerRpc;
+
+/**
+ * RPC for requesting upload URLs for files dropped on the file drop target.
+ *
+ * @author Vaadin Ltd
+ * @since 8.1
+ */
+public interface FileDropTargetRpc extends ServerRpc {
+
+ /**
+ * Called when files are dropped onto the file drop target.
+ *
+ * @param fileParams
+ * Generated file IDs and file parameters of dropped files.
+ */
+ public void drop(Map<String, FileParameters> fileParams);
+}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetState.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetState.java
new file mode 100644
index 0000000000..d825a4d60f
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/FileDropTargetState.java
@@ -0,0 +1,26 @@
+/*
+ * 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.dnd;
+
+/**
+ * State class containing parameters for FileDropTarget.
+ *
+ * @author Vaadin Ltd
+ * @since 8.1
+ */
+public class FileDropTargetState extends DropTargetState {
+
+}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/FileParameters.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/FileParameters.java
new file mode 100644
index 0000000000..0e4f5cdf76
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/FileParameters.java
@@ -0,0 +1,110 @@
+/*
+ * 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.dnd;
+
+import java.io.Serializable;
+
+/**
+ * Contains parameters of a file. Used for transferring information about
+ * dropped files from the client to the server.
+ *
+ * @author Vaadin Ltd
+ * @since 8.1
+ */
+public class FileParameters implements Serializable {
+ private String name;
+ private long size;
+ private String mime;
+
+ /**
+ * Creates a file parameters object.
+ */
+ public FileParameters() {
+ }
+
+ /**
+ * Creates a file parameters object.
+ *
+ * @param name
+ * Name of the file.
+ * @param size
+ * Size of the file.
+ * @param mime
+ * Mime type of the file.
+ */
+ public FileParameters(String name, long size, String mime) {
+ this.name = name;
+ this.size = size;
+ this.mime = mime;
+ }
+
+ /**
+ * Gets the file name.
+ *
+ * @return Name of the file.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the file name.
+ *
+ * @param name
+ * Name of the file.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Gets the file size.
+ *
+ * @return Size of the file.
+ */
+ public long getSize() {
+ return size;
+ }
+
+ /**
+ * Sets the file size.
+ *
+ * @param size
+ * Size of the file.
+ */
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ /**
+ * Gets the mime type.
+ *
+ * @return Mime type of the file.
+ */
+ public String getMime() {
+ return mime;
+ }
+
+ /**
+ * Sets the mime type.
+ *
+ * @param mime
+ * Mime type of the file.
+ */
+ public void setMime(String mime) {
+ this.mime = mime;
+ }
+}