use of com.vaadin.terminal.ExternalResource in project Activiti by Activiti.
the class EditModelClickListener method showModeler.
protected void showModeler() throws MalformedURLException {
URL explorerURL = ExplorerApp.get().getURL();
URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "modeler.html?modelId=" + model.getId());
ExplorerApp.get().getMainWindow().open(new ExternalResource(url));
}
use of com.vaadin.terminal.ExternalResource in project Activiti by Activiti.
the class UrlAttachmentRenderer method getDetailComponent.
public Component getDetailComponent(Attachment attachment) {
VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.setSpacing(true);
verticalLayout.setMargin(true);
verticalLayout.addComponent(new Label(attachment.getDescription()));
HorizontalLayout linkLayout = new HorizontalLayout();
linkLayout.setSpacing(true);
verticalLayout.addComponent(linkLayout);
// Icon
linkLayout.addComponent(new Embedded(null, Images.RELATED_CONTENT_URL));
// Link
Link link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
linkLayout.addComponent(link);
return verticalLayout;
}
use of com.vaadin.terminal.ExternalResource in project Activiti by Activiti.
the class GenericAttachmentRenderer method getDetailComponent.
public Component getDetailComponent(Attachment attachment) {
VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.setSizeUndefined();
verticalLayout.setSpacing(true);
verticalLayout.setMargin(true);
Label description = new Label(attachment.getDescription());
description.setSizeUndefined();
verticalLayout.addComponent(description);
HorizontalLayout linkLayout = new HorizontalLayout();
linkLayout.setSpacing(true);
verticalLayout.addComponent(linkLayout);
// Image
linkLayout.addComponent(new Embedded(null, getImage(attachment)));
// Link
Link link = null;
if (attachment.getUrl() != null) {
link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
} else {
TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
Resource res = new StreamResource(new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())), attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get());
link = new Link(attachment.getName(), res);
}
// Set generic image and external window
link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
linkLayout.addComponent(link);
return verticalLayout;
}
use of com.vaadin.terminal.ExternalResource in project Activiti by Activiti.
the class ProfilePanel method initContactSection.
protected void initContactSection() {
Label header = createProfileHeader(infoPanelLayout, i18nManager.getMessage(Messages.PROFILE_CONTACT));
header.addStyleName(ExplorerLayout.STYLE_H3);
header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
infoPanelLayout.addComponent(header);
GridLayout contactLayout = createInfoSectionLayout(2, 4);
// Email
if (!editable && isDefined(user.getEmail())) {
addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), user.getEmail());
} else if (editable) {
emailField = new TextField();
addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), emailField, user.getEmail());
}
// Phone
if (!editable && isDefined(phone)) {
addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phone);
} else if (editable) {
phoneField = new TextField();
addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phoneField, phone);
}
// Twitter
if (!editable && isDefined(twitterName)) {
Link twitterLink = new Link(twitterName, new ExternalResource("http://www.twitter.com/" + twitterName));
addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterLink);
} else if (editable) {
twitterField = new TextField();
addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterField, twitterName);
}
// Skype
if (!editable && isDefined(skypeId)) {
// The skype entry shows the name + skype icon, laid out in a small grid
GridLayout skypeLayout = new GridLayout(2, 1);
skypeLayout.setSpacing(true);
skypeLayout.setSizeUndefined();
Label skypeIdLabel = new Label(skypeId);
skypeIdLabel.setSizeUndefined();
skypeLayout.addComponent(skypeIdLabel);
addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeLayout);
} else if (editable) {
skypeField = new TextField();
addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeField, skypeId);
}
}
use of com.vaadin.terminal.ExternalResource 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);
}
}
}
}
Aggregations