Java 类com.vaadin.ui.Upload.FinishedListener 实例源码

项目:SecureBPMN    文件:ProfilePanel.java   
protected Upload initChangePictureButton() {
  final Upload changePictureUpload = new Upload();
  changePictureUpload.setImmediate(true);
  changePictureUpload.setButtonCaption(i18nManager.getMessage(Messages.PROFILE_CHANGE_PICTURE));

  final InMemoryUploadReceiver receiver = initPictureReceiver(changePictureUpload);
  changePictureUpload.addListener(new FinishedListener() {
    private static final long serialVersionUID = 1L;
    public void uploadFinished(FinishedEvent event) {
      if (!receiver.isInterruped()) {
        picture = new Picture(receiver.getBytes(), receiver.getMimeType());
        identityService.setUserPicture(userId, picture);

        // reset picture
        imageLayout.removeAllComponents();
        initPicture();
      } else {
        receiver.reset();
      }
    }
  });

  return changePictureUpload;
}
项目:FiWare-Template-Handler    文件:ProfilePanel.java   
protected Upload initChangePictureButton() {
  final Upload changePictureUpload = new Upload();
  changePictureUpload.setImmediate(true);
  changePictureUpload.setButtonCaption(i18nManager.getMessage(Messages.PROFILE_CHANGE_PICTURE));

  final InMemoryUploadReceiver receiver = initPictureReceiver(changePictureUpload);
  changePictureUpload.addListener(new FinishedListener() {
    private static final long serialVersionUID = 1L;
    public void uploadFinished(FinishedEvent event) {
      if (!receiver.isInterruped()) {
        picture = new Picture(receiver.getBytes(), receiver.getMimeType());
        identityService.setUserPicture(userId, picture);

        // reset picture
        imageLayout.removeAllComponents();
        initPicture();
      } else {
        receiver.reset();
      }
    }
  });

  return changePictureUpload;
}
项目:SecureBPMN    文件:UploadComponent.java   
protected void addUpload() {
  this.upload = new Upload(null, receiver);
  upload.setButtonCaption(i18nManager.getMessage(Messages.UPLOAD_SELECT));
  upload.setImmediate(true);
  addComponent(upload);
  setComponentAlignment(upload, Alignment.MIDDLE_CENTER);

  // register ourselves as listener for upload events
  upload.addListener((StartedListener) this);
  upload.addListener((FailedListener) this);
  upload.addListener((FinishedListener) this);
  upload.addListener((ProgressListener) this);
}
项目:SecureBPMN    文件:UploadComponent.java   
public void uploadFinished(FinishedEvent event) {
  // Hide progress indicator
  progressIndicator.setVisible(false);
  for (FinishedListener finishedListener : finishedListeners) {
    finishedListener.uploadFinished(event);
  }
}
项目:SecureBPMN    文件:UploadPopupWindow.java   
public UploadPopupWindow(String caption, String description, Receiver receiver) {
  this.i18nManager = ExplorerApp.get().getI18nManager();

  init(caption, description, receiver);

  uploadComponent.addFinishedListener(new FinishedListener() {

    private static final long serialVersionUID = 1L;

    public void uploadFinished(FinishedEvent event) {
      close();
    }
  });
}
项目:vaadinInvoiceGenerator    文件:UploadComponent.java   
public UploadComponent(String buttonCaption, String sessionId, int maxSize, String folderPath) {
     upload = new Upload();
     this.addComponent(upload);
     this.maxSize = maxSize;
     upload.setReceiver( this); 
     this.directory = folderPath;
     upload.setButtonCaption(buttonCaption);
     upload.addSucceededListener((Upload.SucceededListener) this);
     upload.addFailedListener((Upload.FailedListener) this);
     upload.addProgressListener((Upload.ProgressListener) this);
     upload.addFinishedListener((Upload.FinishedListener) this);

     processingLayout = new HorizontalLayout();
     processingLayout.setSpacing(true);
     processingLayout.setVisible(false);
     this.addComponent(processingLayout);

     progressBar = new ProgressBar();
     processingLayout.addComponent(progressBar);

     cancelProcessing = new Button("cancel", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
    cancelled = true;
             upload.interruptUpload();

}
     });
     processingLayout.addComponent(cancelProcessing);
 }
