List of usage examples for com.vaadin.ui Embedded setType
public void setType(int type)
From source file:org.activiti.explorer.ui.flow.ProcessInstanceDetailPanel.java
License:Apache License
protected void addFlowImage() { ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService) .getDeployedProcessDefinition(processDefinition.getId()); // Only show when graphical notation is defined if (processDefinitionEntity != null && processDefinitionEntity.isGraphicalNotationDefined()) { Label header = new Label(i18nManager.getMessage(Messages.FLOW_INSTANCE_HEADER_DIAGRAM)); header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); header.addStyleName(ExplorerLayout.STYLE_H3); verticalLayout.addComponent(header); StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder() .buildStreamResource(processInstance, repositoryService, runtimeService); Embedded embedded = new Embedded("", diagram); embedded.setType(Embedded.TYPE_IMAGE); verticalLayout.addComponent(embedded); }//from w w w. j a v a2s . co m }
From source file:org.activiti.explorer.ui.management.deployment.DeleteDeploymentPopupWindow.java
License:Apache License
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(); }//from ww w . ja va 2s . c o m 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); }
From source file:org.activiti.explorer.ui.management.process.ProcessInstanceDetailPanel.java
License:Apache License
protected void addProcessImage() { ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService) .getDeployedProcessDefinition(processDefinition.getId()); // Only show when graphical notation is defined if (processDefinitionEntity != null && 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(400, UNITS_PIXELS); HorizontalLayout panelLayoutT = new HorizontalLayout(); panelLayoutT.setSizeUndefined(); imagePanel.setContent(panelLayoutT); imagePanel.addComponent(embedded); panelLayout.addComponent(imagePanel); }//from w ww . j a va2s. c om } }
From source file:org.activiti.explorer.ui.management.processinstance.ProcessInstanceDetailPanel.java
License:Apache License
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; }/*from ww w.j a v a 2s.com*/ 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 && 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(); 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); } } } }
From source file:org.activiti.explorer.ui.process.ProcessDefinitionInfoComponent.java
License:Apache License
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 {/* w ww .ja v a 2 s . co m*/ 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; } } 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()); 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(); Panel imagePanel = new Panel(); // using panel for scrollbars 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); }
From source file:org.activiti.explorer.ui.process.simple.editor.SimpleTableEditor.java
License:Apache License
protected void showDiagram() { StreamResource.StreamSource streamSource = new StreamSource() { private static final long serialVersionUID = 6993112534181068935L; public InputStream getStream() { WorkflowDefinitionConversion workflowDefinitionConversion = ExplorerApp.get() .getWorkflowDefinitionConversionFactory() .createWorkflowDefinitionConversion(createWorkflow()); final ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines .getDefaultProcessEngine(); final ProcessEngineConfiguration processEngineConfiguration = defaultProcessEngine .getProcessEngineConfiguration(); final ProcessDiagramGenerator diagramGenerator = processEngineConfiguration .getProcessDiagramGenerator(); return diagramGenerator.generateDiagram(workflowDefinitionConversion.getBpmnModel(), "png", processEngineConfiguration.getActivityFontName(), processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getClassLoader()); }//from ww w .j a v a 2 s . c o m }; // resource must have unique id (or cache-crap can happen)! StreamResource imageresource = new StreamResource(streamSource, UUID.randomUUID() + ".png", ExplorerApp.get()); Embedded diagram = new Embedded("", imageresource); diagram.setType(Embedded.TYPE_IMAGE); diagram.setSizeUndefined(); imagePanel = new Panel(); // using panel for scrollbars imagePanel.setScrollable(true); imagePanel.addStyleName(Reindeer.PANEL_LIGHT); imagePanel.setWidth(100, UNITS_PERCENTAGE); imagePanel.setHeight("100%"); mainLayout.addComponent(imagePanel); HorizontalLayout panelLayout = new HorizontalLayout(); panelLayout.setSizeUndefined(); imagePanel.setContent(panelLayout); imagePanel.addComponent(diagram); }
From source file:org.activiti.explorer.ui.profile.ProfilePanel.java
License:Apache License
protected void initPicture() { StreamResource imageresource = new StreamResource(new StreamSource() { private static final long serialVersionUID = 1L; public InputStream getStream() { return picture.getInputStream(); }/* w w w. j a v a 2 s .c o m*/ }, user.getId(), ExplorerApp.get()); imageresource.setCacheTime(0); Embedded picture = new Embedded(null, imageresource); picture.setType(Embedded.TYPE_IMAGE); picture.setHeight(200, UNITS_PIXELS); picture.setWidth(200, UNITS_PIXELS); picture.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE); imageLayout.addComponent(picture); imageLayout.setWidth(picture.getWidth() + 5, picture.getWidthUnits()); // Change picture button if (isCurrentLoggedInUser) { Upload changePictureButton = initChangePictureButton(); imageLayout.addComponent(changePictureButton); imageLayout.setComponentAlignment(changePictureButton, Alignment.MIDDLE_CENTER); } }
From source file:org.activiti.explorer.ui.task.TaskEventsPanel.java
License:Apache License
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(); }// w w w. j a v a2 s . com }, "event_" + taskEvent.getUserId() + "." + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()), ExplorerApp.get()); authorPicture = new Embedded(null, imageresource); } else { authorPicture = new Embedded(null, Images.USER_50); } authorPicture.setType(Embedded.TYPE_IMAGE); authorPicture.setHeight("48px"); authorPicture.setWidth("48px"); authorPicture.addStyleName(ExplorerLayout.STYLE_TASK_EVENT_PICTURE); eventGrid.addComponent(authorPicture); }
From source file:org.activiti.explorer.ui.task.UserDetailsComponent.java
License:Apache License
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(); }/*from ww w. j a va2 s . c o m*/ }, user.getId(), ExplorerApp.get()); } } Embedded picture = new Embedded(null, pictureResource); picture.setType(Embedded.TYPE_IMAGE); picture.addStyleName(ExplorerLayout.STYLE_TASK_EVENT_PICTURE); if (user != null) { // Only set fixed height and width when user has image, otherwise icon's dimensions will be used picture.setHeight("32px"); picture.setWidth("32px"); } addComponent(picture); // Add profile popup listener if (user != null) { picture.addStyleName(ExplorerLayout.STYLE_CLICKABLE); picture.addListener(new com.vaadin.event.MouseEvents.ClickListener() { public void click(ClickEvent event) { viewManager.showProfilePopup(user.getId()); } }); } }
From source file:org.activiti.kickstart.ui.popup.ProcessImagePopupWindow.java
License:Apache License
protected void initUi() { setModal(true);/*ww w .j a v a 2 s. c o m*/ setHeight("80%"); setWidth("80%"); center(); setCaption(TITLE); StreamResource.StreamSource streamSource = null; if (processDefinitionId != null) { streamSource = new StreamSource() { private static final long serialVersionUID = -8875067466181823014L; public InputStream getStream() { return adhocWorkflowService.getProcessImage(processDefinitionId); } }; } else if (adhocWorkflow != null) { final ProcessDiagramGenerator converter = new ProcessDiagramGenerator(adhocWorkflow); streamSource = new StreamSource() { private static final long serialVersionUID = 239500411112658830L; public InputStream getStream() { return converter.execute(); } }; } // resource must have unique id! StreamResource imageresource = new StreamResource(streamSource, UUID.randomUUID() + ".png", viewManager.getApplication()); Panel panel = new Panel(); panel.setContent(new HorizontalLayout()); panel.setStyleName(Reindeer.PANEL_LIGHT); panel.setHeight("95%"); Embedded embedded = new Embedded("", imageresource); embedded.setType(Embedded.TYPE_IMAGE); panel.addComponent(embedded); addComponent(panel); }