use of org.activiti.explorer.ui.util.InputStreamStreamSource in project Activiti by Activiti.
the class ProcessDefinitionImageStreamResourceBuilder method buildStreamResource.
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.getAnnotationFontName(), 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());
}
}
return imageResource;
}
use of org.activiti.explorer.ui.util.InputStreamStreamSource in project Activiti by Activiti.
the class ProcessDefinitionImageStreamResourceBuilder method buildStreamResource.
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.getAnnotationFontName(), 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;
}
use of org.activiti.explorer.ui.util.InputStreamStreamSource in project Activiti by Activiti.
the class GenericAttachmentRenderer method getDetailComponent.
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);
HorizontalLayout linkLayout = new HorizontalLayout();
linkLayout.setSpacing(true);
verticalLayout.addComponent(linkLayout);
// Image
linkLayout.addComponent(new Embedded(null, getImage(attachment)));
// Link
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);
}
// Set generic image and external window
link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
linkLayout.addComponent(link);
return verticalLayout;
}
use of org.activiti.explorer.ui.util.InputStreamStreamSource in project Activiti by Activiti.
the class ProcessDefinitionImageStreamResourceBuilder method buildStreamResource.
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;
}
use of org.activiti.explorer.ui.util.InputStreamStreamSource in project Activiti by Activiti.
the class UserProfileLink method initPicture.
protected void initPicture(IdentityService identityService, boolean renderPicture, final String userName) {
if (renderPicture) {
Picture picture = identityService.getUserPicture(userName);
if (picture != null) {
Resource imageResource = new StreamResource(new InputStreamStreamSource(picture.getInputStream()), userName + picture.getMimeType(), ExplorerApp.get());
Embedded image = new Embedded(null, imageResource);
image.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
image.setType(Embedded.TYPE_IMAGE);
image.setHeight(30, Embedded.UNITS_PIXELS);
image.setWidth(30, Embedded.UNITS_PIXELS);
image.addListener(new MouseEvents.ClickListener() {
private static final long serialVersionUID = 7341560240277898495L;
public void click(MouseEvents.ClickEvent event) {
viewManager.showProfilePopup(userName);
}
});
addComponent(image);
setComponentAlignment(image, Alignment.MIDDLE_LEFT);
} else {
// TODO: what when no image is available?
}
}
}
Aggregations