Search in sources :

Example 1 with Resource

use of com.vaadin.terminal.Resource in project Activiti by Activiti.

the class UserDetailsComponent method addUserPicture.

protected void addUserPicture() {
    // default icon
    Resource pictureResource = Images.USER_32;
    if (user != null) {
        final Picture userPicture = identityService.getUserPicture(user.getId());
        if (userPicture != null) {
            pictureResource = new StreamResource(new StreamSource() {

                public InputStream getStream() {
                    return userPicture.getInputStream();
                }
            }, user.getId(), ExplorerApp.get());
        }
    }
    Embedded picture = new Embedded(null, pictureResource);
    picture.setType(Embedded.TYPE_IMAGE);
    picture.addStyleName(ExplorerLayout.STYLE_TASK_EVENT_PICTURE);
    if (user != null) {
        // Only set fixed height and width when user has image, otherwise icon's dimensions will be used
        picture.setHeight("32px");
        picture.setWidth("32px");
    }
    addComponent(picture);
    // Add profile popup listener
    if (user != null) {
        picture.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
        picture.addListener(new com.vaadin.event.MouseEvents.ClickListener() {

            public void click(ClickEvent event) {
                viewManager.showProfilePopup(user.getId());
            }
        });
    }
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) Picture(org.activiti.engine.identity.Picture) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) ClickEvent(com.vaadin.event.MouseEvents.ClickEvent) StreamResource(com.vaadin.terminal.StreamResource) Resource(com.vaadin.terminal.Resource) Embedded(com.vaadin.ui.Embedded)

Example 2 with Resource

use of com.vaadin.terminal.Resource 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 3 with Resource

use of com.vaadin.terminal.Resource in project Activiti by Activiti.

the class CreateAttachmentPopupWindow method initTable.

protected void initTable() {
    attachmentTypes = new Table();
    attachmentTypes.setSizeUndefined();
    attachmentTypes.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
    attachmentTypes.setSelectable(true);
    attachmentTypes.setImmediate(true);
    attachmentTypes.setNullSelectionAllowed(false);
    attachmentTypes.setWidth(200, UNITS_PIXELS);
    attachmentTypes.setHeight(100, UNITS_PERCENTAGE);
    attachmentTypes.setCellStyleGenerator(new CellStyleGenerator() {

        private static final long serialVersionUID = 1L;

        public String getStyle(Object itemId, Object propertyId) {
            if ("name".equals(propertyId)) {
                return ExplorerLayout.STYLE_RELATED_CONTENT_CREATE_LIST_LAST_COLUMN;
            }
            return null;
        }
    });
    attachmentTypes.addStyleName(ExplorerLayout.STYLE_RELATED_CONTENT_CREATE_LIST);
    attachmentTypes.addContainerProperty("type", Embedded.class, null);
    attachmentTypes.setColumnWidth("type", 16);
    attachmentTypes.addContainerProperty("name", String.class, null);
    // Add all possible attachment types
    for (AttachmentEditor editor : attachmentRendererManager.getAttachmentEditors()) {
        String name = editor.getTitle(i18nManager);
        Embedded image = null;
        Resource resource = editor.getImage();
        if (resource != null) {
            image = new Embedded(null, resource);
        }
        Item item = attachmentTypes.addItem(editor.getName());
        item.getItemProperty("type").setValue(image);
        item.getItemProperty("name").setValue(name);
    }
    // Add listener to show editor component
    attachmentTypes.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            String type = (String) event.getProperty().getValue();
            selectType(type);
        }
    });
    layout.addComponent(attachmentTypes);
}
Also used : Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Table(com.vaadin.ui.Table) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) Resource(com.vaadin.terminal.Resource) CellStyleGenerator(com.vaadin.ui.Table.CellStyleGenerator) Embedded(com.vaadin.ui.Embedded)

Example 4 with Resource

use of com.vaadin.terminal.Resource in project Activiti by Activiti.

the class UserProfileLink method initPicture.

protected void initPicture(IdentityService identityService, boolean renderPicture, final String userName) {
    if (renderPicture) {
        Picture picture = identityService.getUserPicture(userName);
        if (picture != null) {
            Resource imageResource = new StreamResource(new InputStreamStreamSource(picture.getInputStream()), userName + picture.getMimeType(), ExplorerApp.get());
            Embedded image = new Embedded(null, imageResource);
            image.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
            image.setType(Embedded.TYPE_IMAGE);
            image.setHeight(30, Embedded.UNITS_PIXELS);
            image.setWidth(30, Embedded.UNITS_PIXELS);
            image.addListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 7341560240277898495L;

                public void click(MouseEvents.ClickEvent event) {
                    viewManager.showProfilePopup(userName);
                }
            });
            addComponent(image);
            setComponentAlignment(image, Alignment.MIDDLE_LEFT);
        } else {
        // TODO: what when no image is available?
        }
    }
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) Picture(org.activiti.engine.identity.Picture) StreamResource(com.vaadin.terminal.StreamResource) Resource(com.vaadin.terminal.Resource) Embedded(com.vaadin.ui.Embedded) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) MouseEvents(com.vaadin.event.MouseEvents)

Example 5 with Resource

use of com.vaadin.terminal.Resource in project Activiti by Activiti.

the class ImageAttachmentRenderer method getDetailComponent.

@Override
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);
    // Image
    TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
    String mimeType = extractMineType(attachment.getType());
    InputStream imageStream = ImageUtil.resizeImage(taskService.getAttachmentContent(attachment.getId()), mimeType, 900, 550);
    Resource resource = new StreamResource(new InputStreamStreamSource(imageStream), attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get());
    Embedded image = new Embedded(null, resource);
    verticalLayout.addComponent(image);
    // Linke
    HorizontalLayout LinkLayout = new HorizontalLayout();
    LinkLayout.setSpacing(true);
    verticalLayout.addComponent(LinkLayout);
    verticalLayout.setComponentAlignment(LinkLayout, Alignment.MIDDLE_CENTER);
    Label fullSizeLabel = new Label(ExplorerApp.get().getI18nManager().getMessage(Messages.RELATED_CONTENT_SHOW_FULL_SIZE));
    LinkLayout.addComponent(fullSizeLabel);
    Link link = null;
    if (attachment.getUrl() != null) {
        link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
        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);
    }
    link.setIcon(Images.RELATED_CONTENT_PICTURE);
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    LinkLayout.addComponent(link);
    return verticalLayout;
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) TaskService(org.activiti.engine.TaskService) InputStream(java.io.InputStream) 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) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) Link(com.vaadin.ui.Link) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

Resource (com.vaadin.terminal.Resource)5 Embedded (com.vaadin.ui.Embedded)5 StreamResource (com.vaadin.terminal.StreamResource)4 InputStreamStreamSource (org.activiti.explorer.ui.util.InputStreamStreamSource)3 ExternalResource (com.vaadin.terminal.ExternalResource)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Label (com.vaadin.ui.Label)2 Link (com.vaadin.ui.Link)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 TaskService (org.activiti.engine.TaskService)2 Picture (org.activiti.engine.identity.Picture)2 Item (com.vaadin.data.Item)1 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)1 ValueChangeListener (com.vaadin.data.Property.ValueChangeListener)1 MouseEvents (com.vaadin.event.MouseEvents)1 ClickEvent (com.vaadin.event.MouseEvents.ClickEvent)1 StreamSource (com.vaadin.terminal.StreamResource.StreamSource)1 Table (com.vaadin.ui.Table)1 CellStyleGenerator (com.vaadin.ui.Table.CellStyleGenerator)1 InputStream (java.io.InputStream)1