Search in sources :

Example 6 with StreamSource

use of com.vaadin.terminal.StreamResource.StreamSource in project Activiti by Activiti.

the class ProfilePanel method initPicture.

protected void initPicture() {
    StreamResource imageresource = new StreamResource(new StreamSource() {

        private static final long serialVersionUID = 1L;

        public InputStream getStream() {
            return picture.getInputStream();
        }
    }, 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);
    }
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) InputStream(java.io.InputStream) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) Upload(com.vaadin.ui.Upload) Embedded(com.vaadin.ui.Embedded)

Example 7 with StreamSource

use of com.vaadin.terminal.StreamResource.StreamSource in project Activiti by Activiti.

the class EditorProcessDefinitionInfoComponent 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);
    StreamSource streamSource = null;
    final byte[] editorSourceExtra = repositoryService.getModelEditorSourceExtra(modelData.getId());
    if (editorSourceExtra != null) {
        streamSource = new StreamSource() {

            private static final long serialVersionUID = 1L;

            public InputStream getStream() {
                InputStream inStream = null;
                try {
                    inStream = new ByteArrayInputStream(editorSourceExtra);
                } catch (Exception e) {
                    LOGGER.warn("Error reading PNG in StreamSource", e);
                }
                return inStream;
            }
        };
    }
    if (streamSource != null) {
        Embedded embedded = new Embedded(null, new ImageStreamSource(streamSource, ExplorerApp.get()));
        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(700, UNITS_PIXELS);
        HorizontalLayout panelLayout = new HorizontalLayout();
        panelLayout.setSizeUndefined();
        imagePanel.setContent(panelLayout);
        imagePanel.addComponent(embedded);
        processImageContainer.addComponent(imagePanel);
    } else {
        Label noImageAvailable = new Label(i18nManager.getMessage(Messages.PROCESS_NO_DIAGRAM));
        processImageContainer.addComponent(noImageAvailable);
    }
    addComponent(processImageContainer);
}
Also used : Panel(com.vaadin.ui.Panel) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) Embedded(com.vaadin.ui.Embedded) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 8 with StreamSource

use of com.vaadin.terminal.StreamResource.StreamSource 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);
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) Picture(org.activiti.engine.identity.Picture) InputStream(java.io.InputStream) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) Label(com.vaadin.ui.Label) Embedded(com.vaadin.ui.Embedded) Component(com.vaadin.ui.Component)

Example 9 with StreamSource

use of com.vaadin.terminal.StreamResource.StreamSource in project Activiti by Activiti.

the class ProcessDefinitionImageStreamResourceBuilder method buildStreamResource.

public StreamResource buildStreamResource(ProcessDefinition processDefinition, RepositoryService repositoryService) {
    StreamResource imageResource = null;
    if (processDefinition.getDiagramResourceName() != null) {
        final InputStream definitionImageStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName());
        StreamSource streamSource = new InputStreamStreamSource(definitionImageStream);
        // Creating image name based on process-definition ID is fine, since the diagram image cannot
        // be altered once deployed.
        String imageExtension = extractImageExtension(processDefinition.getDiagramResourceName());
        String fileName = processDefinition.getId() + "." + imageExtension;
        imageResource = new StreamResource(streamSource, fileName, ExplorerApp.get());
    }
    return imageResource;
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) InputStream(java.io.InputStream) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource)

Example 10 with StreamSource

use of com.vaadin.terminal.StreamResource.StreamSource in project Activiti by Activiti.

the class DeploymentDetailPanel method addResourceLinks.

protected void addResourceLinks() {
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(deployment.getId());
    // small nr of elements, so we can do it in-memory
    Collections.sort(resourceNames);
    if (!resourceNames.isEmpty()) {
        Label resourceHeader = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_RESOURCES));
        resourceHeader.setWidth("95%");
        resourceHeader.addStyleName(ExplorerLayout.STYLE_H3);
        resourceHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
        addDetailComponent(resourceHeader);
        // resources
        VerticalLayout resourceLinksLayout = new VerticalLayout();
        resourceLinksLayout.setSpacing(true);
        resourceLinksLayout.setMargin(true, false, false, false);
        addDetailComponent(resourceLinksLayout);
        for (final String resourceName : resourceNames) {
            StreamResource.StreamSource streamSource = new StreamSource() {

                public InputStream getStream() {
                    return repositoryService.getResourceAsStream(deployment.getId(), resourceName);
                }
            };
            Link resourceLink = new Link(resourceName, new StreamResource(streamSource, resourceName, ExplorerApp.get()));
            resourceLinksLayout.addComponent(resourceLink);
        }
    }
}
Also used : StreamSource(com.vaadin.terminal.StreamResource.StreamSource) StreamResource(com.vaadin.terminal.StreamResource) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) VerticalLayout(com.vaadin.ui.VerticalLayout) Link(com.vaadin.ui.Link)

Aggregations

StreamSource (com.vaadin.terminal.StreamResource.StreamSource)10 StreamResource (com.vaadin.terminal.StreamResource)9 InputStream (java.io.InputStream)7 Embedded (com.vaadin.ui.Embedded)6 Label (com.vaadin.ui.Label)3 Picture (org.activiti.engine.identity.Picture)3 InputStreamStreamSource (org.activiti.explorer.ui.util.InputStreamStreamSource)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Panel (com.vaadin.ui.Panel)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 BpmnModel (org.activiti.bpmn.model.BpmnModel)2 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)2 ClickEvent (com.vaadin.event.MouseEvents.ClickEvent)1 Resource (com.vaadin.terminal.Resource)1 Component (com.vaadin.ui.Component)1 Link (com.vaadin.ui.Link)1 Upload (com.vaadin.ui.Upload)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)1 ProcessEngineImpl (org.activiti.engine.impl.ProcessEngineImpl)1