List of usage examples for com.vaadin.ui Button Button
public Button(Resource icon, ClickListener listener)
From source file:com.esofthead.mycollab.mobile.ui.MobileAttachmentUtils.java
License:Open Source License
public static Component renderAttachmentRow(final Content attachment) { String docName = attachment.getPath(); int lastIndex = docName.lastIndexOf("/"); HorizontalLayout attachmentRow = new HorizontalLayout(); attachmentRow.setStyleName("attachment-row"); attachmentRow.setWidth("100%"); attachmentRow.setSpacing(true);//from w w w.j a va2 s . c o m attachmentRow.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); CssLayout thumbnailWrap = new CssLayout(); thumbnailWrap.setWidth("25px"); thumbnailWrap.setHeight("40px"); 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.setWidth("100%"); thumbnailWrap.addComponent(thumbnail); attachmentRow.addComponent(thumbnailWrap); if (lastIndex != -1) { docName = docName.substring(lastIndex + 1, docName.length()); } if (MimeTypesUtil.isImageType(docName)) { Button b = new Button(attachment.getTitle(), new Button.ClickListener() { private static final long serialVersionUID = -1713187920922886934L; @Override public void buttonClick(Button.ClickEvent event) { AttachmentPreviewView previewView = new AttachmentPreviewView(VaadinResourceManager .getResourceManager().getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE)); EventBusFactory.getInstance().post(new ShellEvent.PushView(this, previewView)); } }); b.setWidth("100%"); attachmentRow.addComponent(b); attachmentRow.setExpandRatio(b, 1.0f); } else { Label l = new Label(attachment.getTitle()); l.setWidth("100%"); attachmentRow.addComponent(l); attachmentRow.setExpandRatio(l, 1.0f); } return attachmentRow; }
From source file:com.esofthead.mycollab.mobile.ui.MobileAttachmentUtils.java
License:Open Source License
public static Component renderAttachmentFieldRow(final Content attachment, Button.ClickListener additionalListener) { String docName = attachment.getPath(); int lastIndex = docName.lastIndexOf("/"); if (lastIndex != -1) { docName = docName.substring(lastIndex + 1, docName.length()); }/*from w w w . ja v a2s.co m*/ final HorizontalLayout attachmentLayout = new HorizontalLayout(); attachmentLayout.setSpacing(true); attachmentLayout.setStyleName("attachment-row"); attachmentLayout.setWidth("100%"); attachmentLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); CssLayout thumbnailWrap = new CssLayout(); thumbnailWrap.setWidth("25px"); thumbnailWrap.setHeight("40px"); 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.setWidth("100%"); thumbnailWrap.addComponent(thumbnail); attachmentLayout.addComponent(thumbnailWrap); Label attachmentLink = new Label(docName); attachmentLayout.addComponent(attachmentLink); attachmentLayout.setExpandRatio(attachmentLink, 1.0f); Button removeAttachment = new Button( "<span aria-hidden=\"true\" data-icon=\"" + IconConstants.DELETE + "\"></span>", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialog.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.CloseListener() { 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); } } }); } }); if (additionalListener != null) { removeAttachment.addClickListener(additionalListener); } removeAttachment.setHtmlContentAllowed(true); removeAttachment.setStyleName("link"); attachmentLayout.addComponent(removeAttachment); return attachmentLayout; }
From source file:com.esofthead.mycollab.module.crm.ui.components.CommentInput.java
License:Open Source License
@SuppressWarnings("rawtypes") CommentInput(final ReloadableComponent component, final CommentType typeVal, final String typeidVal, final Integer extraTypeIdVal, final boolean cancelButtonEnable, final boolean isSendingEmailRelay, final Class emailHandler) { this.setWidth("600px"); setSpacing(true);// w ww. ja va 2 s .c om type = typeVal; typeid = typeidVal; extraTypeId = extraTypeIdVal; commentArea = new RichTextArea(); commentArea.setWidth("100%"); commentArea.setHeight("200px"); final AttachmentPanel attachments = new AttachmentPanel(); final MHorizontalLayout controlsLayout = new MHorizontalLayout().withWidth("100%"); final MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.with(uploadExt).withAlign(uploadExt, Alignment.TOP_LEFT).expand(uploadExt); final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_POST), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { final Comment comment = new Comment(); comment.setComment(Jsoup.clean(commentArea.getValue(), Whitelist.relaxed())); comment.setCreatedtime(new GregorianCalendar().getTime()); comment.setCreateduser(AppContext.getUsername()); comment.setSaccountid(AppContext.getAccountId()); comment.setType(type.toString()); comment.setTypeid(typeid); comment.setExtratypeid(extraTypeId); final CommentService commentService = ApplicationContextUtil .getSpringBean(CommentService.class); int commentId; if (isSendingEmailRelay) { commentId = commentService.saveWithSession(comment, AppContext.getUsername(), isSendingEmailRelay, emailHandler); } else { commentId = commentService.saveWithSession(comment, AppContext.getUsername(), false, emailHandler); } String attachmentPath = ""; if (CommentType.CRM_NOTE.equals(type)) { attachmentPath = AttachmentUtils.getCrmNoteCommentAttachmentPath( AppContext.getAccountId(), Integer.parseInt(typeid), commentId); } else { // do nothing } if (!"".equals(attachmentPath)) { attachments.saveContentsToRepo(attachmentPath); } // save success, clear comment area and load list // comments again commentArea.setValue(""); attachments.removeAllAttachmentsDisplay(); component.reload(); } }); saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK); saveBtn.setIcon(FontAwesome.SEND); controlsLayout.with(saveBtn).withAlign(saveBtn, Alignment.TOP_RIGHT); if (cancelButtonEnable) { 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) { component.cancel(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); controlsLayout.addComponent(cancelBtn); controlsLayout.setComponentAlignment(cancelBtn, Alignment.TOP_RIGHT); } MVerticalLayout editBox = new MVerticalLayout(); MHorizontalLayout commentWrap = new MHorizontalLayout().withWidth("100%"); commentWrap.addStyleName("message"); SimpleUser currentUser = AppContext.getSession(); VerticalLayout userBlock = new VerticalLayout(); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); userBlock.setWidth("80px"); userBlock.setSpacing(true); userBlock.addComponent(UserAvatarControlFactory.createUserAvatarButtonLink(currentUser.getAvatarid(), currentUser.getDisplayName())); Label userName = new Label(currentUser.getDisplayName()); userName.setStyleName("user-name"); userBlock.addComponent(userName); commentWrap.addComponent(userBlock); VerticalLayout textAreaWrap = new VerticalLayout(); textAreaWrap.setStyleName("message-container"); textAreaWrap.setWidth("100%"); textAreaWrap.addComponent(editBox); commentWrap.addComponent(textAreaWrap); commentWrap.setExpandRatio(textAreaWrap, 1.0f); editBox.addComponent(commentArea); editBox.addComponent(controlsLayout); this.addComponent(commentWrap); }
From source file:com.esofthead.mycollab.module.crm.ui.components.CrmCommentInput.java
License:Open Source License
CrmCommentInput(final ReloadableComponent component, final String typeVal) { super();//from www . ja va 2 s . co m this.withMargin(new MarginInfo(true, true, false, true)).withFullWidth().withStyleName("message"); SimpleUser currentUser = AppContext.getUser(); UserBlock userBlock = new UserBlock(currentUser.getUsername(), currentUser.getAvatarid(), currentUser.getDisplayName()); MVerticalLayout textAreaWrap = new MVerticalLayout().withFullWidth().withStyleName("message-container"); this.with(userBlock, textAreaWrap).expand(textAreaWrap); type = typeVal; commentArea = new RichTextArea(); commentArea.setWidth("100%"); commentArea.setHeight("200px"); final AttachmentPanel attachments = new AttachmentPanel(); final MHorizontalLayout controlsLayout = new MHorizontalLayout().withFullWidth(); controlsLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT); final MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.with(uploadExt).withAlign(uploadExt, Alignment.TOP_LEFT).expand(uploadExt); final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLEAR), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { commentArea.setValue(""); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); final Button newCommentBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_POST), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { CommentWithBLOBs comment = new CommentWithBLOBs(); comment.setComment(Jsoup.clean(commentArea.getValue(), Whitelist.relaxed())); comment.setCreatedtime(new GregorianCalendar().getTime()); comment.setCreateduser(AppContext.getUsername()); comment.setSaccountid(AppContext.getAccountId()); comment.setType(type); comment.setTypeid(typeId); CommentService commentService = AppContextUtil.getSpringBean(CommentService.class); int commentId = commentService.saveWithSession(comment, AppContext.getUsername()); String attachmentPath = AttachmentUtils.getCommentAttachmentPath(typeVal, AppContext.getAccountId(), null, typeId, commentId); if (!"".equals(attachmentPath)) { attachments.saveContentsToRepo(attachmentPath); } // save success, clear comment area and load list // comments again commentArea.setValue(""); attachments.removeAllAttachmentsDisplay(); component.reload(); } }); newCommentBtn.setStyleName(UIConstants.BUTTON_ACTION); newCommentBtn.setIcon(FontAwesome.SEND); controlsLayout.with(cancelBtn, newCommentBtn); textAreaWrap.with(commentArea, controlsLayout); }
From source file:com.esofthead.mycollab.module.crm.ui.components.CrmFollowersComp.java
License:Open Source License
public void displayFollowers(final V bean) { this.bean = bean; this.removeAllComponents(); MHorizontalLayout header = new MHorizontalLayout(); Label followerHeader = new Label( FontAwesome.EYE.getHtml() + " " + AppContext.getMessage(FollowerI18nEnum.OPT_SUB_INFO_WATCHERS), ContentMode.HTML);/*from w w w . j av a 2s.c o m*/ followerHeader.setStyleName("info-hdr"); header.addComponent(followerHeader); if (hasEditPermission()) { Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { showEditWatchersWindow(bean); } }); editBtn.setStyleName("link"); header.addComponent(editBtn); } this.addComponent(header); header.addComponent(new Label("/")); currentUserFollow = isUserWatching(bean); final Button toogleWatching = new Button(""); toogleWatching.setStyleName("link"); toogleWatching.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (currentUserFollow) { unfollowItem(AppContext.getUsername(), bean); currentUserFollow = false; toogleWatching.setCaption(AppContext.getMessage(FollowerI18nEnum.BUTTON_FOLLOW)); } else { followItem(AppContext.getUsername(), bean); toogleWatching.setCaption(AppContext.getMessage(FollowerI18nEnum.BUTTON_UNFOLLOW)); currentUserFollow = true; } updateTotalFollowers(bean); } }); header.addComponent(toogleWatching); if (currentUserFollow) { toogleWatching.setCaption(AppContext.getMessage(FollowerI18nEnum.BUTTON_UNFOLLOW)); } else { toogleWatching.setCaption(AppContext.getMessage(FollowerI18nEnum.BUTTON_FOLLOW)); } MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true)) .withWidth("100%"); this.addComponent(layout); int totalFollowers = getTotalFollowers(bean); followersBtn = new Button(AppContext.getMessage(FollowerI18nEnum.OPT_NUM_FOLLOWERS, totalFollowers), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (hasReadPermission()) { showEditWatchersWindow(bean); } } }); followersBtn.setStyleName("link"); layout.addComponent(followersBtn); }
From source file:com.esofthead.mycollab.module.crm.ui.components.CrmListNoItemView.java
License:Open Source License
public CrmListNoItemView() { MVerticalLayout layout = new MVerticalLayout().withWidth("800px"); layout.addStyleName("case-noitem"); layout.setDefaultComponentAlignment(Alignment.TOP_CENTER); Label image = new Label(titleIcon().getHtml(), ContentMode.HTML); image.setSizeUndefined();/* w w w .j av a2 s. c o m*/ layout.with(image).withAlign(image, Alignment.TOP_CENTER); Label title = new Label(titleMessage()); title.addStyleName("h2"); title.setWidthUndefined(); layout.addComponent(title); Label hintLabel = new Label(hintMessage()); hintLabel.setWidthUndefined(); layout.addComponent(hintLabel); Button btCreateContact = new Button(actionMessage(), actionListener()); btCreateContact.setEnabled(hasPermission()); MHorizontalLayout links = new MHorizontalLayout(); links.addComponent(btCreateContact); btCreateContact.addStyleName(UIConstants.THEME_GREEN_LINK); /* * Label or = new Label("Or"); or.setStyleName("h2"); * links.addComponent(or); * * Button btImportContact = new Button("Import Cases", new * Button.ClickListener() { private static final long serialVersionUID = * 1L; * * @Override public void buttonClick(ClickEvent arg0) { * UI.getCurrent().addWindow(new CaseImportWindow()); } }); * * btImportContact.addStyleName(UIConstants.THEME_GRAY_LINK); * * * links.addComponent(btImportContact); */ layout.addComponent(links); this.with(layout).withAlign(layout, Alignment.TOP_CENTER); }
From source file:com.esofthead.mycollab.module.crm.ui.components.CrmPreviewFormControlsGenerator.java
License:Open Source License
public CrmPreviewFormControlsGenerator(final AdvancedPreviewBeanForm<T> editForm) { this.previewForm = editForm; layout = new HorizontalLayout(); Button editButtons = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_OPTION), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/* ww w. j a v a2s . c o m*/ public void buttonClick(ClickEvent event) { optionBtn.setPopupVisible(true); } }); editButtons.setWidthUndefined(); editButtons.addStyleName(UIConstants.THEME_GRAY_LINK); optionBtn = new SplitButton(editButtons); optionBtn.addStyleName(UIConstants.THEME_GRAY_LINK); }
From source file:com.esofthead.mycollab.module.crm.ui.components.CrmPreviewFormControlsGenerator.java
License:Open Source License
public HorizontalLayout createButtonControls(int buttonEnableFlags, final String permissionItem) { layout.setStyleName("control-buttons"); layout.setSpacing(true);// w ww. j av a 2 s .co m layout.setSizeUndefined(); boolean canRead = true; boolean canWrite = true; boolean canAccess = true; if (permissionItem != null) { canRead = AppContext.canRead(permissionItem); canWrite = AppContext.canWrite(permissionItem); canAccess = AppContext.canAccess(permissionItem); } MVerticalLayout popupButtonsControl = new MVerticalLayout() .withMargin(new MarginInfo(false, true, false, true)); if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) { Button addBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); final T item = previewForm.getBean(); previewForm.fireAddForm(item); } }); addBtn.setIcon(FontAwesome.PLUS); addBtn.setStyleName(UIConstants.THEME_GREEN_LINK); addBtn.setEnabled(canWrite); layout.addComponent(addBtn); } if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) { Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); final T item = previewForm.getBean(); previewForm.fireEditForm(item); } }); editBtn.setIcon(FontAwesome.EDIT); editBtn.setStyleName(UIConstants.THEME_GREEN_LINK); editBtn.setEnabled(canWrite); layout.addComponent(editBtn); } if ((buttonEnableFlags & DELETE_BTN_PRESENTED) == DELETE_BTN_PRESENTED) { Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final T item = previewForm.getBean(); previewForm.fireDeleteForm(item); } }); deleteBtn.setIcon(FontAwesome.TRASH_O); deleteBtn.setStyleName(UIConstants.THEME_RED_LINK); layout.addComponent(deleteBtn); deleteBtn.setEnabled(canAccess); } if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) { Button cloneBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLONE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); final T item = previewForm.getBean(); previewForm.fireCloneForm(item); } }); cloneBtn.setIcon(FontAwesome.ROAD); cloneBtn.setStyleName("link"); popupButtonsControl.addComponent(cloneBtn); } if ((buttonEnableFlags & HISTORY_BTN_PRESENTED) == HISTORY_BTN_PRESENTED) { Button historyBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_HISTORY), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); previewForm.showHistory(); } }); historyBtn.setIcon(FontAwesome.HISTORY); historyBtn.setStyleName("link"); popupButtonsControl.addComponent(historyBtn); } optionBtn.setContent(popupButtonsControl); if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED | (buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) { layout.addComponent(optionBtn); } ButtonGroup navigationBtns = new ButtonGroup(); navigationBtns.setStyleName("navigation-btns"); if ((buttonEnableFlags & PREVIOUS_BTN_PRESENTED) == PREVIOUS_BTN_PRESENTED) { Button previousItem = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final T item = previewForm.getBean(); previewForm.fireGotoPrevious(item); } }); previousItem.setStyleName(UIConstants.THEME_GREEN_LINK); previousItem.setIcon(FontAwesome.CHEVRON_LEFT); previousItem.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM)); navigationBtns.addButton(previousItem); previousItem.setEnabled(canRead); } if ((buttonEnableFlags & NEXT_BTN_PRESENTED) == NEXT_BTN_PRESENTED) { Button nextItemBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final T item = previewForm.getBean(); previewForm.fireGotoNextItem(item); } }); nextItemBtn.setStyleName(UIConstants.THEME_GREEN_LINK); nextItemBtn.setIcon(FontAwesome.CHEVRON_RIGHT); nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM)); navigationBtns.addButton(nextItemBtn); nextItemBtn.setEnabled(canRead); } layout.addComponent(navigationBtns); return layout; }
From source file:com.esofthead.mycollab.module.crm.ui.components.NoteListItems.java
License:Open Source License
private void initUI() { noteWrapper = new MVerticalLayout().withSpacing(true).withMargin(new MarginInfo(true, true, false, true)) .withWidth("100%").withStyleName("note-view"); this.addComponent(noteWrapper); addStyleName("note-list"); createBtn = new Button(AppContext.getMessage(CrmCommonI18nEnum.BUTTON_NEW_NOTE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/*from w ww . j a v a 2s . com*/ public void buttonClick(final ClickEvent event) { NoteEditor addCommentEditor = new NoteEditor(); noteWrapper.replaceComponent(createBtn, addCommentEditor); noteWrapper.setComponentAlignment(addCommentEditor, Alignment.TOP_LEFT); } }); createBtn.setStyleName(UIConstants.THEME_GREEN_LINK); createBtn.setIcon(FontAwesome.PLUS); noteWrapper.addComponent(createBtn); noteWrapper.setComponentAlignment(createBtn, Alignment.TOP_RIGHT); noteList = new BeanList<>(noteService, NoteRowDisplayHandler.class); noteList.setDisplayEmptyListText(false); noteList.setStyleName("noteList"); noteListContainer = new VerticalLayout(); noteWrapper.addComponent(noteListContainer); }
From source file:com.esofthead.mycollab.module.crm.ui.components.RelatedEditItemField.java
License:Open Source License
public RelatedEditItemField(String[] types, Object bean) { this.bean = bean; relatedItemComboBox = new RelatedItemComboBox(types); itemField = new TextField(); itemField.setEnabled(true);//from www .j a va 2 s . co m browseBtn = new Button(null, FontAwesome.ELLIPSIS_H); browseBtn.addStyleName(UIConstants.THEME_GRAY_LINK); browseBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { String type = (String) relatedItemComboBox.getValue(); if ("Account".equals(type)) { AccountSelectionWindow accountWindow = new AccountSelectionWindow(RelatedEditItemField.this); UI.getCurrent().addWindow(accountWindow); accountWindow.show(); } else if ("Campaign".equals(type)) { CampaignSelectionWindow campaignWindow = new CampaignSelectionWindow(RelatedEditItemField.this); UI.getCurrent().addWindow(campaignWindow); campaignWindow.show(); } else if ("Contact".equals(type)) { ContactSelectionWindow contactWindow = new ContactSelectionWindow(RelatedEditItemField.this); UI.getCurrent().addWindow(contactWindow); contactWindow.show(); } else if ("Lead".equals(type)) { LeadSelectionWindow leadWindow = new LeadSelectionWindow(RelatedEditItemField.this); UI.getCurrent().addWindow(leadWindow); leadWindow.show(); } else if ("Opportunity".equals(type)) { OpportunitySelectionWindow opportunityWindow = new OpportunitySelectionWindow( RelatedEditItemField.this); UI.getCurrent().addWindow(opportunityWindow); opportunityWindow.show(); } else if ("Case".equals(type)) { CaseSelectionWindow caseWindow = new CaseSelectionWindow(RelatedEditItemField.this); UI.getCurrent().addWindow(caseWindow); caseWindow.show(); } else { relatedItemComboBox.focus(); } } }); clearBtn = new Button(null, FontAwesome.TRASH_O); clearBtn.addStyleName(UIConstants.THEME_GRAY_LINK); clearBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { try { PropertyUtils.setProperty(RelatedEditItemField.this.bean, "typeid", null); } catch (Exception e) { LOG.error("Error while saving type", e); } } }); }