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

项目:vaadin-fluent-api    文件:FUploadTest.java   
@Test
public void test() {
    FUpload upload = new FUpload().withButtonCaption("file")
                                  .withImmediateMode(false)
                                  .withFailedListener(event -> System.out.println("failed"))
                                  .withFinishedListener(event -> System.out.println("finished"))
                                  .withChangeListener(event -> System.out.println("changed"))
                                  .withSucceededListener(event -> System.out.println("succeeded"))
                                  .withProgressListener((readBytes, contentLength) -> System.out.println("progress"));

    assertEquals("file", upload.getButtonCaption());
    assertFalse(upload.isImmediateMode());
    assertEquals(1, upload.getListeners(FailedEvent.class).size());
    assertTrue(upload.getListeners(FinishedEvent.class).size() > 0);
    assertEquals(1, upload.getListeners(ChangeEvent.class).size());
    assertEquals(1, upload.getListeners(SucceededEvent.class).size());
    assertEquals(1, upload.getListeners(StreamingProgressEvent.class).size());
}
项目: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;
}
项目:garantia    文件:UploadInfoWindow.java   
@Override
public void uploadFinished(final FinishedEvent event) {
    state.setValue("Finalizado");
    progressBar.setVisible(false);
    textualProgress.setVisible(false);
    cancelButton.setVisible(false);
}
项目:hawkbit    文件:UploadHandler.java   
/**
 * Upload finished for {@link Upload} variant. Both for good and error
 * variant.
 *
 * @see com.vaadin.ui.Upload.FinishedListener#uploadFinished(com.vaadin.ui.Upload.FinishedEvent)
 */
@Override
public void uploadFinished(final FinishedEvent event) {
    LOG.debug("Upload finished for file :{}", event.getFilename());
    eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_FINISHED,
            new UploadFileStatus(event.getFilename())));
}
项目: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();
    }
  });
}
项目: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();
    }
  });
}
项目:enterprise-app    文件:DownloadField.java   
public void uploadFinishedEvent(FinishedEvent event) {
    try {
        setValue(uploadField.getValue());
        fileName = event.getFilename();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:own-music-cloud    文件:MusicUploader.java   
@Override
public void uploadFinished(FinishedEvent event) {
    setComponentsToVisible(false);
    Window.removeFromParent(this);
    indexerService.startIndexer();
    new Notification("Finished upload" + event.getFilename(), null, //$NON-NLS-1$
            Notification.Type.TRAY_NOTIFICATION).show(Page.getCurrent());
    callback.onUploadFinished();

}
项目:osc-core    文件:UploadInfoWindow.java   
@Override
public void uploadFinished(final FinishedEvent event) {
    this.progressBar.setVisible(false);
    this.bytesProcessed.setVisible(false);
    this.cancelButton.setVisible(false);
}
项目: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);
}
项目:SecureBPMN    文件:DeploymentUploadReceiver.java   
public void uploadFinished(FinishedEvent event) {
  deployUploadedFile();
  if (validFile) {
    showUploadedDeployment();
  }
}
项目:vaadinInvoiceGenerator    文件:UploadComponent.java   
@Override
public void uploadFinished(FinishedEvent event) {
    processingLayout.setVisible(false);
}
项目: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);
}
项目:FiWare-Template-Handler    文件:DeploymentUploadReceiver.java   
public void uploadFinished(FinishedEvent event) {
  deployUploadedFile();
  if (validFile) {
    showUploadedDeployment();
  }
}
项目:enterprise-app    文件:DefaultCrudFieldFactory.java   
/**
 * Creates a field to download/upload a file.
 * @param bean bean to which the field belongs.
 * @param pid property name.
 * @param uiContext the component where the field is presented.
 * @param downloadableAnnotation
 * @return a new download/upload field for the specified property.
 * @throws SecurityException
 * @throws NoSuchMethodException
 */
public Field createDownloadableField(final Object bean, final String pid, Component uiContext, final Downloadable downloadableAnnotation) throws SecurityException, NoSuchMethodException {
    DownloadField field = null;

    if(downloadableAnnotation != null) {
        String capitalizedFileNameField = downloadableAnnotation.propertyFileName().substring(0, 1).toUpperCase() + downloadableAnnotation.propertyFileName().substring(1, downloadableAnnotation.propertyFileName().length());

        final Method setFileNameMethod = bean.getClass().getMethod("set" + capitalizedFileNameField, String.class);
        final Method getFileNameMethod = bean.getClass().getMethod("get" + capitalizedFileNameField, (Class<?>[]) null);

        field = new DownloadField(EnterpriseApplication.getInstance()) {
            private static final long serialVersionUID = 1L;

            @Override
            public void uploadFinishedEvent(FinishedEvent event) {
                super.uploadFinishedEvent(event);
                try {
                    setFileNameMethod.invoke(bean, event.getFilename());

                } catch (IllegalArgumentException e) {
                    throw new RuntimeException(e);
                } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
                } catch (InvocationTargetException e) {
                    throw new RuntimeException(e);
                }
            }

            @Override
            public String getFileName() {
                String name = "file";
                try {
                    name = getFileNameMethod.invoke(bean, (Object[]) null) + downloadableAnnotation.fileNameSufix();

                } catch (IllegalArgumentException e) {
                    throw new RuntimeException(e);
                } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
                } catch (InvocationTargetException e) {
                    throw new RuntimeException(e);
                }

                return name;
            }
        };
    }

    return field;
}