Search in sources :

Example 26 with Embedded

use of com.vaadin.ui.Embedded in project Activiti by Activiti.

the class ProcessDefinitionInfoComponent method initImage.

protected void initImage() {
    processImageContainer = new VerticalLayout();
    Label processTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
    processTitle.addStyleName(ExplorerLayout.STYLE_H3);
    processImageContainer.addComponent(processTitle);
    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());
                Embedded browserPanel = new Embedded("", new ExternalResource(url));
                browserPanel.setType(Embedded.TYPE_BROWSER);
                browserPanel.setWidth(maxX + 350 + "px");
                browserPanel.setHeight(maxY + 220 + "px");
                HorizontalLayout panelLayout = new HorizontalLayout();
                panelLayout.setSizeUndefined();
                imagePanel.setContent(panelLayout);
                imagePanel.addComponent(browserPanel);
                processImageContainer.addComponent(imagePanel);
                didDrawImage = true;
            }
        } catch (Exception e) {
            LOGGER.error("Error loading process diagram component", e);
        }
    }
    if (didDrawImage == false) {
        StreamResource diagram = null;
        // Try generating process-image stream
        if (processDefinition.getDiagramResourceName() != null) {
            diagram = new ProcessDefinitionImageStreamResourceBuilder().buildStreamResource(processDefinition, repositoryService);
        }
        if (diagram != null) {
            Embedded embedded = new Embedded(null, diagram);
            embedded.setType(Embedded.TYPE_IMAGE);
            embedded.setSizeUndefined();
            // using panel for scrollbars
            Panel imagePanel = new Panel();
            imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
            imagePanel.setWidth(100, UNITS_PERCENTAGE);
            imagePanel.setHeight(100, UNITS_PERCENTAGE);
            HorizontalLayout panelLayout = new HorizontalLayout();
            panelLayout.setSizeUndefined();
            imagePanel.setContent(panelLayout);
            imagePanel.addComponent(embedded);
            processImageContainer.addComponent(imagePanel);
            didDrawImage = true;
        }
    }
    if (didDrawImage == false) {
        Label noImageAvailable = new Label(i18nManager.getMessage(Messages.PROCESS_NO_DIAGRAM));
        processImageContainer.addComponent(noImageAvailable);
    }
    addComponent(processImageContainer);
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) InputStream(java.io.InputStream) Label(com.vaadin.ui.Label) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) 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) StreamResource(com.vaadin.terminal.StreamResource) VerticalLayout(com.vaadin.ui.VerticalLayout) Embedded(com.vaadin.ui.Embedded) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Example 27 with Embedded

use of com.vaadin.ui.Embedded in project Activiti by Activiti.

the class HistoricTaskDetailPanel method initHeader.

protected void initHeader() {
    GridLayout taskDetails = new GridLayout(5, 2);
    taskDetails.setWidth(100, UNITS_PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);
    taskDetails.setMargin(false, false, true, false);
    // Add image
    Embedded image = new Embedded(null, Images.TASK_50);
    taskDetails.addComponent(image, 0, 0, 0, 1);
    // Add task name
    Label nameLabel = new Label(historicTask.getName());
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0, 4, 0);
    // Add due date
    PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_DUEDATE_SHORT), historicTask.getDueDate(), i18nManager.getMessage(Messages.TASK_DUEDATE_UNKNOWN), false);
    dueDateLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_DUEDATE);
    taskDetails.addComponent(dueDateLabel, 1, 1);
    // Add priority
    Integer lowMedHighPriority = convertPriority(historicTask.getPriority());
    Label priorityLabel = new Label();
    switch(lowMedHighPriority) {
        case 1:
            priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_LOW));
            priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_LOW);
            break;
        case 2:
            priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_MEDIUM));
            priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_MEDIUM);
            break;
        case 3:
        default:
            priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_HIGH));
            priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_HIGH);
    }
    taskDetails.addComponent(priorityLabel, 2, 1);
    // Add create date
    PrettyTimeLabel createLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_CREATED_SHORT), historicTask.getStartTime(), "", true);
    createLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_CREATE_TIME);
    taskDetails.addComponent(createLabel, 3, 1);
    // Add label to fill excess space
    Label spacer = new Label();
    spacer.setContentMode(Label.CONTENT_XHTML);
    spacer.setValue("&nbsp;");
    spacer.setSizeUndefined();
    taskDetails.addComponent(spacer);
    taskDetails.setColumnExpandRatio(1, 1.0f);
    taskDetails.setColumnExpandRatio(2, 1.0f);
    taskDetails.setColumnExpandRatio(3, 1.0f);
    taskDetails.setColumnExpandRatio(4, 1.0f);
    centralLayout.addComponent(taskDetails);
}
Also used : GridLayout(com.vaadin.ui.GridLayout) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) Embedded(com.vaadin.ui.Embedded) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel)

