protected void initForm() { form = new Form(); form.setValidationVisibleOnCommit(true); form.setImmediate(true); addComponent(form); // name nameField = new TextField(i18nManager.getMessage(Messages.TASK_NAME)); nameField.focus(); nameField.setRequired(true); nameField.setRequiredError(i18nManager.getMessage(Messages.TASK_NAME_REQUIRED)); form.addField("name", nameField); // description descriptionArea = new TextArea(i18nManager.getMessage(Messages.TASK_DESCRIPTION)); descriptionArea.setColumns(25); form.addField("description", descriptionArea); // duedate dueDateField = new DateField(i18nManager.getMessage(Messages.TASK_DUEDATE)); dueDateField.setResolution(DateField.RESOLUTION_DAY); form.addField("duedate", dueDateField); // priority priorityComboBox = new PriorityComboBox(i18nManager); form.addField("priority", priorityComboBox); }
protected HorizontalLayout generateActionButtons(Object taskItemId) { HorizontalLayout actionButtons = new HorizontalLayout(); FormDefinition form = taskFormModel.getForm(taskItemId); Button formButton = new Button( form == null ? i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_FORM_CREATE) : i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_FORM_EDIT)); formButton.addListener(new ShowFormClickListener(taskFormModel, taskItemId)); formButton.setData(taskItemId); actionButtons.addComponent(formButton); Button deleteTaskButton = new Button("-"); deleteTaskButton.setData(taskItemId); deleteTaskButton.addListener(new DeleteTaskClickListener(this)); actionButtons.addComponent(deleteTaskButton); Button addTaskButton = new Button("+"); addTaskButton.setData(taskItemId); addTaskButton.addListener(new AddTaskClickListener(this)); actionButtons.addComponent(addTaskButton); return actionButtons; }
protected void addButtons() { // Cancel Button cancelButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL)); cancelButton.addStyleName(Reindeer.BUTTON_SMALL); cancelButton.addListener( new ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); // Delete Button deleteButton = new Button(i18nManager.getMessage(Messages.DEPLOYMENT_DELETE_POPUP_DELETE_BUTTON)); deleteButton.addStyleName(Reindeer.BUTTON_SMALL); deleteButton.addListener( new ClickListener() { public void buttonClick(ClickEvent event) { // Delete deployment, close popup window and refresh deployment list repositoryService.deleteDeployment(deployment.getId(), true); close(); deploymentPage.refreshSelectNext(); } }); // Alignment HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(cancelButton); buttonLayout.addComponent(deleteButton); addComponent(buttonLayout); windowLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT); }
protected void initName() { TextField nameField = new TextField(i18nManager.getMessage(Messages.RELATED_CONTENT_NAME)); nameField.focus(); nameField.setRequired(true); nameField.setRequiredError(i18nManager.getMessage(Messages.RELATED_CONTENT_NAME_REQUIRED)); nameField.setWidth(100, UNITS_PERCENTAGE); form.addField("name", nameField); }
protected void addVariables() { Label header = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_HEADER_VARIABLES)); header.addStyleName(ExplorerLayout.STYLE_H3); header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); header.addStyleName(ExplorerLayout.STYLE_NO_LINE); panelLayout.addComponent(header); panelLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); // variable sorting is done in-memory (which is ok, since normally there aren't that many vars) Map<String, Object> variables = new TreeMap<String, Object>(runtimeService.getVariables(processInstance.getId())); if (variables.size() > 0) { Table variablesTable = new Table(); variablesTable.setWidth(60, UNITS_PERCENTAGE); variablesTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST); variablesTable.addContainerProperty( "name", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_VARIABLE_NAME), null, Table.ALIGN_LEFT); variablesTable.addContainerProperty( "value", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_VARIABLE_VALUE), null, Table.ALIGN_LEFT); for (String variable : variables.keySet()) { Item variableItem = variablesTable.addItem(variable); variableItem.getItemProperty("name").setValue(variable); // Get string value to show String theValue = variableRendererManager.getStringRepresentation(variables.get(variable)); variableItem.getItemProperty("value").setValue(theValue); } variablesTable.setPageLength(variables.size()); panelLayout.addComponent(variablesTable); } else { Label noVariablesLabel = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_NO_VARIABLES)); panelLayout.addComponent(noVariablesLabel); } }
protected void addResourceLinks() { List<String> resourceNames = repositoryService.getDeploymentResourceNames(deployment.getId()); Collections.sort(resourceNames); // small nr of elements, so we can do it in-memory if (resourceNames.size() > 0) { Label resourceHeader = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_RESOURCES)); resourceHeader.setWidth("95%"); resourceHeader.addStyleName(ExplorerLayout.STYLE_H3); resourceHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); addDetailComponent(resourceHeader); // resources VerticalLayout resourceLinksLayout = new VerticalLayout(); resourceLinksLayout.setSpacing(true); resourceLinksLayout.setMargin(true, false, false, false); addDetailComponent(resourceLinksLayout); for (final String resourceName : resourceNames) { 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); } } }
protected void initDescription() { TextArea descriptionField = new TextArea(i18nManager.getMessage(Messages.RELATED_CONTENT_DESCRIPTION)); descriptionField.setWidth(100, UNITS_PERCENTAGE); descriptionField.setHeight(50, UNITS_PIXELS); form.addField("description", descriptionField); }
public Attachment getAttachment() throws InvalidValueException { // Force validation of the fields form.commit(); // Check if file is uploaded if (!fileUploaded) { InvalidValueException ive = new InvalidValueException( i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_FILE_REQUIRED)); form.setComponentError(ive); throw ive; } if (attachment != null) { applyValuesToAttachment(); } else { // Create new attachment based on values // TODO: use explorerApp to get services attachment = taskService.createAttachment( mimeType, taskId, processInstanceId, getAttachmentName(), getAttachmentDescription(), new ByteArrayInputStream(byteArrayOutputStream.toByteArray())); } return attachment; }
protected void addTaskItem(HistoricTaskInstance task, Table taskTable) { Item item = taskTable.addItem(task.getId()); if (task.getEndTime() != null) { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_FINISHED_22)); } else { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_22)); } item.getItemProperty("name").setValue(task.getName()); item.getItemProperty("priority").setValue(task.getPriority()); item.getItemProperty("startDate").setValue(new PrettyTimeLabel(task.getStartTime(), true)); item.getItemProperty("endDate").setValue(new PrettyTimeLabel(task.getEndTime(), true)); if (task.getDueDate() != null) { Label dueDateLabel = new PrettyTimeLabel( task.getEndTime(), i18nManager.getMessage(Messages.TASK_NOT_FINISHED_YET), true); item.getItemProperty("dueDate").setValue(dueDateLabel); } if (task.getAssignee() != null) { Component taskAssigneeComponent = getTaskAssigneeComponent(task.getAssignee()); if (taskAssigneeComponent != null) { item.getItemProperty("assignee").setValue(taskAssigneeComponent); } } }
protected void addHeader() { GridLayout header = new GridLayout(3, 2); header.setWidth(100, UNITS_PERCENTAGE); header.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); header.setSpacing(true); header.setMargin(false, false, true, false); // Add image Embedded image = new Embedded(null, Images.PROCESS_50); header.addComponent(image, 0, 0, 0, 1); // Add task name Label nameLabel = new Label(getProcessDisplayName(processDefinition, processInstance)); nameLabel.addStyleName(Reindeer.LABEL_H2); header.addComponent(nameLabel, 1, 0, 2, 0); // Add start time PrettyTimeLabel startTimeLabel = new PrettyTimeLabel( i18nManager.getMessage(Messages.PROCESS_START_TIME), historicProcessInstance.getStartTime(), null, true); startTimeLabel.addStyleName(ExplorerLayout.STYLE_PROCESS_HEADER_START_TIME); header.addComponent(startTimeLabel, 1, 1); header.setColumnExpandRatio(1, 1.0f); header.setColumnExpandRatio(2, 1.0f); panelLayout.addComponent(header); }
protected void initWindow() { windowLayout.setSpacing(true); addStyleName(Reindeer.WINDOW_LIGHT); setModal(true); center(); setCaption( i18nManager.getMessage(Messages.DEPLOYMENT_DELETE_POPUP_CAPTION, deployment.getName())); }
protected void addConvertWarning() { Label convertLabel = new Label(i18nManager.getMessage(Messages.PROCESS_CONVERT_POPUP_MESSAGE)); convertLabel.addStyleName(Reindeer.LABEL_SMALL); addComponent(convertLabel); // Some empty space Label emptySpace = new Label(" ", Label.CONTENT_XHTML); addComponent(emptySpace); }
protected void addDeleteButton() { Button deleteProcessInstanceButton = new Button(i18nManager.getMessage(Messages.PROCESS_INSTANCE_DELETE)); deleteProcessInstanceButton.setIcon(Images.DELETE); deleteProcessInstanceButton.addListener( new DeleteProcessInstanceClickListener(processInstance.getId(), processInstancePage)); // Clear toolbar and add 'start' button processInstancePage.getToolBar().removeAllButtons(); processInstancePage.getToolBar().addButton(deleteProcessInstanceButton); }
protected void initWindow() { windowLayout.setSpacing(true); addStyleName(Reindeer.WINDOW_LIGHT); setModal(true); center(); String name = processDefinition.getName(); if (StringUtils.isEmpty(name)) { name = processDefinition.getKey(); } setCaption(i18nManager.getMessage(Messages.PROCESS_CONVERT_POPUP_CAPTION, name)); }
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(" ", Label.CONTENT_XHTML); addComponent(emptySpace); }
public TaskTable() { this.i18nManager = ExplorerApp.get().getI18nManager(); this.taskFormModel.addFormModelListener(this); setEditable(true); setColumnReorderingAllowed(true); setSizeFull(); setPageLength(0); addContainerProperty(ID_NAME, String.class, null); addContainerProperty(ID_ASSIGNEE, String.class, null); addContainerProperty(ID_GROUPS, String.class, null); addContainerProperty(ID_DESCRIPTION, TextField.class, null); addContainerProperty(ID_START_WITH_PREVIOUS, CheckBox.class, null); addContainerProperty(ID_ACTIONS, HorizontalLayout.class, null); setColumnHeader(ID_NAME, i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_NAME)); setColumnHeader(ID_ASSIGNEE, i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_ASSIGNEE)); setColumnHeader(ID_GROUPS, i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_GROUPS)); setColumnHeader( ID_DESCRIPTION, i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_DESCRIPTION)); setColumnHeader( ID_START_WITH_PREVIOUS, i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_CONCURRENCY)); setColumnHeader(ID_ACTIONS, i18nManager.getMessage(Messages.PROCESS_EDITOR_ACTIONS)); setColumnAlignment(ID_NAME, ALIGN_CENTER); setColumnAlignment(ID_ASSIGNEE, ALIGN_CENTER); setColumnAlignment(ID_GROUPS, ALIGN_CENTER); setColumnAlignment(ID_START_WITH_PREVIOUS, ALIGN_CENTER); setColumnAlignment(ID_START_WITH_PREVIOUS, ALIGN_CENTER); setColumnWidth(ID_ACTIONS, 170); }
protected void addDeploymentName() { GridLayout taskDetails = new GridLayout(3, 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.DEPLOYMENT_50); taskDetails.addComponent(image, 0, 0, 0, 1); // Add deployment name Label nameLabel = new Label(); if (deployment.getName() != null) { nameLabel.setValue(deployment.getName()); } else { nameLabel.setValue(i18nManager.getMessage(Messages.DEPLOYMENT_NO_NAME)); } nameLabel.addStyleName(Reindeer.LABEL_H2); taskDetails.addComponent(nameLabel, 1, 0, 2, 0); // Add deploy time PrettyTimeLabel deployTimeLabel = new PrettyTimeLabel( i18nManager.getMessage(Messages.DEPLOYMENT_DEPLOY_TIME), deployment.getDeploymentTime(), null, true); deployTimeLabel.addStyleName(ExplorerLayout.STYLE_DEPLOYMENT_HEADER_DEPLOY_TIME); taskDetails.addComponent(deployTimeLabel, 1, 1); taskDetails.setColumnExpandRatio(1, 1.0f); taskDetails.setColumnExpandRatio(2, 1.0f); addDetailComponent(taskDetails); }
protected void addActions() { // Delete button Button deleteButton = new Button(i18nManager.getMessage(Messages.DEPLOYMENT_DELETE)); deleteButton.setIcon(Images.DELETE); deleteButton.addListener( new ClickListener() { public void buttonClick(ClickEvent event) { viewManager.showPopupWindow(new DeleteDeploymentPopupWindow(deployment, parent)); } }); parent.getToolBar().removeAllButtons(); parent.getToolBar().addButton(deleteButton); }
protected void initInputField() { // Csslayout is used to style inputtext as rounded CssLayout csslayout = new CssLayout(); csslayout.setHeight(24, UNITS_PIXELS); csslayout.setWidth(100, UNITS_PERCENTAGE); layout.addComponent(csslayout); inputField = new TextField(); inputField.setWidth(100, UNITS_PERCENTAGE); inputField.addStyleName(ExplorerLayout.STYLE_SEARCHBOX); inputField.setInputPrompt(i18nManager.getMessage(Messages.TASK_CREATE_NEW)); inputField.focus(); csslayout.addComponent(inputField); layout.setComponentAlignment(csslayout, Alignment.MIDDLE_LEFT); layout.setExpandRatio(csslayout, 1.0f); }
public NewCasePopupWindow() { this.taskService = ProcessEngines.getDefaultProcessEngine().getTaskService(); this.i18nManager = ExplorerApp.get().getI18nManager(); setModal(true); center(); setResizable(false); setCaption(i18nManager.getMessage(Messages.TASK_NEW)); addStyleName(Reindeer.WINDOW_LIGHT); setWidth(430, UNITS_PIXELS); setHeight(320, UNITS_PIXELS); initForm(); initCreateTaskButton(); initEnterKeyListener(); }
protected void initCreateTaskButton() { HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setWidth(100, UNITS_PERCENTAGE); form.getFooter().setWidth(100, UNITS_PERCENTAGE); form.getFooter().addComponent(buttonLayout); Button createButton = new Button(i18nManager.getMessage(Messages.BUTTON_CREATE)); buttonLayout.addComponent(createButton); buttonLayout.setComponentAlignment(createButton, Alignment.BOTTOM_RIGHT); createButton.addListener( new ClickListener() { public void buttonClick(ClickEvent event) { handleFormSubmit(); } }); }
protected Object addTaskRow( Object previousTaskItemId, String taskName, String taskAssignee, String taskGroups, String taskDescription, Boolean startWithPrevious) { Object newItemId = null; if (previousTaskItemId == null) { // add at the end of list newItemId = addItem(); } else { newItemId = addItemAfter(previousTaskItemId); } Item newItem = getItem(newItemId); // name newItem.getItemProperty(ID_NAME).setValue(taskName == null ? "my task" : taskName); // assignee newItem.getItemProperty(ID_ASSIGNEE).setValue(taskAssignee == null ? "" : taskAssignee); // groups newItem.getItemProperty(ID_GROUPS).setValue(taskGroups == null ? "" : taskGroups); // description TextField descriptionTextField = new TextField(); descriptionTextField.setColumns(16); descriptionTextField.setRows(1); if (taskDescription != null) { descriptionTextField.setValue(taskDescription); } newItem.getItemProperty(ID_DESCRIPTION).setValue(descriptionTextField); // concurrency CheckBox startWithPreviousCheckBox = new CheckBox(i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_START_WITH_PREVIOUS)); startWithPreviousCheckBox.setValue(startWithPrevious == null ? false : startWithPrevious); newItem.getItemProperty(ID_START_WITH_PREVIOUS).setValue(startWithPreviousCheckBox); // actions newItem.getItemProperty(ID_ACTIONS).setValue(generateActionButtons(newItemId)); return newItemId; }
public FileAttachmentEditorComponent( Attachment attachment, String taskId, String processInstanceId) { this.attachment = attachment; this.taskId = taskId; this.processInstanceId = processInstanceId; this.i18nManager = ExplorerApp.get().getI18nManager(); taskService = ProcessEngines.getDefaultProcessEngine().getTaskService(); form = new Form(); form.setDescription(i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_FILE_HELP)); setSizeFull(); addComponent(form); initSuccessIndicator(); initFileUpload(); initName(); initDescription(); }
protected void addProcessDefinitionLinks() { List<ProcessDefinition> processDefinitions = repositoryService .createProcessDefinitionQuery() .deploymentId(deployment.getId()) .orderByProcessDefinitionName() .asc() .list(); if (processDefinitions.size() > 0) { // Header Label processDefinitionHeader = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_DEFINITIONS)); processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_H3); processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); processDefinitionHeader.setWidth(100, UNITS_PERCENTAGE); addDetailComponent(processDefinitionHeader); // processes VerticalLayout processDefinitionLinksLayout = new VerticalLayout(); processDefinitionLinksLayout.setSpacing(true); processDefinitionLinksLayout.setMargin(true, false, true, false); addDetailComponent(processDefinitionLinksLayout); for (final ProcessDefinition processDefinition : processDefinitions) { Button processDefinitionButton = new Button(getProcessDisplayName(processDefinition)); processDefinitionButton.addListener( new ClickListener() { public void buttonClick(ClickEvent event) { viewManager.showDeployedProcessDefinitionPage(processDefinition.getId()); } }); processDefinitionButton.addStyleName(Reindeer.BUTTON_LINK); processDefinitionLinksLayout.addComponent(processDefinitionButton); } } }
protected void addButtons() { // Cancel Button cancelButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL)); cancelButton.addStyleName(Reindeer.BUTTON_SMALL); cancelButton.addListener( new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { close(); } }); // Convert Button convertButton = new Button(i18nManager.getMessage(Messages.PROCESS_CONVERT_POPUP_CONVERT_BUTTON)); convertButton.addStyleName(Reindeer.BUTTON_SMALL); convertButton.addListener( new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { try { InputStream bpmnStream = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), processDefinition.getResourceName()); XMLInputFactory xif = XMLInputFactory.newInstance(); InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8"); XMLStreamReader xtr = xif.createXMLStreamReader(in); BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); if (bpmnModel.getMainProcess() == null || bpmnModel.getMainProcess().getId() == null) { notificationManager.showErrorNotification( Messages.MODEL_IMPORT_FAILED, i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMN_EXPLANATION)); } else { if (bpmnModel.getLocationMap().size() == 0) { notificationManager.showErrorNotification( Messages.MODEL_IMPORT_INVALID_BPMNDI, i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMNDI_EXPLANATION)); } else { BpmnJsonConverter converter = new BpmnJsonConverter(); ObjectNode modelNode = converter.convertToJson(bpmnModel); Model modelData = repositoryService.newModel(); ObjectNode modelObjectNode = new ObjectMapper().createObjectNode(); modelObjectNode.put(MODEL_NAME, processDefinition.getName()); modelObjectNode.put(MODEL_REVISION, 1); modelObjectNode.put(MODEL_DESCRIPTION, processDefinition.getDescription()); modelData.setMetaInfo(modelObjectNode.toString()); modelData.setName(processDefinition.getName()); repositoryService.saveModel(modelData); repositoryService.addModelEditorSource( modelData.getId(), modelNode.toString().getBytes("utf-8")); close(); ExplorerApp.get() .getViewManager() .showEditorProcessDefinitionPage(modelData.getId()); URL explorerURL = ExplorerApp.get().getURL(); URL url = new URL( explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "service/editor?id=" + modelData.getId()); ExplorerApp.get().getMainWindow().open(new ExternalResource(url)); } } } catch (Exception e) { notificationManager.showErrorNotification("error", e); } } }); // Alignment HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(cancelButton); buttonLayout.addComponent(convertButton); addComponent(buttonLayout); windowLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT); }
protected void addTasks() { Label header = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_HEADER_TASKS)); header.addStyleName(ExplorerLayout.STYLE_H3); header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); header.addStyleName(ExplorerLayout.STYLE_NO_LINE); panelLayout.addComponent(header); panelLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); Table taskTable = new Table(); taskTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST); taskTable.setWidth(100, UNITS_PERCENTAGE); // Fetch all tasks List<HistoricTaskInstance> tasks = historyService .createHistoricTaskInstanceQuery() .processInstanceId(processInstance.getId()) .orderByHistoricTaskInstanceEndTime() .desc() .orderByHistoricTaskInstanceStartTime() .desc() .list(); if (tasks.size() > 0) { // Finished icon taskTable.addContainerProperty( "finished", Component.class, null, "", null, Table.ALIGN_CENTER); taskTable.setColumnWidth("finished", 22); taskTable.addContainerProperty( "name", String.class, null, i18nManager.getMessage(Messages.TASK_NAME), null, Table.ALIGN_LEFT); taskTable.addContainerProperty( "priority", Integer.class, null, i18nManager.getMessage(Messages.TASK_PRIORITY), null, Table.ALIGN_LEFT); taskTable.addContainerProperty( "assignee", Component.class, null, i18nManager.getMessage(Messages.TASK_ASSIGNEE), null, Table.ALIGN_LEFT); taskTable.addContainerProperty( "dueDate", Component.class, null, i18nManager.getMessage(Messages.TASK_DUEDATE), null, Table.ALIGN_LEFT); taskTable.addContainerProperty( "startDate", Component.class, null, i18nManager.getMessage(Messages.TASK_CREATE_TIME), null, Table.ALIGN_LEFT); taskTable.addContainerProperty( "endDate", Component.class, null, i18nManager.getMessage(Messages.TASK_COMPLETE_TIME), null, Table.ALIGN_LEFT); panelLayout.addComponent(taskTable); panelLayout.setExpandRatio(taskTable, 1.0f); for (HistoricTaskInstance task : tasks) { addTaskItem(task, taskTable); } taskTable.setPageLength(taskTable.size()); } else { // No tasks Label noTaskLabel = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_NO_TASKS)); panelLayout.addComponent(noTaskLabel); } }
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 = XMLInputFactory.newInstance(); XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream); BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); if (bpmnModel.getFlowLocationMap().size() > 0) { 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; } } Panel imagePanel = new Panel(); // using panel for scrollbars 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 == false && 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); 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(); Panel imagePanel = new Panel(); // using panel for scrollbars 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); } } } }