List of usage examples for com.vaadin.ui CssLayout addComponent
@Override public void addComponent(Component c)
From source file:com.esofthead.mycollab.ui.chart.GenericChartWrapper.java
License:Open Source License
final protected void displayChart() { removeAllComponents();/*from w w w. j a va 2s .co m*/ 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.ui.chart.PieChartWrapper.java
License:Open Source License
@Override protected final ComponentContainer createLegendBox() { final CssLayout mainLayout = new CssLayout(); mainLayout.addStyleName("legendBoxContent"); mainLayout.setSizeUndefined();// w ww. j ava 2 s. com final List keys = pieDataSet.getKeys(); for (int i = 0; i < keys.size(); i++) { MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(false, false, false, true)); layout.addStyleName("inline-block"); layout.setSizeUndefined(); layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); final Comparable key = (Comparable) keys.get(i); int colorIndex = i % CHART_COLOR_STR.size(); final String color = "<div style = \" width:13px;height:13px;background: #" + CHART_COLOR_STR.get(colorIndex) + "\" />"; final Label lblCircle = new Label(color); lblCircle.setContentMode(ContentMode.HTML); String btnCaption; if (enumKeyCls == null) { if (key instanceof Key) { btnCaption = String.format("%s (%d)", StringUtils.trim(((Key) key).getDisplayName(), 20, true), pieDataSet.getValue(key).intValue()); } else { btnCaption = String.format("%s (%d)", key, pieDataSet.getValue(key).intValue()); } } else { btnCaption = String.format("%s(%d)", AppContext.getMessage(enumKeyCls, key.toString()), pieDataSet.getValue(key).intValue()); } final Button btnLink = new Button(StringUtils.trim(btnCaption, 25, true), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (key instanceof Key) { clickLegendItem(((Key) key).getKey()); } else { clickLegendItem(key.toString()); } } }); btnLink.setDescription(btnCaption); btnLink.addStyleName(UIConstants.BUTTON_LINK); layout.with(lblCircle, btnLink); mainLayout.addComponent(layout); } mainLayout.setWidth("100%"); return mainLayout; }
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 {/*from ww w. ja v a 2 s . com*/ 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()); }/*from w w w. jav a 2 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"); 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 ww . j a v a 2 s. 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);// w w w .jav a 2s .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(); 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.ui.MultiSelectComp.java
License:Open Source License
@Override protected Component initContent() { final HorizontalLayout content = new HorizontalLayout(); content.setSpacing(false);//from ww w. java 2 s.c o m content.addComponent(this.componentsDisplay); content.setComponentAlignment(this.componentsDisplay, Alignment.MIDDLE_LEFT); this.componentPopupSelection.addStyleName(UIConstants.SELECT_BG); this.componentPopupSelection.setWidth("25px"); this.componentPopupSelection.setPopupPositionComponent(content); CssLayout btnWrapper = new CssLayout(); btnWrapper.setWidthUndefined(); btnWrapper.addStyleName(UIConstants.SELECT_BG); btnWrapper.addComponent(componentPopupSelection); content.addComponent(btnWrapper); content.setComponentAlignment(btnWrapper, Alignment.MIDDLE_LEFT); content.setWidth(widthVal); content.setExpandRatio(this.componentsDisplay, 1.0f); return content; }
From source file:com.esofthead.mycollab.vaadin.ui.OptionPopupContent.java
License:Open Source License
public void addOption(Button btn) { CssLayout wrap = new CssLayout(); btn.setStyleName("action"); wrap.addStyleName("action-wrap"); wrap.addComponent(btn); addComponent(wrap);/*from www. j a va2 s . c o m*/ }
From source file:com.esofthead.mycollab.vaadin.ui.VerticalTabsheet.java
License:Open Source License
public VerticalTabsheet(boolean isLeft) { CssLayout contentLayout = new CssLayout(); navigatorWrapper = new CssLayout(); navigatorWrapper.setStyleName("navigator-wrap"); navigatorContainer = new VerticalLayout(); navigatorWrapper.addComponent(navigatorContainer); contentWrapper = new VerticalLayout(); contentWrapper.setStyleName("container-wrap"); contentWrapper.setWidth("100%"); tabContainer = new CssLayout(); tabContainer.setWidth("100%"); contentWrapper.addComponent(tabContainer); if (isLeft) { contentLayout.addComponent(navigatorWrapper); contentLayout.addComponent(contentWrapper); } else {/* w ww. j a v a 2 s .c o m*/ contentLayout.addComponent(contentWrapper); contentLayout.addComponent(navigatorWrapper); } this.setCompositionRoot(contentLayout); this.setStyleName(TABSHEET_STYLENAME); }
From source file:com.esofthead.mycollab.vaadin.web.ui.AddViewLayout.java
License:Open Source License
public void setTitle(final String title) { if (title != null) { CssLayout titleWrap = new CssLayout(); titleWrap.setWidth("100%"); titleWrap.addComponent(ELabel.h3(title)); addComponent(titleWrap, "addViewTitle"); } else {/* w ww . j a v a 2 s . c o m*/ removeComponent("addViewTitle"); } }