Package com.vaadin.ui

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


 
  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

 
  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

Related Classes of com.vaadin.ui.Html5File

Copyright © 2018 www.massapicom. 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.