Search in sources :

Example 1 with Html5File

use of com.vaadin.ui.Html5File in project Activiti by Activiti.

the class UploadComponent method drop.

// Drag and drop handling (DropHandler) ---------------------------------------------------------
public void drop(DragAndDropEvent event) {
    WrapperTransferable transferable = (WrapperTransferable) event.getTransferable();
    Html5File[] files = transferable.getFiles();
    if (files != null && files.length > 0) {
        // only support for one file upload at this moment
        final Html5File file = files[0];
        file.setStreamVariable(new StreamVariable() {

            private static final long serialVersionUID = 1L;

            public void streamingStarted(StreamingStartEvent event) {
                // event doesnt matter here
                uploadStarted(null);
            }

            public void streamingFinished(StreamingEndEvent event) {
                // event doesnt matter here
                uploadFinished(null);
            }

            public void streamingFailed(StreamingErrorEvent event) {
                uploadFailed(null);
            }

            public void onProgress(StreamingProgressEvent event) {
                updateProgress(event.getBytesReceived(), event.getContentLength());
            }

            public boolean listenProgress() {
                return true;
            }

            public boolean isInterrupted() {
                return false;
            }

            public OutputStream getOutputStream() {
                return receiver.receiveUpload(file.getFileName(), file.getType());
            }
        });
    }
}
Also used : Html5File(com.vaadin.ui.Html5File) OutputStream(java.io.OutputStream) WrapperTransferable(com.vaadin.ui.DragAndDropWrapper.WrapperTransferable) StreamVariable(com.vaadin.terminal.StreamVariable)

Aggregations

StreamVariable (com.vaadin.terminal.StreamVariable)1 WrapperTransferable (com.vaadin.ui.DragAndDropWrapper.WrapperTransferable)1 Html5File (com.vaadin.ui.Html5File)1 OutputStream (java.io.OutputStream)1