Example 28 with Embedded

use of com.vaadin.ui.Embedded in project Activiti by Activiti.

the class JobDetailPanel method addHeader.

protected void addHeader() {
    GridLayout jobDetails = new GridLayout(3, 2);
    jobDetails.setWidth(100, UNITS_PERCENTAGE);
    jobDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    jobDetails.setSpacing(true);
    jobDetails.setMargin(false, false, true, false);
    // Add image
    Embedded image = new Embedded(null, Images.JOB_50);
    jobDetails.addComponent(image, 0, 0, 0, 1);
    // Add job name
    Label nameLabel = new Label(getJobLabel(job));
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    jobDetails.addComponent(nameLabel, 1, 0, 2, 0);
    // Add due date
    PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.JOB_DUEDATE), job.getDuedate(), i18nManager.getMessage(Messages.JOB_NO_DUEDATE), false);
    dueDateLabel.addStyleName(ExplorerLayout.STYLE_JOB_HEADER_DUE_DATE);
    jobDetails.addComponent(dueDateLabel, 1, 1);
    jobDetails.setColumnExpandRatio(1, 1.0f);
    jobDetails.setColumnExpandRatio(2, 1.0f);
    addDetailComponent(jobDetails);
}
Also used : GridLayout(com.vaadin.ui.GridLayout) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) Embedded(com.vaadin.ui.Embedded) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel)

Example 29 with Embedded

use of com.vaadin.ui.Embedded in project Activiti by Activiti.

the class DatabaseDetailPanel method addTableName.

protected void addTableName() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth(100, UNITS_PERCENTAGE);
    header.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    header.setSpacing(true);
    // TODO: use right image
    Embedded image = new Embedded(null, Images.DATABASE_50);
    header.addComponent(image);
    header.setComponentAlignment(image, Alignment.MIDDLE_LEFT);
    header.setMargin(false, false, true, false);
    Label name = new Label(tableName);
    name.addStyleName(Reindeer.LABEL_H2);
    header.addComponent(name);
    header.setExpandRatio(name, 1.0f);
    header.setComponentAlignment(name, Alignment.MIDDLE_LEFT);
    addDetailComponent(header);
    Label spacer = new Label();
    spacer.setWidth(100, UNITS_PERCENTAGE);
    spacer.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    addDetailComponent(spacer);
}
Also used : Label(com.vaadin.ui.Label) Embedded(com.vaadin.ui.Embedded) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 30 with Embedded

use of com.vaadin.ui.Embedded in project Activiti by Activiti.

the class DeleteDeploymentPopupWindow method addDeleteWarning.

protected void addDeleteWarning() {
    List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();
    int nrOfProcessInstances = 0;
    for (ProcessDefinition processDefinition : processDefinitions) {
        nrOfProcessInstances += runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).count();
    }
    if (nrOfProcessInstances == 0) {
        Label noInstancesLabel = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_NO_INSTANCES));
        noInstancesLabel.addStyleName(Reindeer.LABEL_SMALL);
        addComponent(noInstancesLabel);
    } else {
        HorizontalLayout warningLayout = new HorizontalLayout();
        warningLayout.setSpacing(true);
        addComponent(warningLayout);
        Embedded warningIcon = new Embedded(null, Images.WARNING);
        warningIcon.setType(Embedded.TYPE_IMAGE);
        warningLayout.addComponent(warningIcon);
        Label warningLabel = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_DELETE_POPUP_WARNING, nrOfProcessInstances), Label.CONTENT_XHTML);
        warningLabel.setSizeUndefined();
        warningLabel.addStyleName(Reindeer.LABEL_SMALL);
        warningLayout.addComponent(warningLabel);
    }
    // Some empty space
    Label emptySpace = new Label("&nbsp;", Label.CONTENT_XHTML);
    addComponent(emptySpace);
}
Also used : Label(com.vaadin.ui.Label) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Embedded(com.vaadin.ui.Embedded) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

Embedded (com.vaadin.ui.Embedded)40 Label (com.vaadin.ui.Label)29 HorizontalLayout (com.vaadin.ui.HorizontalLayout)19 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)14 StreamResource (com.vaadin.terminal.StreamResource)12 GridLayout (com.vaadin.ui.GridLayout)9 Item (com.vaadin.data.Item)7 InputStream (java.io.InputStream)7 StreamSource (com.vaadin.terminal.StreamResource.StreamSource)6 ExternalResource (com.vaadin.terminal.ExternalResource)5 Resource (com.vaadin.terminal.Resource)5 VerticalLayout (com.vaadin.ui.VerticalLayout)5 Component (com.vaadin.ui.Component)4 Panel (com.vaadin.ui.Panel)4 Picture (org.activiti.engine.identity.Picture)4 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 ClickListener (com.vaadin.ui.Button.ClickListener)3 Link (com.vaadin.ui.Link)3 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)3 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)3