Search in sources :

Example 1 with Upload

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

the class ProfilePanel method initChangePictureButton.

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;
}
Also used : InMemoryUploadReceiver(org.activiti.explorer.ui.custom.InMemoryUploadReceiver) FinishedEvent(com.vaadin.ui.Upload.FinishedEvent) Picture(org.activiti.engine.identity.Picture) Upload(com.vaadin.ui.Upload) FinishedListener(com.vaadin.ui.Upload.FinishedListener)

Example 2 with Upload

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

the class ProfilePanel method initPicture.

protected void initPicture() {
    StreamResource imageresource = new StreamResource(new StreamSource() {

        private static final long serialVersionUID = 1L;

        public InputStream getStream() {
            return picture.getInputStream();
        }
    }, user.getId(), ExplorerApp.get());
    imageresource.setCacheTime(0);
    Embedded picture = new Embedded(null, imageresource);
    picture.setType(Embedded.TYPE_IMAGE);
    picture.setHeight(200, UNITS_PIXELS);
    picture.setWidth(200, UNITS_PIXELS);
    picture.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE);
    imageLayout.addComponent(picture);
    imageLayout.setWidth(picture.getWidth() + 5, picture.getWidthUnits());
    // Change picture button
    if (isCurrentLoggedInUser) {
        Upload changePictureButton = initChangePictureButton();
        imageLayout.addComponent(changePictureButton);
        imageLayout.setComponentAlignment(changePictureButton, Alignment.MIDDLE_CENTER);
    }
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) InputStream(java.io.InputStream) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) Upload(com.vaadin.ui.Upload) Embedded(com.vaadin.ui.Embedded)

Example 3 with Upload

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

the class ImportComponent method addUpload.

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);
}
Also used : Upload(com.vaadin.ui.Upload)

Example 4 with Upload

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

the class UploadComponent method addUpload.

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);
}
Also used : Upload(com.vaadin.ui.Upload)

Aggregations

Upload (com.vaadin.ui.Upload)4 StreamResource (com.vaadin.terminal.StreamResource)1 StreamSource (com.vaadin.terminal.StreamResource.StreamSource)1 Embedded (com.vaadin.ui.Embedded)1 FinishedEvent (com.vaadin.ui.Upload.FinishedEvent)1 FinishedListener (com.vaadin.ui.Upload.FinishedListener)1 InputStream (java.io.InputStream)1 Picture (org.activiti.engine.identity.Picture)1 InMemoryUploadReceiver (org.activiti.explorer.ui.custom.InMemoryUploadReceiver)1