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;
}
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);
}
}
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);
}
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);
}
Aggregations