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);
}
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(" ");
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);
}
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);
}
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);
}
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(" ", Label.CONTENT_XHTML);
addComponent(emptySpace);
}
Aggregations