List of usage examples for com.vaadin.ui Button.ClickListener Button.ClickListener
Button.ClickListener
From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java
License:Open Source License
@Override protected final ComponentContainer createLegendBox() { final CustomLayout boxWrapper = CustomLayoutExt.createLayout("legendBox"); final CssLayout mainLayout = new CssLayout(); mainLayout.setSizeUndefined();// w w w.ja v a 2s . c om final List keys = pieDataSet.getKeys(); for (int i = 0; i < keys.size(); i++) { final HorizontalLayout layout = new HorizontalLayout(); layout.setMargin(new MarginInfo(false, false, false, true)); layout.addStyleName("inline-block"); final Comparable key = (Comparable) keys.get(i); final String color = "<div style = \" width:8px;height:8px;border-radius:5px;background: #" + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length] + "\" />"; final Label lblCircle = new Label(color); lblCircle.setContentMode(ContentMode.HTML); String btnCaption; if (enumKeyCls == null) { 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(btnCaption, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { PieChartWrapper.this.onClickedDescription(key.toString()); } }); btnLink.addStyleName("link"); layout.addComponent(lblCircle); layout.setComponentAlignment(lblCircle, Alignment.MIDDLE_CENTER); layout.addComponent(btnLink); layout.setComponentAlignment(btnLink, Alignment.MIDDLE_CENTER); layout.setSizeUndefined(); mainLayout.addComponent(layout); } boxWrapper.setWidth("100%"); boxWrapper.addComponent(mainLayout, "legendBoxContent"); return boxWrapper; }
From source file:com.esofthead.mycollab.community.vaadin.web.ui.field.PopupFieldBuilder.java
License:Open Source License
public PopupView build() { view = new PopupView(new PopupView.Content() { @Override/*from w w w. jav a 2 s . c om*/ public String getMinimizedValueAsHTML() { return captionHtml; } @Override public Component getPopupComponent() { MVerticalLayout layout = new MVerticalLayout(); layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); Label infoLbl = new Label( AppContext.getMessage(GenericI18Enum.NOTIFICATION_FEATURE_NOT_AVAILABLE_IN_VERSION)); Button requestFeatureBtn = new Button("Buy the premium edition", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().addWindow(new AdWindow()); view.setPopupVisible(false); } }); requestFeatureBtn.addStyleName(UIConstants.BUTTON_ACTION); layout.with(infoLbl, requestFeatureBtn); return layout; } }); view.setDescription(description); view.setStyleName("block-popupedit"); return view; }
From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectCommentInputView.java
License:Open Source License
public ProjectCommentInputView(String typeVal, String typeIdVal, Integer extraTypeIdVal) { this.setCaption("Add a comment"); resourceService = AppContextUtil.getSpringBean(ResourceService.class); MVerticalLayout content = new MVerticalLayout().withFullWidth().withStyleName("comment-input"); this.setContent(content); type = typeVal;/* w ww. j av a2s . c o m*/ typeId = typeIdVal; extraTypeId = extraTypeIdVal; prepareUploadField(); commentInput = new TextArea(); commentInput.setWidth("100%"); commentInput.setInputPrompt(AppContext.getMessage(GenericI18Enum.M_NOTE_INPUT_PROMPT)); Button postBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { final CommentWithBLOBs comment = new CommentWithBLOBs(); comment.setComment(commentInput.getValue()); comment.setCreatedtime(new GregorianCalendar().getTime()); comment.setCreateduser(AppContext.getUsername()); comment.setSaccountid(AppContext.getAccountId()); comment.setType(type); comment.setTypeid("" + typeId); comment.setExtratypeid(extraTypeId); final CommentService commentService = AppContextUtil.getSpringBean(CommentService.class); int commentId = commentService.saveWithSession(comment, AppContext.getUsername()); String attachmentPath = AttachmentUtils.getCommentAttachmentPath(type, AppContext.getAccountId(), CurrentProjectVariables.getProjectId(), typeId, commentId); if (!"".equals(attachmentPath)) { saveContentsToRepo(attachmentPath); } getNavigationManager().navigateBack(); } }); this.setRightComponent(postBtn); content.with(commentInput, ELabel.hr(), uploadField, statusWrapper); }
From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectCommentInputView.java
License:Open Source License
private Component createAttachmentRow(String fileName) { final MHorizontalLayout uploadSucceedLayout = new MHorizontalLayout().withFullWidth(); Label uploadResult = new Label(fileName); uploadSucceedLayout.with(uploadResult).expand(uploadResult); Button removeAttachment = new Button("", new Button.ClickListener() { @Override//from ww w .ja v a2s . co m public void buttonClick(ClickEvent event) { statusWrapper.removeComponent(uploadSucceedLayout); } }); removeAttachment.setIcon(FontAwesome.TRASH); removeAttachment.setHtmlContentAllowed(true); removeAttachment.setStyleName("link"); uploadSucceedLayout.addComponent(removeAttachment); return uploadSucceedLayout; }
From source file:com.esofthead.mycollab.mobile.shell.view.MainView.java
License:Open Source License
public MainView() { super();/*www . j a v a 2 s . c om*/ this.setSizeFull(); MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth(); contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER); Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png")); contentLayout.addComponent(mainLogo); Label introText = new Label( "MyCollab helps you do all your office jobs on the computers, phones and tablets you use"); introText.setStyleName("intro-text"); contentLayout.addComponent(introText); CssLayout welcomeTextWrapper = new CssLayout(); welcomeTextWrapper.setStyleName("welcometext-wrapper"); welcomeTextWrapper.setWidth("100%"); welcomeTextWrapper.setHeight("15px"); contentLayout.addComponent(welcomeTextWrapper); Button crmButton = new Button(AppContext.getMessage(GenericI18Enum.MODULE_CRM), new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)); } }); crmButton.addStyleName(UIConstants.BUTTON_ACTION); crmButton.setWidth("100%"); contentLayout.addComponent(crmButton); Button pmButton = new Button(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT), new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null)); } }); pmButton.setWidth("100%"); pmButton.addStyleName(UIConstants.BUTTON_ACTION); contentLayout.addComponent(pmButton); this.addComponent(contentLayout); }
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);//from w w w. j a va 2s . c o m 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.CommentRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, true, false)).withWidth("100%").withStyleName("message"); UserBlock memberBlock = new UserBlock(comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock);/*w w w. j a v a 2s . c o m*/ CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, false, true)).withWidth("100%") .withStyleName("message-header"); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel timePostLbl = new ELabel(AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())), ContentMode.HTML).withDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); messageHeader.with(timePostLbl).expand(timePostLbl); // Message delete button Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); if (hasDeletePermission(comment)) { msgDeleteBtn.setVisible(true); msgDeleteBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), 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()) { CommentService commentService = ApplicationContextUtil .getSpringBean(CommentService.class); commentService.removeWithSession(comment.getId(), AppContext.getUsername(), AppContext.getAccountId()); CommentRowDisplayHandler.this.owner.removeRow(layout); } } }); } }); } else { msgDeleteBtn.setVisible(false); } rowLayout.addComponent(messageHeader); Label messageContent = new SafeHtmlLabel(comment.getComment()); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withWidth("100%") .withStyleName("message-footer"); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.with(rowLayout).expand(rowLayout); return layout; }
From source file:com.esofthead.mycollab.module.crm.ui.components.CrmActivityComponent.java
License:Open Source License
private Component buildCommentBlock(final SimpleComment comment) { final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, true, false)).withFullWidth().withStyleName("message"); ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock);/*from w w w.j a v a 2 s . c o m*/ MVerticalLayout rowLayout = new MVerticalLayout().withFullWidth().withStyleName("message-container"); MHorizontalLayout messageHeader = new MHorizontalLayout().withFullWidth(); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel timePostLbl = new ELabel(AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())), ContentMode.HTML).withDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setStyleName(UIConstants.META_INFO); if (hasDeletePermission(comment)) { Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); msgDeleteBtn.setVisible(true); msgDeleteBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), 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()) { CommentService commentService = AppContextUtil .getSpringBean(CommentService.class); commentService.removeWithSession(comment, AppContext.getUsername(), AppContext.getAccountId()); activityBox.removeComponent(layout); } } }); } }); messageHeader.with(timePostLbl, msgDeleteBtn).expand(timePostLbl); } else { messageHeader.with(timePostLbl).expand(timePostLbl); } rowLayout.addComponent(messageHeader); Label messageContent = new SafeHtmlLabel(comment.getComment()); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout().withMargin(false).withSpacing(false) .withFullWidth(); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.with(attachmentDisplay); rowLayout.addComponent(messageFooter); } layout.with(rowLayout).expand(rowLayout); return layout; }
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);// w ww.j av a2 s .c om 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.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//www.j av a 2 s .co m 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); }