use of org.activiti.explorer.ui.util.InputStreamStreamSource in project Activiti by Activiti.
the class ImageAttachmentRenderer method getDetailComponent.
@Override
public Component getDetailComponent(Attachment attachment) {
VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.setSizeUndefined();
verticalLayout.setSpacing(true);
verticalLayout.setMargin(true);
Label description = new Label(attachment.getDescription());
description.setSizeUndefined();
verticalLayout.addComponent(description);
// Image
TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
String mimeType = extractMineType(attachment.getType());
InputStream imageStream = ImageUtil.resizeImage(taskService.getAttachmentContent(attachment.getId()), mimeType, 900, 550);
Resource resource = new StreamResource(new InputStreamStreamSource(imageStream), attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get());
Embedded image = new Embedded(null, resource);
verticalLayout.addComponent(image);
// Linke
HorizontalLayout LinkLayout = new HorizontalLayout();
LinkLayout.setSpacing(true);
verticalLayout.addComponent(LinkLayout);
verticalLayout.setComponentAlignment(LinkLayout, Alignment.MIDDLE_CENTER);
Label fullSizeLabel = new Label(ExplorerApp.get().getI18nManager().getMessage(Messages.RELATED_CONTENT_SHOW_FULL_SIZE));
LinkLayout.addComponent(fullSizeLabel);
Link link = null;
if (attachment.getUrl() != null) {
link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
} else {
taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
Resource res = new StreamResource(new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())), attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get());
link = new Link(attachment.getName(), res);
}
link.setIcon(Images.RELATED_CONTENT_PICTURE);
link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
LinkLayout.addComponent(link);
return verticalLayout;
}
Aggregations