Search in sources :

Example 1 with InMemoryUploadReceiver

use of org.activiti.explorer.ui.custom.InMemoryUploadReceiver 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 InMemoryUploadReceiver

use of org.activiti.explorer.ui.custom.InMemoryUploadReceiver in project Activiti by Activiti.

the class ProfilePanel method initPictureReceiver.

protected InMemoryUploadReceiver initPictureReceiver(Upload upload) {
    // 100 kb limit
    InMemoryUploadReceiver receiver = new InMemoryUploadReceiver(upload, 102400L);
    upload.setReceiver(receiver);
    receiver.setAcceptedMimeTypes(Constants.DEFAULT_IMAGE_MIMETYPES);
    return receiver;
}
Also used : InMemoryUploadReceiver(org.activiti.explorer.ui.custom.InMemoryUploadReceiver)

Aggregations

InMemoryUploadReceiver (org.activiti.explorer.ui.custom.InMemoryUploadReceiver)2 Upload (com.vaadin.ui.Upload)1 FinishedEvent (com.vaadin.ui.Upload.FinishedEvent)1 FinishedListener (com.vaadin.ui.Upload.FinishedListener)1 Picture (org.activiti.engine.identity.Picture)1