List of usage examples for com.vaadin.ui CssLayout setStyleName
@Override public void setStyleName(String style)
From source file:com.esofthead.mycollab.module.project.view.user.ProjectActivityStreamPagedList.java
License:Open Source License
@Override public void doSearch() { this.totalCount = this.projectActivityStreamService .getTotalActivityStream(this.searchRequest.getSearchCriteria()); this.totalPage = (this.totalCount - 1) / this.searchRequest.getNumberOfItems() + 1; if (this.searchRequest.getCurrentPage() > this.totalPage) { this.searchRequest.setCurrentPage(this.totalPage); }//from www. j a va 2 s. c o m if (totalPage > 1) { if (this.controlBarWrapper != null) { this.removeComponent(this.controlBarWrapper); } this.addComponent(this.createPageControls()); } else { if (getComponentCount() == 2) { removeComponent(getComponent(1)); } } final List<ProjectActivityStream> currentListData = this.projectActivityStreamService .getProjectActivityStreams(this.searchRequest); this.listContainer.removeAllComponents(); Date currentDate = new GregorianCalendar(2100, 1, 1).getTime(); CssLayout currentFeedBlock = new CssLayout(); try { for (final ProjectActivityStream activityStream : currentListData) { if (ProjectTypeConstants.PAGE.equals(activityStream.getType())) { ProjectPageService pageService = ApplicationContextUtil.getSpringBean(ProjectPageService.class); Page page = pageService.getPage(activityStream.getTypeid(), AppContext.getUsername()); if (page != null) { activityStream.setNamefield(page.getSubject()); } } final Date itemCreatedDate = activityStream.getCreatedtime(); if (!DateUtils.isSameDay(currentDate, itemCreatedDate)) { currentFeedBlock = new CssLayout(); currentFeedBlock.setStyleName("feed-block"); feedBlocksPut(currentDate, itemCreatedDate, currentFeedBlock); currentDate = itemCreatedDate; } StringBuffer content = new StringBuffer(); String itemType = AppContext .getMessage(ProjectLocalizationTypeMap.getType(activityStream.getType())); String assigneeParam = buildAssigneeValue(activityStream); String itemParam = buildItemValue(activityStream); if (ActivityStreamConstants.ACTION_CREATE.equals(activityStream.getAction())) { content.append( AppContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_CREATE_ACTION_TITLE, assigneeParam, itemType, itemParam)); } else if (ActivityStreamConstants.ACTION_UPDATE.equals(activityStream.getAction())) { content.append( AppContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_UPDATE_ACTION_TITLE, assigneeParam, itemType, itemParam)); if (activityStream.getAssoAuditLog() != null) { content.append( ProjectAuditLogStreamGenerator.generatorDetailChangeOfActivity(activityStream)); } } else if (ActivityStreamConstants.ACTION_COMMENT.equals(activityStream.getAction())) { content.append( AppContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_COMMENT_ACTION_TITLE, assigneeParam, itemType, itemParam)); if (activityStream.getAssoAuditLog() != null) { content.append("<p><ul><li>\"").append(activityStream.getAssoAuditLog().getChangeset()) .append("\"</li></ul></p>"); } } final Label actionLbl = new Label(content.toString(), ContentMode.HTML); final CssLayout streamWrapper = new CssLayout(); streamWrapper.setWidth("100%"); streamWrapper.addStyleName("stream-wrapper"); streamWrapper.addComponent(actionLbl); currentFeedBlock.addComponent(streamWrapper); } } catch (final Exception e) { throw new MyCollabException(e); } }
From source file:com.esofthead.mycollab.module.project.view.user.ProjectSummaryViewImpl.java
License:Open Source License
@Override protected void displayView() { withMargin(new MarginInfo(true, false, false, false)); CssLayout contentWrapper = new CssLayout(); contentWrapper.setStyleName("content-wrapper"); contentWrapper.setWidth("100%"); this.addComponent(contentWrapper); ProjectInformationComponent prjView = new ProjectInformationComponent(); contentWrapper.addComponent(prjView); final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%"); contentWrapper.addComponent(layout); final VerticalLayout leftPanel = new VerticalLayout(); ProjectActivityStreamComponent activityPanel = new ProjectActivityStreamComponent(); leftPanel.addComponent(activityPanel); layout.addComponent(leftPanel);/* w w w . j av a2s . c o m*/ final MVerticalLayout rightPanel = new MVerticalLayout() .withMargin(new MarginInfo(false, false, false, true)); layout.addComponent(rightPanel); ProjectMessageListComponent messageWidget = new ProjectMessageListComponent(); ProjectMembersWidget membersWidget = new ProjectMembersWidget(); ProjectAssignmentsWidget taskOverdueWidget = new ProjectAssignmentsWidget(); rightPanel.with(messageWidget, membersWidget, taskOverdueWidget); activityPanel.showProjectFeeds(); prjView.displayProjectInformation(); membersWidget.showInformation(); taskOverdueWidget.showOpenAssignments(); messageWidget.showLatestMessages(); }
From source file:com.esofthead.mycollab.module.project.view.UserDashboardViewImpl.java
License:Open Source License
@Override protected void displayView() { this.removeAllComponents(); this.withMargin(false).withWidth("100%"); final CssLayout headerWrapper = new CssLayout(); headerWrapper.setWidth("100%"); headerWrapper.setStyleName("projectfeed-hdr-wrapper"); final MHorizontalLayout header = new MHorizontalLayout().withMargin(false).withWidth("100%"); header.addStyleName("projectfeed-hdr"); Button avatar = UserAvatarControlFactory.createUserAvatarEmbeddedButton(AppContext.getUserAvatarId(), 64); avatar.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override// w w w . j a va2 s .com public void buttonClick(final ClickEvent event) { String userFullLinkStr = AccountLinkGenerator.generatePreviewFullUserLink(AppContext.getSiteUrl(), AppContext.getUsername()); getUI().getPage().open(userFullLinkStr, null); } }); header.addComponent(avatar); final MVerticalLayout headerContent = new MVerticalLayout() .withMargin(new MarginInfo(false, false, false, true)); headerContent.addStyleName("projectfeed-hdr-content"); final Label headerLabel = new Label(AppContext.getSession().getDisplayName()); headerLabel.setStyleName(Reindeer.LABEL_H1); final MHorizontalLayout headerContentTop = new MHorizontalLayout() .withMargin(new MarginInfo(false, false, true, false)); headerContentTop.with(headerLabel).withAlign(headerLabel, Alignment.TOP_LEFT); if (AppContext.canBeYes(RolePermissionCollections.CREATE_NEW_PROJECT)) { final Button createProjectBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_NEW_PROJECT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { final ProjectAddWindow projectNewWindow = new ProjectAddWindow(); UI.getCurrent().addWindow(projectNewWindow); } }); createProjectBtn.setIcon(FontAwesome.PLUS); createProjectBtn.setStyleName(UIConstants.THEME_GREEN_LINK); headerContentTop.addComponent(createProjectBtn); headerContentTop.setComponentAlignment(createProjectBtn, Alignment.MIDDLE_LEFT); } followingTicketsLink = new LabelLink(AppContext.getMessage(FollowerI18nEnum.OPT_MY_FOLLOWING_TICKETS, 0), AppContext.getSiteUrl() + "#project/following"); followingTicketsLink.setIconLink(FontAwesome.EYE); LabelLink timeTrackingLink = new LabelLink(AppContext.getMessage(TimeTrackingI18nEnum.TIME_RECORD_HEADER), AppContext.getSiteUrl() + "#project/timetracking"); timeTrackingLink.setIconLink(ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME)); final MHorizontalLayout headerContentBottom = new MHorizontalLayout().withMargin(false) .with(followingTicketsLink, timeTrackingLink); headerContent.with(headerContentTop, headerContentBottom); header.with(headerContent).expand(headerContent); headerWrapper.addComponent(header); this.addComponent(headerWrapper); final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(false, false, true, false)).withWidth("100%"); ActivityStreamComponent activityStreamComponent = new ActivityStreamComponent(); final MVerticalLayout leftPanel = new MVerticalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, false)).withWidth("100%") .with(activityStreamComponent); final MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false).withWidth("565px"); MyProjectListComponent myProjectListComponent = new MyProjectListComponent(); TaskStatusComponent taskStatusComponent = new TaskStatusComponent(); rightPanel.with(myProjectListComponent, taskStatusComponent); layout.with(leftPanel, rightPanel).expand(leftPanel); final CssLayout contentWrapper = new CssLayout(); contentWrapper.setWidth("100%"); contentWrapper.addStyleName("content-wrapper"); this.addComponent(contentWrapper); contentWrapper.addComponent(layout); final ProjectService prjService = ApplicationContextUtil.getSpringBean(ProjectService.class); prjKeys = prjService.getProjectKeysUserInvolved(AppContext.getUsername(), AppContext.getAccountId()); if (CollectionUtils.isNotEmpty(prjKeys)) { activityStreamComponent.showFeeds(prjKeys); myProjectListComponent.displayDefaultProjectsList(); displayFollowingTicketsCount(); } taskStatusComponent.showProjectTasksByStatus(prjKeys); }
From source file:com.esofthead.mycollab.ui.chart.GenericChartWrapper.java
License:Open Source License
final protected void displayChart() { removeAllComponents();/* w w w. jav a 2 s. c om*/ final JFreeChart chart = createChart(); final JFreeChartWrapper chartWrapper = new JFreeChartWrapper(chart); final CssLayout borderWrap = new CssLayout(); borderWrap.addComponent(chartWrapper); borderWrap.setStyleName("chart-wrapper"); borderWrap.setHeight(height + "px"); borderWrap.setWidth(width + "px"); chartWrapper.setHeight(height + "px"); chartWrapper.setWidth(width + "px"); chartWrapper.setGraphHeight(height); chartWrapper.setGraphWidth(width); this.addComponent(borderWrap); final Component legendBox = createLegendBox(); if (legendBox != null) { this.addComponent(legendBox); } }
From source file:com.esofthead.mycollab.vaadin.ui.AddViewLayout.java
License:Open Source License
public void setTitle(final String title) { if (title != null) { CssLayout titleWrap = new CssLayout(); titleWrap.setStyleName("addViewTitle"); titleWrap.setWidth("100%"); titleWrap.addComponent(new Label(title)); this.addComponent(titleWrap, "addViewTitle"); } else {// ww w . jav a 2s. c o m this.removeComponent("addViewTitle"); } }
From source file:com.esofthead.mycollab.vaadin.ui.AttachmentDisplayComponent.java
License:Open Source License
public static Component constructAttachmentRow(final Content attachment) { String docName = attachment.getPath(); int lastIndex = docName.lastIndexOf("/"); if (lastIndex != -1) { docName = docName.substring(lastIndex + 1, docName.length()); }// www .j a v a 2 s.c om final AbsoluteLayout attachmentLayout = new AbsoluteLayout(); attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); attachmentLayout.setHeight(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT); attachmentLayout.setStyleName("attachment-block"); CssLayout thumbnailWrap = new CssLayout(); thumbnailWrap.setSizeFull(); thumbnailWrap.setStyleName("thumbnail-wrap"); Image thumbnail = new Image(null); if (org.apache.commons.lang3.StringUtils.isBlank(attachment.getThumbnail())) { thumbnail.setSource(DEFAULT_SOURCE); } else { thumbnail.setSource(VaadinResourceManager.getResourceManager() .getImagePreviewResource(attachment.getThumbnail(), DEFAULT_SOURCE)); } thumbnail.setDescription(docName); thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); thumbnailWrap.addComponent(thumbnail); attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;"); if (MimeTypesUtil.isImageType(docName)) { thumbnail.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = -2853211588120500523L; @Override public void click(MouseEvents.ClickEvent event) { Resource previewResource = VaadinResourceManager.getResourceManager() .getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE); UI.getCurrent().addWindow(new AttachmentPreviewWindow(previewResource)); } }); } CssLayout attachmentNameWrap = new CssLayout(); attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); attachmentNameWrap.setStyleName("attachment-name-wrap"); Label attachmentName = new Label(StringUtils.trim(docName, 60, true)); attachmentName.setStyleName("attachment-name"); attachmentNameWrap.addComponent(attachmentName); attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;"); Button trashBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ResourceService attachmentService = ApplicationContextUtil .getSpringBean(ResourceService.class); attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(), AppContext.getAccountId()); ((ComponentContainer) attachmentLayout.getParent()) .removeComponent(attachmentLayout); } } }); } }); trashBtn.setIcon(FontAwesome.TRASH_O); trashBtn.setStyleName("attachment-control"); attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;"); Button downloadBtn = new Button(); FileDownloader fileDownloader = new FileDownloader( VaadinResourceManager.getResourceManager().getStreamResource(attachment.getPath())); fileDownloader.extend(downloadBtn); downloadBtn.setIcon(FontAwesome.DOWNLOAD); downloadBtn.setStyleName("attachment-control"); attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;"); return attachmentLayout; }
From source file:com.esofthead.mycollab.vaadin.ui.Depot.java
License:Open Source License
public Depot(final Label titleLbl, final AbstractOrderedLayout headerElement, final ComponentContainer component, final String headerWidth, final String headerLeftWidth) { this.setStyleName("depotComp"); this.setMargin(new MarginInfo(true, false, false, false)); this.header = new HorizontalLayout(); this.header.setStyleName("depotHeader"); this.header.setWidth(headerWidth); this.bodyContent = component; if (headerElement != null) { this.headerContent = headerElement; } else {/*from w w w. j a va 2s. c o m*/ this.headerContent = new HorizontalLayout(); this.headerContent.setSpacing(true); this.headerContent.setMargin(true); this.headerContent.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); this.headerContent.setVisible(false); } this.headerContent.setStyleName("header-elements"); this.headerContent.setWidthUndefined(); this.headerContent.setSizeUndefined(); this.addComponent(this.header); final HorizontalLayout headerLeft = new HorizontalLayout(); headerLeft.setMargin(false); this.headerLbl = titleLbl; this.headerLbl.setStyleName("h2"); this.headerLbl.setWidth("100%"); headerLeft.addComponent(this.headerLbl); headerLeft.setStyleName("depot-title"); headerLeft.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 1L; @Override public void layoutClick(final LayoutClickEvent event) { Depot.this.isOpenned = !Depot.this.isOpenned; if (Depot.this.isOpenned) { Depot.this.bodyContent.setVisible(true); Depot.this.removeStyleName("collapsed"); } else { Depot.this.bodyContent.setVisible(false); Depot.this.addStyleName("collapsed"); } } }); final CssLayout headerWrapper = new CssLayout(); headerWrapper.addComponent(headerLeft); headerWrapper.setStyleName("header-wrapper"); headerWrapper.setWidth(headerLeftWidth); this.header.addComponent(headerWrapper); this.header.setComponentAlignment(headerWrapper, Alignment.MIDDLE_LEFT); this.header.addComponent(this.headerContent); this.header.setComponentAlignment(this.headerContent, Alignment.TOP_RIGHT); this.header.setExpandRatio(headerWrapper, 1.0f); final CustomComponent customComp = new CustomComponent(this.bodyContent); customComp.setWidth("100%"); this.bodyContent.addStyleName("depotContent"); this.addComponent(customComp); this.setComponentAlignment(customComp, Alignment.TOP_CENTER); }
From source file:com.esofthead.mycollab.vaadin.ui.MailFormWindow.java
License:Open Source License
private void initUI() { GridLayout mainLayout = new GridLayout(1, 5); mainLayout.setWidth("100%"); mainLayout.setMargin(true);/*from w w w . ja va 2s. com*/ mainLayout.setSpacing(true); CssLayout inputPanel = new CssLayout(); inputPanel.setWidth("100%"); inputPanel.setStyleName("mail-panel"); inputLayout = new GridLayout(3, 4); inputLayout.setSpacing(true); inputLayout.setWidth("100%"); inputLayout.setColumnExpandRatio(0, 1.0f); inputPanel.addComponent(inputLayout); mainLayout.addComponent(inputPanel); tokenFieldMailTo = new EmailTokenField(); tokenFieldMailTo.setRequired(true); inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0); if (lstMail != null) { for (String mail : lstMail) { if (StringUtils.isNotBlank(mail)) { if (mail.indexOf("<") > -1) { String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">")); if (strMail != null && !strMail.equalsIgnoreCase("null")) { tokenFieldMailTo.addToken(mail); } } else { tokenFieldMailTo.addToken(mail); } } } } final TextField subject = new TextField(); subject.setRequired(true); subject.setWidth("100%"); subjectField = createTextFieldMail("Subject:", subject); inputLayout.addComponent(subjectField, 0, 1); initButtonLinkCcBcc(); ccField = createTextFieldMail("Cc:", tokenFieldMailCc); bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc); final RichTextArea noteArea = new RichTextArea(); noteArea.setWidth("100%"); noteArea.setHeight("200px"); mainLayout.addComponent(noteArea, 0, 1); mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("500px"); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.addComponent(uploadExt); controlsLayout.setExpandRatio(uploadExt, 1.0f); controlsLayout.setSpacing(true); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { MailFormWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); controlsLayout.addComponent(cancelBtn); controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT); Button sendBtn = new Button("Send", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) { NotificationUtil.showErrorNotification( "To Email field and Subject field must be not empty! Please fulfil them before sending email."); return; } if (AppContext.getSession().getEmail() != null && AppContext.getSession().getEmail().length() > 0) { ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class); List<File> listFile = attachments.getListFile(); List<EmailAttachementSource> emailAttachmentSource = null; if (listFile != null && listFile.size() > 0) { emailAttachmentSource = new ArrayList<EmailAttachementSource>(); for (File file : listFile) { emailAttachmentSource.add(new FileEmailAttachmentSource(file)); } } systemMailService.sendHTMLMail(AppContext.getSession().getEmail(), AppContext.getSession().getDisplayName(), tokenFieldMailTo.getListRecipient(), tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(), subject.getValue().toString(), noteArea.getValue().toString(), emailAttachmentSource); MailFormWindow.this.close(); } else { NotificationUtil.showErrorNotification( "Your email is empty value, please fulfil it before sending email!"); } } }); sendBtn.setStyleName(UIConstants.THEME_GREEN_LINK); controlsLayout.addComponent(sendBtn); controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT); mainLayout.addComponent(controlsLayout, 0, 2); this.setContent(mainLayout); }
From source file:com.esofthead.mycollab.vaadin.web.ui.AttachmentDisplayComponent.java
License:Open Source License
public void addAttachmentRow(final Content attachment) { String docName = attachment.getPath(); int lastIndex = docName.lastIndexOf("/"); if (lastIndex != -1) { docName = docName.substring(lastIndex + 1, docName.length()); }//w ww . ja v a2 s . c o m final AbsoluteLayout attachmentLayout = new AbsoluteLayout(); attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); attachmentLayout.setHeight(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT); attachmentLayout.setStyleName("attachment-block"); CssLayout thumbnailWrap = new CssLayout(); thumbnailWrap.setSizeFull(); thumbnailWrap.setStyleName("thumbnail-wrap"); Link thumbnail = new Link(); if (StringUtils.isBlank(attachment.getThumbnail())) { thumbnail.setIcon(FileAssetsUtil.getFileIconResource(attachment.getName())); } else { thumbnail.setIcon(VaadinResourceFactory.getInstance().getResource(attachment.getThumbnail())); } if (MimeTypesUtil.isImageType(docName)) { thumbnail.setResource(VaadinResourceFactory.getInstance().getResource(attachment.getPath())); new Fancybox(thumbnail).setPadding(0).setVersion("2.1.5").setEnabled(true).setDebug(true); } Div contentTooltip = new Div().appendChild(new Span().appendText(docName).setStyle("font-weight:bold")); Ul ul = new Ul() .appendChild(new Li().appendText("Size: " + FileUtils.getVolumeDisplay(attachment.getSize()))) .setStyle("line-height:1.5em"); ul.appendChild(new Li().appendText( "Last modified: " + AppContext.formatPrettyTime(attachment.getLastModified().getTime()))); contentTooltip.appendChild(ul); thumbnail.setDescription(contentTooltip.write()); thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); thumbnailWrap.addComponent(thumbnail); attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;"); CssLayout attachmentNameWrap = new CssLayout(); attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); attachmentNameWrap.setStyleName("attachment-name-wrap"); Label attachmentName = new Label(StringUtils.trim(docName, 60, true)); attachmentName.setStyleName("attachment-name"); attachmentNameWrap.addComponent(attachmentName); attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;"); Button trashBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()), AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ResourceService attachmentService = AppContextUtil .getSpringBean(ResourceService.class); attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(), AppContext.getAccountId()); ((ComponentContainer) attachmentLayout.getParent()) .removeComponent(attachmentLayout); } } }); } }); trashBtn.setIcon(FontAwesome.TRASH_O); trashBtn.setStyleName("attachment-control"); attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;"); Button downloadBtn = new Button(); FileDownloader fileDownloader = new FileDownloader( VaadinResourceFactory.getInstance().getStreamResource(attachment.getPath())); fileDownloader.extend(downloadBtn); downloadBtn.setIcon(FontAwesome.DOWNLOAD); downloadBtn.setStyleName("attachment-control"); attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;"); this.addComponent(attachmentLayout); }
From source file:com.esofthead.mycollab.vaadin.web.ui.MailFormWindow.java
License:Open Source License
private void initUI() { GridLayout mainLayout = new GridLayout(1, 5); mainLayout.setWidth("100%"); mainLayout.setMargin(true);/*from w ww .j av a 2 s .co m*/ mainLayout.setSpacing(true); CssLayout inputPanel = new CssLayout(); inputPanel.setWidth("100%"); inputPanel.setStyleName("mail-panel"); inputLayout = new GridLayout(3, 4); inputLayout.setSpacing(true); inputLayout.setWidth("100%"); inputLayout.setColumnExpandRatio(0, 1.0f); inputPanel.addComponent(inputLayout); mainLayout.addComponent(inputPanel); tokenFieldMailTo = new EmailTokenField(); inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0); if (lstMail != null) { for (String mail : lstMail) { if (StringUtils.isNotBlank(mail)) { if (mail.indexOf("<") > -1) { String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">")); if (strMail != null && !strMail.equalsIgnoreCase("null")) { } } else { } } } } final TextField subject = new TextField(); subject.setRequired(true); subject.setWidth("100%"); subjectField = createTextFieldMail("Subject:", subject); inputLayout.addComponent(subjectField, 0, 1); initButtonLinkCcBcc(); ccField = createTextFieldMail("Cc:", tokenFieldMailCc); bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc); final RichTextArea noteArea = new RichTextArea(); noteArea.setWidth("100%"); noteArea.setHeight("200px"); mainLayout.addComponent(noteArea, 0, 1); mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("500px"); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.addComponent(uploadExt); controlsLayout.setExpandRatio(uploadExt, 1.0f); controlsLayout.setSpacing(true); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { MailFormWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); controlsLayout.addComponent(cancelBtn); controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT); Button sendBtn = new Button("Send", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) { NotificationUtil.showErrorNotification( "To Email field and Subject field must be not empty! Please fulfil them before sending email."); return; } if (AppContext.getUser().getEmail() != null && AppContext.getUser().getEmail().length() > 0) { ExtMailService systemMailService = AppContextUtil.getSpringBean(ExtMailService.class); List<File> listFile = attachments.files(); List<EmailAttachmentSource> emailAttachmentSource = null; if (listFile != null && listFile.size() > 0) { emailAttachmentSource = new ArrayList<>(); for (File file : listFile) { emailAttachmentSource.add(new FileEmailAttachmentSource(file)); } } systemMailService.sendHTMLMail(AppContext.getUser().getEmail(), AppContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(), tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(), subject.getValue(), noteArea.getValue(), emailAttachmentSource); MailFormWindow.this.close(); } else { NotificationUtil.showErrorNotification( "Your email is empty value, please fulfil it before sending email!"); } } }); sendBtn.setIcon(FontAwesome.SEND); sendBtn.setStyleName(UIConstants.BUTTON_ACTION); controlsLayout.addComponent(sendBtn); controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT); mainLayout.addComponent(controlsLayout, 0, 2); this.setContent(mainLayout); }