List of usage examples for com.vaadin.ui Button.ClickListener Button.ClickListener
Button.ClickListener
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()); }/*from www . j a va2 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"); 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.BuildCriterionComponent.java
License:Open Source License
public BuildCriterionComponent(GenericSearchPanel.SearchLayout<S> searchLayout, Param[] paramFields, Class<S> type, String searchCategory) { this.hostSearchLayout = searchLayout; this.paramFields = paramFields; this.type = type; this.searchCategory = searchCategory; MHorizontalLayout headerBox = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, true)); headerBox.setDefaultComponentAlignment(Alignment.TOP_LEFT); addComponent(headerBox);/*from w ww . ja v a 2 s. c o m*/ Label filterLbl = new Label(AppContext.getMessage(GenericI18Enum.OPT_SAVED_FILTER)); headerBox.with(filterLbl).withAlign(filterLbl, Alignment.TOP_LEFT); filterBox = new MHorizontalLayout(); headerBox.with(filterBox).withAlign(filterBox, Alignment.TOP_LEFT); buildFilterBox(null); searchContainer = new MVerticalLayout().withMargin(false); searchContainer.setDefaultComponentAlignment(Alignment.TOP_LEFT); MHorizontalLayout controlsBtn = new MHorizontalLayout().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.BUTTON_ACTION); addCriteriaBtn.setIcon(FontAwesome.PLUS); controlsBtn.with(addCriteriaBtn); this.with(searchContainer, controlsBtn); }
From source file:com.esofthead.mycollab.vaadin.web.ui.BuildCriterionComponent.java
License:Open Source License
private void buildFilterBox(String queryName) { filterBox.removeAllComponents();/* w w w.j av a 2 s. c o m*/ SavedSearchResultComboBox filterComboBox = new SavedSearchResultComboBox(); filterBox.addComponent(filterComboBox); Button saveSearchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_NEW_FILTER), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { buildSaveFilterBox(); } }); saveSearchBtn.addStyleName(UIConstants.BUTTON_ACTION); saveSearchBtn.setIcon(FontAwesome.PLUS); filterBox.addComponent(saveSearchBtn); }
From source file:com.esofthead.mycollab.vaadin.web.ui.BuildCriterionComponent.java
License:Open Source License
private void buildSaveFilterBox() { filterBox.removeAllComponents();// ww w .j ava 2s . c o m final TextField queryTextField = new TextField(); 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.BUTTON_ACTION); 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.BUTTON_OPTION); filterBox.addComponent(cancelBtn); }
From source file:com.esofthead.mycollab.vaadin.web.ui.DynamicQueryParamLayout.java
License:Open Source License
private HorizontalLayout createButtonControls() { MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(false, true, false, true)); Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override//from ww w. jav a2s. co m public void buttonClick(final ClickEvent event) { callSearchAction(); } }); searchBtn.setStyleName(UIConstants.BUTTON_ACTION); searchBtn.setIcon(FontAwesome.SEARCH); buttonControls.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_CENTER); 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.BUTTON_OPTION); buttonControls.with(clearBtn).withAlign(clearBtn, Alignment.MIDDLE_CENTER); 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>) searchPanel).moveToBasicSearchLayout(); } }); basicSearchBtn.setStyleName(UIConstants.BUTTON_LINK); buttonControls.with(basicSearchBtn).withAlign(basicSearchBtn, Alignment.MIDDLE_CENTER); return buttonControls; }
From source file:com.esofthead.mycollab.vaadin.web.ui.MailFormWindow.java
License:Open Source License
@SuppressWarnings("serial") private void initButtonLinkCcBcc() { btnLinkCc = new Button("Add Cc"); btnLinkCc.setStyleName(UIConstants.BUTTON_LINK); inputLayout.addComponent(btnLinkCc, 1, 0); inputLayout.setComponentAlignment(btnLinkCc, Alignment.MIDDLE_CENTER); btnLinkBcc = new Button("Add Bcc"); btnLinkBcc.setStyleName(UIConstants.BUTTON_LINK); inputLayout.addComponent(btnLinkBcc, 2, 0); inputLayout.setComponentAlignment(btnLinkBcc, Alignment.MIDDLE_CENTER); btnLinkCc.addClickListener(new Button.ClickListener() { @Override/*from w w w.j a v a 2 s . co m*/ public void buttonClick(ClickEvent event) { buttonLinkCcClick(event); } }); btnLinkBcc.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { butonLinkBccClick(event); } }); }
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);/* w w w . j a v a2 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); }
From source file:com.esofthead.mycollab.vaadin.web.ui.MassUpdateWindow.java
License:Open Source License
protected ComponentContainer buildButtonControls() { MHorizontalLayout controlsLayout = new MHorizontalLayout().withMargin(true).withFullWidth(); updateBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_UPDATE_LABEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override//from w w w. j av a2s. co m public void buttonClick(ClickEvent event) { updateForm.commit(); massUpdateCommand.massUpdate(beanItem); MassUpdateWindow.this.close(); } }); updateBtn.setStyleName(UIConstants.BUTTON_ACTION); updateBtn.setIcon(FontAwesome.SAVE); closeBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLOSE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { MassUpdateWindow.this.close(); } }); closeBtn.setStyleName(UIConstants.BUTTON_OPTION); Label spacing = new Label(); controlsLayout.with(spacing, closeBtn, updateBtn).alignAll(Alignment.MIDDLE_RIGHT).expand(spacing); return controlsLayout; }
From source file:com.esofthead.mycollab.vaadin.web.ui.MultiSelectComp.java
License:Open Source License
public MultiSelectComp(final String displayName, boolean canAddNew) { this.canAddNew = canAddNew; propertyDisplayField = displayName;//from ww w . j ava2s.c o m componentsText = new TextField(); componentsText.setNullRepresentation(""); componentsText.setReadOnly(true); componentsText.addStyleName("noBorderRight"); componentsText.setWidth("100%"); componentPopupSelection = new PopupButton(); componentPopupSelection.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { initContentPopup(); } }); popupContent = new MVerticalLayout(); componentPopupSelection.setContent(popupContent); }
From source file:com.esofthead.mycollab.vaadin.web.ui.MultiSelectComp.java
License:Open Source License
@Override protected Component initContent() { MHorizontalLayout content = new MHorizontalLayout().withSpacing(true).withWidth(widthVal) .with(componentsText).withAlign(componentsText, Alignment.MIDDLE_LEFT); componentPopupSelection.addStyleName(UIConstants.MULTI_SELECT_BG); componentPopupSelection.setDirection(Alignment.TOP_LEFT); MHorizontalLayout multiSelectComp = new MHorizontalLayout().withSpacing(false) .with(componentsText, componentPopupSelection).expand(componentsText); content.with(multiSelectComp);//from w ww . java 2s. c om if (canAddNew) { Button newBtn = new Button("New", new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { requestAddNewComp(); } }); newBtn.setStyleName(UIConstants.BUTTON_LINK); newBtn.setWidthUndefined(); content.with(newBtn); } content.expand(multiSelectComp); return content; }