use of com.vaadin.ui.Embedded 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);
}
}
use of com.vaadin.ui.Embedded in project Activiti by Activiti.
the class GroupDetailPanel method initPageTitle.
protected void initPageTitle() {
HorizontalLayout layout = new HorizontalLayout();
layout.setWidth(100, UNITS_PERCENTAGE);
layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
layout.setSpacing(true);
layout.setMargin(false, false, true, false);
addDetailComponent(layout);
Embedded groupImage = new Embedded(null, Images.GROUP_50);
layout.addComponent(groupImage);
Label groupName = new Label(getGroupName(group));
groupName.setSizeUndefined();
groupName.addStyleName(Reindeer.LABEL_H2);
layout.addComponent(groupName);
layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
layout.setExpandRatio(groupName, 1.0f);
}
use of com.vaadin.ui.Embedded in project Activiti by Activiti.
the class UserDetailPanel method loadPicture.
protected void loadPicture() {
Component pictureComponent = null;
final Picture userPicture = identityService.getUserPicture(user.getId());
if (userPicture != null) {
StreamResource imageresource = new StreamResource(new StreamSource() {
private static final long serialVersionUID = 1L;
public InputStream getStream() {
return userPicture.getInputStream();
}
}, user.getId() + "." + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()), ExplorerApp.get());
pictureComponent = new Embedded(null, imageresource);
} else {
pictureComponent = new Label("");
}
pictureComponent.setHeight("200px");
pictureComponent.setWidth("200px");
pictureComponent.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE);
userDetailsLayout.addComponent(pictureComponent);
userDetailsLayout.setComponentAlignment(pictureComponent, Alignment.MIDDLE_CENTER);
}
use of com.vaadin.ui.Embedded 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);
}
}
}
}
use of com.vaadin.ui.Embedded in project Activiti by Activiti.
the class SavedReportDetailPanel method initHeader.
protected void initHeader() {
GridLayout details = new GridLayout(2, 2);
details.setWidth(100, UNITS_PERCENTAGE);
details.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
details.setSpacing(true);
details.setMargin(false, false, true, false);
details.setColumnExpandRatio(1, 1.0f);
detailPanelLayout.addComponent(details);
// Image
Embedded image = new Embedded(null, Images.REPORT_50);
details.addComponent(image, 0, 0, 0, 1);
// Name
Label nameLabel = new Label(SavedReportListItem.getReportDisplayName(historicProcessInstance));
nameLabel.addStyleName(Reindeer.LABEL_H2);
details.addComponent(nameLabel, 1, 0);
// Properties
HorizontalLayout propertiesLayout = new HorizontalLayout();
propertiesLayout.setSpacing(true);
details.addComponent(propertiesLayout);
// Created Time
String createLabel = i18nManager.getMessage(Messages.REPORTING_CREATE_TIME, new HumanTime(i18nManager).format(historicProcessInstance.getEndTime()));
Label versionLabel = new Label(createLabel);
versionLabel.addStyleName(ExplorerLayout.STYLE_PROCESS_HEADER_START_TIME);
propertiesLayout.addComponent(versionLabel);
}
Aggregations