Examples of Html5File


Examples of com.vaadin.ui.DragAndDropWrapper.WrapperTransferable.Html5File

     * @param fileId
     * @throws UploadException
     */
    public void receiveFile(UploadStream upstream, String fileId)
            throws UploadException {
        Html5File file = receivers.get(fileId);
        if (file != null && file.receiver != null) {
            OutputStream receiveUpload = file.receiver.receiveUpload(
                    file.getFileName(), "TODO");

            InputStream stream = upstream.getStream();
            byte[] buf = new byte[AbstractApplicationServlet.MAX_BUFFER_SIZE];
            int bytesRead;
            try {
View Full Code Here

Examples of com.vaadin.ui.DragAndDropWrapper.WrapperTransferable.Html5File

            super(sourceComponent, rawVariables);
            Integer fc = (Integer) rawVariables.get("filecount");
            if (fc != null) {
                files = new Html5File[fc];
                for (int i = 0; i < fc; i++) {
                    Html5File file = new Html5File();
                    String id = (String) rawVariables.get("fi" + i);
                    file.name = (String) rawVariables.get("fn" + i);
                    file.size = (Integer) rawVariables.get("fs" + i);
                    file.type = (String) rawVariables.get("ft" + i);
                    files[i] = file;
View Full Code Here

Examples of com.vaadin.ui.DragAndDropWrapper.WrapperTransferable.Html5File

            super(sourceComponent, rawVariables);
            Integer fc = (Integer) rawVariables.get("filecount");
            if (fc != null) {
                files = new Html5File[fc];
                for (int i = 0; i < fc; i++) {
                    Html5File file = new Html5File();
                    String id = (String) rawVariables.get("fi" + i);
                    file.name = (String) rawVariables.get("fn" + i);
                    file.size = (Integer) rawVariables.get("fs" + i);
                    file.type = (String) rawVariables.get("ft" + i);
                    files[i] = file;
View Full Code Here

Examples of com.vaadin.ui.DragAndDropWrapper.WrapperTransferable.Html5File

     * @param fileId
     * @throws UploadException
     */
    public void receiveFile(UploadStream upstream, String fileId)
            throws UploadException {
        Html5File file = receivers.get(fileId);
        if (file != null && file.receiver != null) {
            OutputStream receiveUpload = file.receiver.receiveUpload(file
                    .getFileName(), "TODO");

            InputStream stream = upstream.getStream();
            byte[] buf = new byte[AbstractApplicationServlet.MAX_BUFFER_SIZE];
            int bytesRead;
View Full Code Here

Examples of com.vaadin.ui.Html5File

                        .getTransferable();
                Html5File[] files = transferable.getFiles();
                if (files != null) {

                    for (int i = 0; i < files.length; i++) {
                        Html5File file = files[i];
                        // Max 1 MB files are uploaded
                        if (file.getFileSize() > 1024 * 1024) {
                            getMainWindow()
                                    .showNotification(
                                            "File "
                                                    + file.getFileName()
                                                    + " was too large, not transferred to the server side.");
                            continue;
                        }

                        StreamVariable streamVariable = new StreamVariable() {

                            @Override
                            public OutputStream getOutputStream() {
                                return new NullOutputStream();
                            }

                            @Override
                            public boolean listenProgress() {
                                return true;
                            }

                            @Override
                            public void onProgress(StreamingProgressEvent event) {
                                System.err.println("Progress"
                                        + event.getBytesReceived());
                            }

                            @Override
                            public void streamingStarted(
                                    StreamingStartEvent event) {
                                getMainWindow().showNotification(
                                        "Started uploading "
                                                + event.getFileName());
                            }

                            @Override
                            public void streamingFinished(
                                    StreamingEndEvent event) {
                                getMainWindow().showNotification(
                                        "Finished uploading "
                                                + event.getFileName());
                            }

                            @Override
                            public void streamingFailed(
                                    StreamingErrorEvent event) {
                                getMainWindow().showNotification(
                                        "Failed uploading "
                                                + event.getFileName());
                            }

                            @Override
                            public boolean isInterrupted() {
                                return false;
                            }
                        };
                        file.setStreamVariable(streamVariable);
                    }
                }

            }
        });
View Full Code Here

Examples of com.vaadin.ui.Html5File

 
  public void drop(DragAndDropEvent event) {
    WrapperTransferable transferable = (WrapperTransferable) event.getTransferable();
    Html5File[] files = transferable.getFiles();
    if (files != null && files.length > 0) {
      final Html5File file = files[0]; // only support for one file upload at this moment
      file.setStreamVariable(new StreamVariable() {
       
        private static final long serialVersionUID = 1L;
       
        public void streamingStarted(StreamingStartEvent event) {
          uploadStarted(null); // event doesnt matter here
        }
        public void streamingFinished(StreamingEndEvent event) {
          uploadFinished(null); // event doesnt matter here
        }
        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());
        }
      });
    }
  }
View Full Code Here

Examples of com.vaadin.ui.Html5File

 
  public void drop(DragAndDropEvent event) {
    WrapperTransferable transferable = (WrapperTransferable) event.getTransferable();
    Html5File[] files = transferable.getFiles();
    if (files.length > 0) {
      final Html5File file = files[0]; // only support for one file upload at this moment
      file.setStreamVariable(new StreamVariable() {
       
        private static final long serialVersionUID = 1L;
       
        public void streamingStarted(StreamingStartEvent event) {
          uploadStarted(null); // event doesnt matter here
        }
        public void streamingFinished(StreamingEndEvent event) {
          uploadFinished(null); // event doesnt matter here
        }
        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());
        }
      });
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.