List of usage examples for com.vaadin.ui Embedded Embedded
public Embedded(String caption, Resource source)
From source file:com.klwork.explorer.ui.content.CreateAttachmentPopupWindow.java
License:Apache License
protected void initTable() { attachmentTypes = new Table(); attachmentTypes.setSizeUndefined();/*from w w w .j a va2 s . c om*/ attachmentTypes.setColumnHeaderMode(ColumnHeaderMode.HIDDEN); attachmentTypes.setSelectable(true); attachmentTypes.setImmediate(true); attachmentTypes.setNullSelectionAllowed(false); attachmentTypes.setWidth(200, Unit.PIXELS); attachmentTypes.setHeight(100, Unit.PERCENTAGE); attachmentTypes.setCellStyleGenerator(new CellStyleGenerator() { private static final long serialVersionUID = 1L; @Override public String getStyle(Table source, 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()) {// ?url if (includeTypes != null && !includeTypes.contains(editor.getName())) { continue; } 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.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { String type = (String) event.getProperty().getValue(); selectType(type); } }); layout.addComponent(attachmentTypes); }
From source file:com.klwork.explorer.ui.content.file.ImageAttachmentRenderer.java
License:Apache License
@Override public Component getDetailComponent(Attachment attachment) { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeUndefined();// www . j a v a2 s . c o m 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())); 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( ViewToolManager.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())); link = new Link(attachment.getName(), res); } link.setIcon(Images.RELATED_CONTENT_PICTURE); link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK); LinkLayout.addComponent(link); return verticalLayout; }
From source file:com.klwork.explorer.ui.content.GenericAttachmentRenderer.java
License:Apache License
public Component getDetailComponent(Attachment attachment) { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeUndefined();//w ww . j a v a 2 s . co m 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())); link = new Link(attachment.getName(), res); } // Set generic image and external window link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK); linkLayout.addComponent(link); return verticalLayout; }
From source file:com.klwork.explorer.ui.content.url.UrlAttachmentRenderer.java
License:Apache License
public Component getDetailComponent(Attachment attachment) { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSpacing(true);//from w ww . ja v a2 s. c o m 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; }
From source file:com.klwork.explorer.ui.custom.ThemeImageColumnGenerator.java
License:Apache License
public Component generateCell(Table source, Object itemId, Object columnId) { return new Embedded(null, image); }
From source file:com.klwork.explorer.ui.task.AbstractTaskPage.java
License:Apache License
@Override public HorizontalLayout createSelectHead() { HorizontalLayout tableHeadLayout = new HorizontalLayout(); // tableHeadLayout.setSizeFull(); tableHeadLayout.setSpacing(true);//from www . jav a 2 s . c om tableHeadLayout.setMargin(true); Resource pictureResource = Images.TASK_LIST; Embedded picture = new Embedded(null, pictureResource); picture.addStyleName(ExplorerLayout.STYLE_TASK_EVENT_PICTURE); picture.setType(Embedded.TYPE_IMAGE); tableHeadLayout.addComponent(picture); tableHeadLayout.setComponentAlignment(picture, Alignment.MIDDLE_LEFT); Label nameLabel = null; nameLabel = new Label(""); nameLabel.addStyleName("taskListLabel"); // nameLabel.addStyleName(ExplorerLayout.STYLE_LABEL_BOLD); tableHeadLayout.addComponent(nameLabel); tableHeadLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT); return tableHeadLayout; }
From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java
License:Apache License
protected void initHeader() { GridLayout taskDetails = new GridLayout(5, 2); taskDetails.setWidth(100, UNITS_PERCENTAGE); taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); taskDetails.setSpacing(true);/*from w w w .j av a2 s .co m*/ taskDetails.setMargin(new MarginInfo(false, false, true, false)); // Add image Embedded image = new Embedded(null, Images.TASK_50); taskDetails.addComponent(image, 0, 0, 0, 1); // Add task name Label nameLabel = new Label(historicTask.getName()); nameLabel.addStyleName(Reindeer.LABEL_H2); taskDetails.addComponent(nameLabel, 1, 0, 4, 0); // Add due date PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_DUEDATE_SHORT), historicTask.getDueDate(), i18nManager.getMessage(Messages.TASK_DUEDATE_UNKNOWN), false); dueDateLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_DUEDATE); taskDetails.addComponent(dueDateLabel, 1, 1); // Add priority Integer lowMedHighPriority = convertPriority(historicTask.getPriority()); Label priorityLabel = new Label(); switch (lowMedHighPriority) { case 1: priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_LOW)); priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_LOW); break; case 2: priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_MEDIUM)); priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_MEDIUM); break; case 3: default: priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_HIGH)); priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_HIGH); } taskDetails.addComponent(priorityLabel, 2, 1); // Add create date PrettyTimeLabel createLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_CREATED_SHORT), historicTask.getStartTime(), "", true); createLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_CREATE_TIME); taskDetails.addComponent(createLabel, 3, 1); // Add label to fill excess space Label spacer = new Label(); spacer.setContentMode(Label.CONTENT_XHTML); spacer.setValue(" "); spacer.setSizeUndefined(); taskDetails.addComponent(spacer); taskDetails.setColumnExpandRatio(1, 1.0f); taskDetails.setColumnExpandRatio(2, 1.0f); taskDetails.setColumnExpandRatio(3, 1.0f); taskDetails.setColumnExpandRatio(4, 1.0f); centralLayout.addComponent(taskDetails); }
From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java
License:Apache License
protected void populateSubTasks(List<HistoricTaskInstance> subTasks) { for (final HistoricTaskInstance subTask : subTasks) { // icon//from w ww . ja v a 2s. co m Embedded icon = new Embedded(null, Images.TASK_22); icon.setWidth(22, UNITS_PIXELS); icon.setWidth(22, UNITS_PIXELS); subTaskGrid.addComponent(icon); // Link to subtask Button subTaskLink = new Button(subTask.getName()); subTaskLink.addStyleName(Reindeer.BUTTON_LINK); subTaskLink.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { ViewToolManager.getMainView().showTaskPage(subTask.getId()); } }); subTaskGrid.addComponent(subTaskLink); subTaskGrid.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT); } }
From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java
License:Apache License
protected void populateRelatedContent(Table table, List<Attachment> attachments) { for (Attachment attachment : attachments) { AttachmentRenderer renderer = attachmentRendererManager.getRenderer(attachment); Item attachmentItem = table.addItem(attachment.getId()); // Simple renderer that just shows a popup window with the attachment RelatedContentComponent relatedContentComponent = new RelatedContentComponent() { public void showAttachmentDetail(Attachment attachment) { AttachmentDetailPopupWindow popup = new AttachmentDetailPopupWindow(attachment); ViewToolManager.showPopupWindow(popup); }/*from w w w.ja va 2s . c om*/ }; attachmentItem.getItemProperty("name") .setValue(renderer.getOverviewComponent(attachment, relatedContentComponent)); attachmentItem.getItemProperty("type").setValue(new Embedded(null, renderer.getImage(attachment))); } table.setPageLength(table.size()); }
From source file:com.klwork.explorer.ui.task.ProcessInstanceEventsPanel.java
License:Apache License
protected void addTaskEventPicture(final Comment taskEvent, GridLayout eventGrid) { final Picture userPicture = identityService.getUserPicture(taskEvent.getUserId()); Embedded authorPicture = null;//from ww w . j a va 2 s. co 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())); 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); }