List of usage examples for com.vaadin.ui Button setIcon
@Override public void setIcon(Resource icon)
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 . j a v a 2s . 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.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//from www .j av a 2 s .co 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);//from w w w . j a v a 2 s .c o 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 buildFilterBox(String queryname) { filterBox.removeAllComponents();//w ww .j a va 2 s. com filterComboBox = new SavedSearchResultComboBox(); filterComboBox.setWidth("125px"); 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.THEME_GREEN_LINK); saveSearchBtn.setIcon(FontAwesome.PLUS); filterBox.addComponent(saveSearchBtn); }
From source file:com.esofthead.mycollab.vaadin.ui.BuildCriterionComponent.java
License:Open Source License
private void buildSaveFilterBox() { filterBox.removeAllComponents();//w ww . j a v a 2s . com 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.DefaultMassItemActionHandlersContainer.java
License:Open Source License
public void addActionItem(final String id, Resource resource, String groupId, String description) { ButtonGroup group = groupMap.get(groupId); if (group == null) { group = new ButtonGroup(); groupMap.put(groupId, group);/*from w w w .j a va2s. com*/ this.addComponent(group); } Button optionBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { changeOption(id); } }); optionBtn.setIcon(resource); if ("delete".equals(groupId)) { optionBtn.addStyleName(UIConstants.THEME_RED_LINK); } else { optionBtn.addStyleName(UIConstants.THEME_BLUE_LINK); } optionBtn.addStyleName("small-padding"); optionBtn.setDescription(description); group.addButton(optionBtn); }
From source file:com.esofthead.mycollab.vaadin.ui.DefaultMassItemActionHandlersContainer.java
License:Open Source License
public void addDownloadActionItem(final String id, Resource resource, String groupId, String downloadFileName, String description) {/* www . j a v a2s. c om*/ ButtonGroup group = groupMap.get(groupId); if (group == null) { group = new ButtonGroup(); groupMap.put(groupId, group); this.addComponent(group); } Button optionBtn = new Button(""); FileDownloader fileDownler = new FileDownloader( new StreamResource(new LazyStreamSource(id), downloadFileName)); fileDownler.extend(optionBtn); optionBtn.setIcon(resource); optionBtn.addStyleName(UIConstants.THEME_BLUE_LINK); optionBtn.addStyleName("small-padding"); optionBtn.setDescription(description); group.addButton(optionBtn); }
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 .j av a2 s . c om*/ 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);//w ww. j a v a2 s.co 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.ServiceMenu.java
License:Open Source License
public void addService(String serviceName, Resource linkIcon, ClickListener listener) { final Button newService = new Button(serviceName, listener); newService.setIcon(linkIcon); newService.setStyleName("link"); this.addButton(newService); }