Package com.vaadin.terminal

Examples of com.vaadin.terminal.StreamResource


      }
    }
   
    if(didDrawImage == false) {
     
      StreamResource diagram = null;
     
      // Try generating process-image stream
      if(processDefinition.getDiagramResourceName() != null) {
         diagram = new ProcessDefinitionImageStreamResourceBuilder()
          .buildStreamResource(processDefinition, repositoryService);
View Full Code Here


  protected void addTaskEventPicture(final org.activiti.engine.task.Event taskEvent, GridLayout eventGrid) {
    final Picture userPicture = identityService.getUserPicture(taskEvent.getUserId());
    Embedded authorPicture = null;
   
    if (userPicture != null) {
      StreamResource imageresource = new StreamResource(new StreamSource() {
        private static final long serialVersionUID = 1L;
        public InputStream getStream() {
          return userPicture.getInputStream();
        }
      }, "event_" + taskEvent.getUserId() + "." + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()), ExplorerApp.get());
View Full Code Here

 
  protected static final Logger LOGGER = LoggerFactory.getLogger(ProcessDefinitionImageStreamResourceBuilder.class);
 
  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

  }

  public StreamResource buildStreamResource(ProcessInstance processInstance, RepositoryService repositoryService,
      RuntimeService runtimeService, ProcessDiagramGenerator diagramGenerator, ProcessEngineConfiguration processEngineConfig) {

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

    if (processDefinition != null && processDefinition.isGraphicalNotationDefined()) {
      try {
       
        BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
        InputStream definitionImageStream = diagramGenerator.generateDiagram(bpmnModel, "png",
          runtimeService.getActiveActivityIds(processInstance.getId()), Collections.<String>emptyList(),
          processEngineConfig.getActivityFontName(), processEngineConfig.getLabelFontName(),
          processEngineConfig.getClassLoader(), 1.0);
             
        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.warn("Process image cannot be generated due to exception: {} - {}", t.getClass().getName(), t.getMessage());
      }
View Full Code Here

 
  public StreamResource buildStreamResource(String processInstanceId, String processDefinitionId,
      RepositoryService repositoryService, RuntimeService runtimeService, ProcessDiagramGenerator diagramGenerator,
      ProcessEngineConfiguration processEngineConfig) {

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

    if (processDefinition != null && processDefinition.isGraphicalNotationDefined()) {
     
      BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
      InputStream definitionImageStream = diagramGenerator.generateDiagram(bpmnModel, "png",
        runtimeService.getActiveActivityIds(processInstanceId), Collections.<String>emptyList(),
        processEngineConfig.getActivityFontName(), processEngineConfig.getLabelFontName(),
        processEngineConfig.getClassLoader(), 1.0);
     
      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

        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

  protected void loadPicture() {
    Component pictureComponent = null;
    final Picture userPicture = identityService.getUserPicture(user.getId());
    if (userPicture != null) {
      StreamResource imageresource = new StreamResource(new StreamSource() {
        private static final long serialVersionUID = 1L;
        public InputStream getStream() {
          return userPicture.getInputStream();
        }
      }, user.getId() + "." + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()), ExplorerApp.get());
View Full Code Here

    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);
    }
   
View Full Code Here

    protected void addUserPicture() {
      Resource pictureResource = Images.USER_32; // default icon
      if (user != null) {
        final Picture userPicture = identityService.getUserPicture(user.getId());
        if (userPicture != null) {
          pictureResource = new StreamResource(new StreamSource() {       
            public InputStream getStream() {
              return userPicture.getInputStream();
            }
          }, user.getId(), ExplorerApp.get());
         
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.