Search in sources :

Example 1 with ProcessDefinitionImageStreamResourceBuilder

use of org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder in project Activiti by Activiti.

the class AdminCompletedInstancesPanel method addProcessImage.

protected void addProcessImage(ProcessDefinition processDefinition, HistoricProcessInstance processInstance) {
    if (currentEmbedded != null) {
        mainPanel.removeComponent(currentEmbedded);
    }
    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinition.getId());
    // Only show when graphical notation is defined
    if (processDefinitionEntity != null && processDefinitionEntity.isGraphicalNotationDefined()) {
        if (imageHeader == null) {
            imageHeader = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
            imageHeader.addStyleName(ExplorerLayout.STYLE_H3);
            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);
    }
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) Embedded(com.vaadin.ui.Embedded) ProcessDefinitionImageStreamResourceBuilder(org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder)

Example 2 with ProcessDefinitionImageStreamResourceBuilder

use of org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder in project Activiti by Activiti.

the class AdminRunningInstancesPanel method addProcessImage.

protected void addProcessImage(ProcessDefinition processDefinition, HistoricProcessInstance processInstance) {
    if (currentEmbedded != null) {
        mainPanel.removeComponent(currentEmbedded);
    }
    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinition.getId());
    // Only show when graphical notation is defined
    if (processDefinitionEntity != null && processDefinitionEntity.isGraphicalNotationDefined()) {
        if (imageHeader == null) {
            imageHeader = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
            imageHeader.addStyleName(ExplorerLayout.STYLE_H3);
            imageHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
            imageHeader.addStyleName(ExplorerLayout.STYLE_NO_LINE);
            addDetailComponent(imageHeader);
        }
        ProcessEngineConfiguration processEngineConfig = ((ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine()).getProcessEngineConfiguration();
        ProcessDiagramGenerator diagramGenerator = processEngineConfig.getProcessDiagramGenerator();
        StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder().buildStreamResource(processInstance.getId(), processInstance.getProcessDefinitionId(), repositoryService, runtimeService, diagramGenerator, processEngineConfig);
        currentEmbedded = new Embedded(null, diagram);
        currentEmbedded.setType(Embedded.TYPE_IMAGE);
        addDetailComponent(currentEmbedded);
    }
}
Also used : ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) StreamResource(com.vaadin.terminal.StreamResource) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) Embedded(com.vaadin.ui.Embedded) ProcessDefinitionImageStreamResourceBuilder(org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl)

Example 3 with ProcessDefinitionImageStreamResourceBuilder

use of org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder in project Activiti by Activiti.

the class ProcessInstanceDetailPanel method addProcessImage.

protected void addProcessImage() {
    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinition.getId());
    // Only show when graphical notation is defined
    if (processDefinitionEntity != null) {
        boolean didDrawImage = false;
        if (ExplorerApp.get().isUseJavascriptDiagram()) {
            try {
                final InputStream definitionStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName());
                XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory();
                XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream);
                BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
                if (!bpmnModel.getFlowLocationMap().isEmpty()) {
                    int maxX = 0;
                    int maxY = 0;
                    for (String key : bpmnModel.getLocationMap().keySet()) {
                        GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key);
                        double elementX = graphicInfo.getX() + graphicInfo.getWidth();
                        if (maxX < elementX) {
                            maxX = (int) elementX;
                        }
                        double elementY = graphicInfo.getY() + graphicInfo.getHeight();
                        if (maxY < elementY) {
                            maxY = (int) elementY;
                        }
                    }
                    // using panel for scrollbars
                    Panel imagePanel = new Panel();
                    imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
                    imagePanel.setWidth(100, UNITS_PERCENTAGE);
                    imagePanel.setHeight(100, UNITS_PERCENTAGE);
                    URL explorerURL = ExplorerApp.get().getURL();
                    URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "diagram-viewer/index.html?processDefinitionId=" + processDefinition.getId() + "&processInstanceId=" + processInstance.getId());
                    Embedded browserPanel = new Embedded("", new ExternalResource(url));
                    browserPanel.setType(Embedded.TYPE_BROWSER);
                    browserPanel.setWidth(maxX + 350 + "px");
                    browserPanel.setHeight(maxY + 220 + "px");
                    HorizontalLayout panelLayoutT = new HorizontalLayout();
                    panelLayoutT.setSizeUndefined();
                    imagePanel.setContent(panelLayoutT);
                    imagePanel.addComponent(browserPanel);
                    panelLayout.addComponent(imagePanel);
                    didDrawImage = true;
                }
            } catch (Exception e) {
                LOGGER.error("Error loading process diagram component", e);
            }
        }
        if (!didDrawImage && processDefinitionEntity.isGraphicalNotationDefined()) {
            ProcessEngineConfiguration processEngineConfiguration = ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration();
            ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
            StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder().buildStreamResource(processInstance, repositoryService, runtimeService, diagramGenerator, processEngineConfiguration);
            if (diagram != null) {
                Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
                header.addStyleName(ExplorerLayout.STYLE_H3);
                header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
                header.addStyleName(ExplorerLayout.STYLE_NO_LINE);
                panelLayout.addComponent(header);
                Embedded embedded = new Embedded(null, diagram);
                embedded.setType(Embedded.TYPE_IMAGE);
                embedded.setSizeUndefined();
                // using panel for scrollbars
                Panel imagePanel = new Panel();
                imagePanel.setScrollable(true);
                imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
                imagePanel.setWidth(100, UNITS_PERCENTAGE);
                imagePanel.setHeight(100, UNITS_PERCENTAGE);
                HorizontalLayout panelLayoutT = new HorizontalLayout();
                panelLayoutT.setSizeUndefined();
                imagePanel.setContent(panelLayoutT);
                imagePanel.addComponent(embedded);
                panelLayout.addComponent(imagePanel);
            }
        }
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) InputStream(java.io.InputStream) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) ExternalResource(com.vaadin.terminal.ExternalResource) URL(java.net.URL) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Panel(com.vaadin.ui.Panel) DetailPanel(org.activiti.explorer.ui.custom.DetailPanel) ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) StreamResource(com.vaadin.terminal.StreamResource) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) Embedded(com.vaadin.ui.Embedded) ProcessDefinitionImageStreamResourceBuilder(org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Aggregations

StreamResource (com.vaadin.terminal.StreamResource)3 Embedded (com.vaadin.ui.Embedded)3 Label (com.vaadin.ui.Label)3 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)3 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)3 ProcessDefinitionImageStreamResourceBuilder (org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder)3 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)2 ProcessDiagramGenerator (org.activiti.image.ProcessDiagramGenerator)2 ExternalResource (com.vaadin.terminal.ExternalResource)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Panel (com.vaadin.ui.Panel)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)1 ProcessEngineImpl (org.activiti.engine.impl.ProcessEngineImpl)1 DetailPanel (org.activiti.explorer.ui.custom.DetailPanel)1