Search in sources :

Example 16 with StreamResource

use of com.vaadin.terminal.StreamResource 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;
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) TaskService(org.activiti.engine.TaskService) InputStream(java.io.InputStream) Label(com.vaadin.ui.Label) StreamResource(com.vaadin.terminal.StreamResource) ExternalResource(com.vaadin.terminal.ExternalResource) Resource(com.vaadin.terminal.Resource) VerticalLayout(com.vaadin.ui.VerticalLayout) Embedded(com.vaadin.ui.Embedded) ExternalResource(com.vaadin.terminal.ExternalResource) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) Link(com.vaadin.ui.Link) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

StreamResource (com.vaadin.terminal.StreamResource)16 Embedded (com.vaadin.ui.Embedded)12 StreamSource (com.vaadin.terminal.StreamResource.StreamSource)9 InputStream (java.io.InputStream)9 Label (com.vaadin.ui.Label)8 InputStreamStreamSource (org.activiti.explorer.ui.util.InputStreamStreamSource)6 HorizontalLayout (com.vaadin.ui.HorizontalLayout)5 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)5 ExternalResource (com.vaadin.terminal.ExternalResource)4 Resource (com.vaadin.terminal.Resource)4 VerticalLayout (com.vaadin.ui.VerticalLayout)4 BpmnModel (org.activiti.bpmn.model.BpmnModel)4 Picture (org.activiti.engine.identity.Picture)4 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)4 Link (com.vaadin.ui.Link)3 Panel (com.vaadin.ui.Panel)3 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)3 ProcessDefinitionImageStreamResourceBuilder (org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder)3 ProcessDiagramGenerator (org.activiti.image.ProcessDiagramGenerator)3 URL (java.net.URL)2