Example usage for com.vaadin.ui Embedded TYPE_IMAGE

List of usage examples for com.vaadin.ui Embedded TYPE_IMAGE

Introduction

In this page you can find the example usage for com.vaadin.ui Embedded TYPE_IMAGE.

Prototype

int TYPE_IMAGE

To view the source code for com.vaadin.ui Embedded TYPE_IMAGE.

Click Source Link

Document

Image types.

Usage

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 ww.  j av  a 2 s .  c  o m*/
}

From source file:org.activiti.explorer.ui.management.admin.AdminCompletedInstancesPanel.java

License:Apache License

protected void addProcessImage(ProcessDefinition processDefinition, HistoricProcessInstance processInstance) {
    if (currentEmbedded != null) {
        mainPanel.removeComponent(currentEmbedded);
    }//from   w ww.jav  a 2s  .  c om

    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);
        }

        StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder()
                .buildStreamResource(processDefinition, repositoryService);

        currentEmbedded = new Embedded(null, diagram);
        currentEmbedded.setType(Embedded.TYPE_IMAGE);
        addDetailComponent(currentEmbedded);
    }
}

From source file:org.activiti.explorer.ui.management.admin.AdminRunningInstancesPanel.java

License:Apache License

protected void addProcessImage(ProcessDefinition processDefinition, HistoricProcessInstance processInstance) {
    if (currentEmbedded != null) {
        mainPanel.removeComponent(currentEmbedded);
    }/*from  w  w w  .j  a  va 2s  .c  o  m*/

    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);
    }
}

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 w w w.  ja  v  a2s .  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("&nbsp;", 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 va  2 s.  co  m
    }
}

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 w w w  . j  a v a2  s  .c om*/
                        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  w w . j a v a  2s . 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  a2  s  .com
    };

    // 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  ww  .ja  va2 s  .com
    }, 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;/*  ww  w.j av a2s. c  o  m*/

    if (userPicture != null) {
        StreamResource imageresource = new StreamResource(new StreamSource() {
            private static final long serialVersionUID = 1L;

            public InputStream getStream() {
                return userPicture.getInputStream();
            }
        }, "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);
}