Search in sources :

Example 1 with ExternalResource

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));
}
Also used : ExternalResource(com.vaadin.terminal.ExternalResource) URL(java.net.URL)

Example 2 with ExternalResource

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;
}
Also used : Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) Embedded(com.vaadin.ui.Embedded) ExternalResource(com.vaadin.terminal.ExternalResource) Link(com.vaadin.ui.Link) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 3 with ExternalResource

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;
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) TaskService(org.activiti.engine.TaskService) Label(com.vaadin.ui.Label) StreamResource(com.vaadin.terminal.StreamResource) ExternalResource(com.vaadin.terminal.ExternalResource) Resource(com.vaadin.terminal.Resource) VerticalLayout(com.vaadin.ui.VerticalLayout) Embedded(com.vaadin.ui.Embedded) ExternalResource(com.vaadin.terminal.ExternalResource) Link(com.vaadin.ui.Link) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 4 with ExternalResource

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);
    }
}
Also used : GridLayout(com.vaadin.ui.GridLayout) Label(com.vaadin.ui.Label) TextField(com.vaadin.ui.TextField) ExternalResource(com.vaadin.terminal.ExternalResource) Link(com.vaadin.ui.Link)

Example 5 with ExternalResource

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);
            }
        }
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) InputStream(java.io.InputStream) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) ExternalResource(com.vaadin.terminal.ExternalResource) URL(java.net.URL) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Panel(com.vaadin.ui.Panel) DetailPanel(org.activiti.explorer.ui.custom.DetailPanel) ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) StreamResource(com.vaadin.terminal.StreamResource) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) Embedded(com.vaadin.ui.Embedded) ProcessDefinitionImageStreamResourceBuilder(org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Aggregations

ExternalResource (com.vaadin.terminal.ExternalResource)10 HorizontalLayout (com.vaadin.ui.HorizontalLayout)7 Label (com.vaadin.ui.Label)6 Embedded (com.vaadin.ui.Embedded)5 Link (com.vaadin.ui.Link)5 URL (java.net.URL)5 StreamResource (com.vaadin.terminal.StreamResource)4 VerticalLayout (com.vaadin.ui.VerticalLayout)4 InputStream (java.io.InputStream)4 Button (com.vaadin.ui.Button)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 ClickListener (com.vaadin.ui.Button.ClickListener)3 XMLInputFactory (javax.xml.stream.XMLInputFactory)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Resource (com.vaadin.terminal.Resource)2 Panel (com.vaadin.ui.Panel)2