Package com.vaadin.terminal

Examples of com.vaadin.terminal.StreamResource


    Link link = null;
    if(attachment.getUrl() != null) {
      link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
      TaskService 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);
    }
   
View Full Code Here


 
  protected static final Logger LOGGER = Logger.getLogger(ProcessDefinitionImageStreamResourceBuilder.class.getName());
 
  public StreamResource buildStreamResource(ProcessDefinition processDefinition, RepositoryService repositoryService) {
   
    StreamResource imageResource = null;
   
    if(processDefinition.getDiagramResourceName() != null) {
      final InputStream definitionImageStream = repositoryService.getResourceAsStream(
        processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName());
     
      StreamSource streamSource = new InputStreamStreamSource(definitionImageStream);
     
      // Creating image name based on process-definition ID is fine, since the diagram image cannot
      // be altered once deployed.
      String imageExtension = extractImageExtension(processDefinition.getDiagramResourceName());
      String fileName = processDefinition.getId() + "." + imageExtension;
     
      imageResource = new StreamResource(streamSource, fileName, ExplorerApp.get());
    }
   
    return imageResource;
  }
View Full Code Here

    return imageResource;
  }

  public StreamResource buildStreamResource(ProcessInstance processInstance, RepositoryService repositoryService, RuntimeService runtimeService) {

    StreamResource imageResource = null;
   
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processInstance
            .getProcessDefinitionId());

    if (processDefinition != null && processDefinition.isGraphicalNotationDefined()) {
      try {
        InputStream definitionImageStream = ProcessDiagramGenerator.generateDiagram(processDefinition, "png",
                runtimeService.getActiveActivityIds(processInstance.getId()));
             
        if(definitionImageStream != null) {
          StreamSource streamSource = new InputStreamStreamSource(definitionImageStream);
         
          // Create image name
          String imageExtension = extractImageExtension(processDefinition.getDiagramResourceName());
          String fileName = processInstance.getId() + UUID.randomUUID() + "." + imageExtension;
         
          imageResource = new StreamResource(streamSource, fileName, ExplorerApp.get());
        }
      } catch(Throwable t) {
        // Image can't be generated, ignore this
        LOGGER.warning("Process image cannot be generated due to exception: " + t.getClass().getName() + " - " + t.getMessage());
      }
View Full Code Here

    return imageResource;
  }
 
  public StreamResource buildStreamResource(String processInstanceId, String processDefinitionId, RepositoryService repositoryService, RuntimeService runtimeService) {

    StreamResource imageResource = null;
   
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionId);

    if (processDefinition != null && processDefinition.isGraphicalNotationDefined()) {
      InputStream definitionImageStream = ProcessDiagramGenerator.generateDiagram(processDefinition, "png",
        runtimeService.getActiveActivityIds(processInstanceId));
     
      StreamSource streamSource = new InputStreamStreamSource(definitionImageStream);
     
      // Create image name
      String imageExtension = extractImageExtension(processDefinition.getDiagramResourceName());
      String fileName = processInstanceId + UUID.randomUUID() + "." + imageExtension;
     
      imageResource = new StreamResource(streamSource, fileName, ExplorerApp.get());
    }
    return imageResource;
  }
View Full Code Here

    profilePanelLayout.addComponent(imageLayout);
    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);
View Full Code Here

   
    Label processTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
    processTitle.addStyleName(ExplorerLayout.STYLE_H3);
    processImageContainer.addComponent(processTitle);
   
    StreamResource diagram = null;
   
    // Try generating process-image stream
    if(processDefinition.getDiagramResourceName() != null) {
       diagram = new ProcessDefinitionImageStreamResourceBuilder()
        .buildStreamResource(processDefinition, repositoryService);
View Full Code Here

    TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
   
    String mimeType = extractMineType(attachment.getType());
   
    InputStream imageStream = ImageUtil.smallify(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);
    }
   
View Full Code Here

        StreamResource.StreamSource streamSource = new StreamSource() {
          public InputStream getStream() {
            return repositoryService.getResourceAsStream(deployment.getId(), resourceName);
          }
        };
        Link resourceLink = new Link(resourceName, new StreamResource(streamSource, resourceName, ExplorerApp.get()));
        resourceLinksLayout.addComponent(resourceLink);
      }
    }
  }
View Full Code Here

        imageHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
        imageHeader.addStyleName(ExplorerLayout.STYLE_NO_LINE);
        addDetailComponent(imageHeader);
      }
     
      StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder()
          .buildStreamResource(processDefinition, repositoryService);

      currentEmbedded = new Embedded(null, diagram);
      currentEmbedded.setType(Embedded.TYPE_IMAGE);
      addDetailComponent(currentEmbedded);
View Full Code Here

    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
      .getDeployedProcessDefinition(processDefinition.getId());

    // Only show when graphical notation is defined
    if (processDefinitionEntity != null && processDefinitionEntity.isGraphicalNotationDefined()) {
      StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder()
        .buildStreamResource(processInstance, repositoryService, runtimeService);

      if(diagram != null) {
        Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
        header.addStyleName(ExplorerLayout.STYLE_H3);
View Full Code Here

TOP

Related Classes of com.vaadin.terminal.StreamResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.