List of usage examples for com.vaadin.ui Button setStyleName
@Override public void setStyleName(String style)
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 av a 2 s.co 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.AttachmentPanel.java
License:Open Source License
private void displayFileName(final String fileName) { final MHorizontalLayout fileAttachmentLayout = new MHorizontalLayout(); Button removeBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override//w ww.j a v a 2 s . c o m public void buttonClick(ClickEvent event) { File file = fileStores.get(fileName); if (file != null) { file.delete(); } fileStores.remove(fileName); AttachmentPanel.this.removeComponent(fileAttachmentLayout); if (multiFileUpload != null) { multiFileUpload.removeAndReInitMultiUpload(); } } }); removeBtn.setIcon(FontAwesome.TRASH_O); removeBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); Label fileIcon = new Label(getFileIconResource(fileName).getHtml(), ContentMode.HTML); Label fileLbl = new Label(fileName); fileAttachmentLayout.with(fileIcon, fileLbl, removeBtn).withAlign(fileLbl, Alignment.MIDDLE_CENTER); this.addComponent(fileAttachmentLayout); }
From source file:com.esofthead.mycollab.vaadin.ui.BuildCriterionComponent.java
License:Open Source License
public BuildCriterionComponent(Param[] paramFields, Class<S> type, String searchCategory) { this.setSpacing(true); this.paramFields = paramFields; this.type = type; this.searchCategory = searchCategory; MHorizontalLayout headerBox = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(true, false, true, true)); headerBox.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); this.addComponent(headerBox); Label filterLbl = new Label(" Saved Filter: ", ContentMode.HTML); headerBox.with(filterLbl).withAlign(filterLbl, Alignment.MIDDLE_LEFT); filterBox = new MHorizontalLayout().withSpacing(true); headerBox.with(filterBox).withAlign(filterBox, Alignment.MIDDLE_LEFT); buildFilterBox(null);//w w w . j av a 2 s . co m this.searchContainer = new MVerticalLayout().withSpacing(true).withMargin(false); this.searchContainer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); controlsBtn = new MHorizontalLayout().withSpacing(true).withMargin(true); Button addCriteriaBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD_CRITERIA), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { CriteriaSelectionLayout newCriteriaBar = new CriteriaSelectionLayout( searchContainer.getComponentCount() + 1); searchContainer.addComponent(newCriteriaBar); } }); addCriteriaBtn.setStyleName(UIConstants.THEME_BROWN_LINK); addCriteriaBtn.setIcon(FontAwesome.PLUS); controlsBtn.with(addCriteriaBtn); this.with(searchContainer, controlsBtn); }
From source file:com.esofthead.mycollab.vaadin.ui.BuildCriterionComponent.java
License:Open Source License
private void buildSaveFilterBox() { filterBox.removeAllComponents();//www . ja v a 2 s.co m final TextField queryTextField = new TextField(); queryTextField.setWidth("125px"); filterBox.addComponent(queryTextField); Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { String queryText = queryTextField.getValue(); saveSearchCriteria(queryText); } }); saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK); saveBtn.setIcon(FontAwesome.SAVE); filterBox.addComponent(saveBtn); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { buildFilterBox(null); } }); cancelBtn.addStyleName(UIConstants.THEME_GRAY_LINK); filterBox.addComponent(cancelBtn); }
From source file:com.esofthead.mycollab.vaadin.ui.ConfirmDialogFactory.java
License:Open Source License
@Override public ConfirmDialog create(final String caption, final String message, final String okCaption, final String cancelCaption, String notOkCaption) { final ConfirmDialog d = super.create(caption, message, okCaption, cancelCaption, notOkCaption); d.getContent().setStyleName("custom-dialog"); d.getContent().setHeightUndefined(); d.setHeightUndefined();//w w w . j a v a 2 s. co m final Button ok = d.getOkButton(); ok.setStyleName(UIConstants.THEME_GREEN_LINK); HorizontalLayout buttons = (HorizontalLayout) ok.getParent(); buttons.setHeightUndefined(); final Button cancelBtn = d.getCancelButton(); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); cancelBtn.focus(); return d; }
From source file:com.esofthead.mycollab.vaadin.ui.DynamicQueryParamLayout.java
License:Open Source License
private HorizontalLayout createButtonControls() { MHorizontalLayout buttonControls = new MHorizontalLayout().withSpacing(true).withMargin(true); final Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/*from w w w. ja va2s.c o m*/ public void buttonClick(final ClickEvent event) { DynamicQueryParamLayout.this.callSearchAction(); } }); searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK); searchBtn.setIcon(FontAwesome.SEARCH); buttonControls.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_CENTER); final Button clearBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLEAR), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { clearFields(); } }); clearBtn.setStyleName(UIConstants.THEME_GRAY_LINK); buttonControls.with(clearBtn).withAlign(clearBtn, Alignment.MIDDLE_CENTER); final Button basicSearchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_BASIC_SEARCH), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { ((DefaultGenericSearchPanel<S>) DynamicQueryParamLayout.this.searchPanel) .moveToBasicSearchLayout(); } }); basicSearchBtn.setStyleName("link"); buttonControls.with(basicSearchBtn).withAlign(basicSearchBtn, Alignment.MIDDLE_CENTER); return buttonControls; }
From source file:com.esofthead.mycollab.vaadin.ui.EditFormControlsGenerator.java
License:Open Source License
public HorizontalLayout createButtonControls(final boolean isSaveBtnVisible, final boolean isSaveAndNewBtnVisible, final boolean isCancelBtnVisible) { final HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);/*from ww w. j a v a 2s .c o m*/ layout.setSizeUndefined(); layout.setStyleName("addNewControl"); if (isSaveBtnVisible) { final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (EditFormControlsGenerator.this.editForm.validateForm()) { EditFormControlsGenerator.this.editForm.fireSaveForm(); } } }); saveBtn.setIcon(FontAwesome.SAVE); saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK); layout.addComponent(saveBtn); layout.setComponentAlignment(saveBtn, Alignment.MIDDLE_CENTER); } if (isSaveAndNewBtnVisible) { final Button saveAndNewBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE_NEW), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (EditFormControlsGenerator.this.editForm.validateForm()) { EditFormControlsGenerator.this.editForm.fireSaveAndNewForm(); } } }); saveAndNewBtn.setIcon(FontAwesome.SHARE_ALT); saveAndNewBtn.setStyleName(UIConstants.THEME_GREEN_LINK); layout.addComponent(saveAndNewBtn); layout.setComponentAlignment(saveAndNewBtn, Alignment.MIDDLE_CENTER); } if (isCancelBtnVisible) { final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EditFormControlsGenerator.this.editForm.fireCancelForm(); } }); cancelBtn.setIcon(FontAwesome.MINUS); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); layout.addComponent(cancelBtn); layout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_CENTER); } return layout; }
From source file:com.esofthead.mycollab.vaadin.ui.FeedbackWindow.java
License:Open Source License
private void initUI() { GridLayout mainLayout = new GridLayout(2, 5); mainLayout.setMargin(true);// w ww .j av a 2s .co m mainLayout.setSpacing(true); emailNameTextField = new TextField(); emailNameTextField.setWidth("500px"); Label emailName = new Label("Your name: "); mainLayout.addComponent(emailName, 0, 0); mainLayout.addComponent(emailNameTextField, 1, 0); emailTextField = new TextField(); emailTextField.setWidth("500px"); emailTextField.setRequired(true); Label emailLbl = new Label("Your email: "); mainLayout.addComponent(emailLbl, 0, 1); mainLayout.addComponent(emailTextField, 1, 1); subjectTextField = new TextField(); subjectTextField.setWidth("500px"); subjectTextField.setRequired(true); Label subjectLbl = new Label("Subject: "); mainLayout.addComponent(subjectLbl, 0, 2); mainLayout.addComponent(subjectTextField, 1, 2); final RichTextArea contentArea = new RichTextArea(); contentArea.setImmediate(true); contentArea.setWidth(500, Sizeable.Unit.PIXELS); contentArea.setHeight(200, Sizeable.Unit.PIXELS); Label contentLbl = new Label("Your feedback: "); mainLayout.addComponent(contentLbl, 0, 3); mainLayout.addComponent(contentArea, 1, 3); initDefaultData(); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("350px"); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); // Panel attachedFilepanel = new Panel(); VerticalLayout contentLayout = new VerticalLayout(); contentLayout.setHeight("80px"); contentLayout.setStyleName("noneBorder-panel"); contentLayout.setSizeUndefined(); contentLayout.addComponent(uploadExt); // attachedFilepanel.setContent(contentLayout); controlsLayout.addComponent(contentLayout); controlsLayout.setComponentAlignment(contentLayout, Alignment.BOTTOM_LEFT); controlsLayout.setExpandRatio(contentLayout, 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) { FeedbackWindow.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) { String email = emailTextField.getValue().toString().trim(); String subject = subjectTextField.getValue().toString().trim(); if (!StringUtils.isValidEmail(email)) { NotificationUtil.showWarningNotification("The email is not valid, please check it again!"); return; } if (!email.equals("") && !subject.equals("")) { ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class); List<File> listFile = attachments.getListFile(); List<EmailAttachementSource> emailAttachmentSource = null; if (CollectionUtils.isNotEmpty(listFile)) { emailAttachmentSource = new ArrayList<EmailAttachementSource>(); for (File file : listFile) { emailAttachmentSource.add(new FileEmailAttachmentSource(file)); } } String nameEmailFrom = emailNameTextField.getValue().toString().trim(); nameEmailFrom = nameEmailFrom.equals("") ? email : nameEmailFrom; String toEmail = SiteConfiguration.getSendErrorEmail(); FeedbackWindow.this.close(); systemMailService.sendHTMLMail(email, nameEmailFrom, Arrays.asList(new MailRecipientField(toEmail, toEmail)), null, null, subject, contentArea.getValue().toString(), emailAttachmentSource); } else { NotificationUtil.showWarningNotification( "The email field and subject field must be not empty! Please fulfil them before pressing enter button."); } } }); sendBtn.setStyleName(UIConstants.THEME_GREEN_LINK); controlsLayout.addComponent(sendBtn); controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT); mainLayout.addComponent(controlsLayout, 0, 4, 1, 4); this.setContent(mainLayout); }
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);/* www . ja v a 2 s .c o 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.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);/*from w w w . j a v a 2 s .com*/ addComponent(wrap); }