项目:FiWare-Template-Handler    文件:UploadComponent.java   
protected void addUpload() {
  this.upload = new Upload(null, receiver);
  upload.setButtonCaption(i18nManager.getMessage(Messages.UPLOAD_SELECT));
  upload.setImmediate(true);
  addComponent(upload);
  setComponentAlignment(upload, Alignment.MIDDLE_CENTER);

  // register ourselves as listener for upload events
  upload.addListener((StartedListener) this);
  upload.addListener((FailedListener) this);
  upload.addListener((FinishedListener) this);
  upload.addListener((ProgressListener) this);
}
项目:FiWare-Template-Handler    文件:UploadComponent.java   
public void uploadFinished(FinishedEvent event) {
  // Hide progress indicator
  progressIndicator.setVisible(false);
  for (FinishedListener finishedListener : finishedListeners) {
    finishedListener.uploadFinished(event);
  }
}
项目:FiWare-Template-Handler    文件:UploadPopupWindow.java   
public UploadPopupWindow(String caption, String description, Receiver receiver) {
  this.i18nManager = ExplorerApp.get().getI18nManager();

  init(caption, description, receiver);

  uploadComponent.addFinishedListener(new FinishedListener() {

    private static final long serialVersionUID = 1L;

    public void uploadFinished(FinishedEvent event) {
      close();
    }
  });
}
项目:SecureBPMN    文件:UploadComponent.java   
public void addFinishedListener(FinishedListener finishedListener) {
  finishedListeners.add(finishedListener);
}
项目:SecureBPMN    文件:UploadPopupWindow.java   
public void addFinishedListener(FinishedListener finishedListener) {
  uploadComponent.addFinishedListener(finishedListener);
}
项目:SecureBPMN    文件:FileAttachmentEditorComponent.java   
protected void initFileUpload() {
  uploadComponent = new UploadComponent(null, new Receiver() {
    private static final long serialVersionUID = 1L;

    public OutputStream receiveUpload(String filename, String mType) {
      fileName = filename;

      // Try extracting the extention as well, and append it to the mime-type
      String extention = extractExtention(filename);
      if(extention != null) {
        mimeType = mType + MIME_TYPE_EXTENTION_SPLIT_CHAR + extention;
      } else {
        mimeType = mType;
      }

      // TODO: Refactor, don't use BAOS!!
      byteArrayOutputStream = new ByteArrayOutputStream();
      return byteArrayOutputStream;
    }
  });

  uploadComponent.addFinishedListener(new FinishedListener() {

    private static final long serialVersionUID = 1L;

    public void uploadFinished(FinishedEvent event) {
      // Update UI
      if(getAttachmentName() == null || "".equals(getAttachmentName())) {
        setAttachmentName(getFriendlyName(fileName));
      }

      fileUploaded = true;
      successIndicator.setVisible(true);
      successIndicator.setCaption(i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_FILE_UPLOADED, fileName));
      form.setComponentError(null);
    }
  });

  addComponent(uploadComponent);
  setExpandRatio(uploadComponent, 1.0f);
}
项目:FiWare-Template-Handler    文件:UploadComponent.java   
public void addFinishedListener(FinishedListener finishedListener) {
  finishedListeners.add(finishedListener);
}
项目:FiWare-Template-Handler    文件:UploadPopupWindow.java   
public void addFinishedListener(FinishedListener finishedListener) {
  uploadComponent.addFinishedListener(finishedListener);
}
项目:FiWare-Template-Handler    文件:FileAttachmentEditorComponent.java   
protected void initFileUpload() {
  uploadComponent = new UploadComponent(null, new Receiver() {
    private static final long serialVersionUID = 1L;

    public OutputStream receiveUpload(String filename, String mType) {
      fileName = filename;

      // Try extracting the extention as well, and append it to the mime-type
      String extention = extractExtention(filename);
      if(extention != null) {
        mimeType = mType + MIME_TYPE_EXTENTION_SPLIT_CHAR + extention;
      } else {
        mimeType = mType;
      }

      // TODO: Refactor, don't use BAOS!!
      byteArrayOutputStream = new ByteArrayOutputStream();
      return byteArrayOutputStream;
    }
  });

  uploadComponent.addFinishedListener(new FinishedListener() {

    private static final long serialVersionUID = 1L;

    public void uploadFinished(FinishedEvent event) {
      // Update UI
      if(getAttachmentName() == null || "".equals(getAttachmentName())) {
        setAttachmentName(getFriendlyName(fileName));
      }

      fileUploaded = true;
      successIndicator.setVisible(true);
      successIndicator.setCaption(i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_FILE_UPLOADED, fileName));
      form.setComponentError(null);
    }
  });

  addComponent(uploadComponent);
  setExpandRatio(uploadComponent, 1.0f);
}
项目:vaadin-fluent-api    文件:FluentUpload.java   
/**
 * Adds the upload received event listener.
 *
 * @param listener
 *            the Listener to be added, not null
 * @return this for method chaining
 * @see Upload#addFinishedListener(FinishedListener)
 */
@SuppressWarnings("unchecked")
public default THIS withFinishedListener(FinishedListener listener) {
    ((Upload) this).addFinishedListener(listener);
    return (THIS) this;
}