List of usage examples for com.vaadin.ui Button addClickListener
public Registration addClickListener(ClickListener listener)
From source file:com.esofthead.mycollab.module.file.view.components.FileBreadcrumb.java
License:Open Source License
private void displayExternalFolder(final ExternalFolder folder) { String folderPath = folder.getPath(); final StringBuffer curPath = new StringBuffer(""); String[] path = folderPath.split("/"); if (path.length == 0) { final Button btn = new Button(); btn.setCaption(StringUtils.trim(folder.getExternalDrive().getFoldername(), 25, true)); this.addLink(btn); this.select(2); return;// w w w .j a va 2s. c o m } for (int i = 0; i < path.length; i++) { String pathName = path[i]; if (i == 0) { pathName = folder.getExternalDrive().getFoldername(); curPath.append("/"); } else { curPath.append(pathName); } final Button btn = new Button(); btn.setCaption(StringUtils.trim(pathName, 25, true)); btn.setDescription(pathName); final String currentFolderPath = curPath.toString(); btn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { FileSearchCriteria criteria = new FileSearchCriteria(); criteria.setBaseFolder(currentFolderPath); criteria.setRootFolder("/"); criteria.setStorageName(StorageNames.DROPBOX); criteria.setExternalDrive(folder.getExternalDrive()); notifySearchHandler(criteria); } }); this.select(i + 1); this.addLink(btn); this.setLinkEnabled(true, i + 1); if (i < path.length - 1) { curPath.append("/"); } } }
From source file:com.esofthead.mycollab.module.file.view.components.ResourcesDisplayComponent.java
License:Open Source License
public ResourcesDisplayComponent(final String rootPath, final Folder rootFolder) { this.setSpacing(true); this.baseFolder = rootFolder; this.rootPath = rootPath; externalResourceService = ApplicationContextUtil.getSpringBean(ExternalResourceService.class); externalDriveService = ApplicationContextUtil.getSpringBean(ExternalDriveService.class); resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class); VerticalLayout mainBodyLayout = new VerticalLayout(); mainBodyLayout.setSpacing(true);/*w w w.j av a 2 s.c o m*/ mainBodyLayout.addStyleName("box-no-border-left"); // file breadcrum --------------------- HorizontalLayout breadcrumbContainer = new HorizontalLayout(); breadcrumbContainer.setMargin(false); fileBreadCrumb = new FileBreadcrumb(rootPath); breadcrumbContainer.addComponent(fileBreadCrumb); mainBodyLayout.addComponent(breadcrumbContainer); // Construct controllGroupBtn controllGroupBtn = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)); final Button selectAllBtn = new Button(); selectAllBtn.addStyleName(UIConstants.THEME_BROWN_LINK); selectAllBtn.setIcon(FontAwesome.SQUARE_O); selectAllBtn.setData(false); selectAllBtn.setImmediate(true); selectAllBtn.setDescription("Select all"); selectAllBtn.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (!(Boolean) selectAllBtn.getData()) { selectAllBtn.setIcon(FontAwesome.CHECK_SQUARE_O); selectAllBtn.setData(true); resourcesContainer.setAllValues(true); } else { selectAllBtn.setData(false); selectAllBtn.setIcon(FontAwesome.SQUARE_O); resourcesContainer.setAllValues(false); } } }); controllGroupBtn.with(selectAllBtn).withAlign(selectAllBtn, Alignment.MIDDLE_LEFT); Button goUpBtn = new Button("Up"); goUpBtn.setIcon(FontAwesome.ARROW_UP); goUpBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Folder parentFolder; if (baseFolder instanceof ExternalFolder) { if (baseFolder.getPath().equals("/")) { parentFolder = baseFolder; } else { parentFolder = externalResourceService.getParentResourceFolder( ((ExternalFolder) baseFolder).getExternalDrive(), baseFolder.getPath()); } } else if (!baseFolder.getPath().equals(rootPath)) { parentFolder = resourceService.getParentFolder(baseFolder.getPath()); } else { parentFolder = baseFolder; } resourcesContainer.constructBody(parentFolder); baseFolder = parentFolder; fileBreadCrumb.gotoFolder(baseFolder); } }); goUpBtn.setDescription("Back to parent folder"); goUpBtn.setStyleName(UIConstants.THEME_BROWN_LINK); goUpBtn.setDescription("Go up"); controllGroupBtn.with(goUpBtn).withAlign(goUpBtn, Alignment.MIDDLE_LEFT); ButtonGroup navButton = new ButtonGroup(); navButton.addStyleName(UIConstants.THEME_BROWN_LINK); Button createBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CREATE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { AddNewFolderWindow addnewFolderWindow = new AddNewFolderWindow(); UI.getCurrent().addWindow(addnewFolderWindow); } }); createBtn.setIcon(FontAwesome.PLUS); createBtn.addStyleName(UIConstants.THEME_BROWN_LINK); createBtn.setDescription("Create new folder"); createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); navButton.addButton(createBtn); Button uploadBtn = new Button("Upload", new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { MultiUploadContentWindow multiUploadWindow = new MultiUploadContentWindow(); UI.getCurrent().addWindow(multiUploadWindow); } }); uploadBtn.setIcon(FontAwesome.UPLOAD); uploadBtn.addStyleName(UIConstants.THEME_BROWN_LINK); uploadBtn.setDescription("Upload"); uploadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); navButton.addButton(uploadBtn); Button downloadBtn = new Button("Download"); LazyStreamSource streamSource = new LazyStreamSource() { private static final long serialVersionUID = 1L; @Override protected StreamSource buildStreamSource() { Collection<Resource> selectedResources = getSelectedResources(); return StreamDownloadResourceUtil.getStreamSourceSupportExtDrive(selectedResources); } @Override public String getFilename() { Collection<Resource> selectedResources = getSelectedResources(); return StreamDownloadResourceUtil.getDownloadFileName(selectedResources); } }; OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource); downloaderExt.extend(downloadBtn); downloadBtn.setIcon(FontAwesome.DOWNLOAD); downloadBtn.addStyleName(UIConstants.THEME_BROWN_LINK); downloadBtn.setDescription("Download"); downloadBtn.setEnabled(AppContext.canRead(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); navButton.addButton(downloadBtn); Button moveToBtn = new Button("Move", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Collection<Resource> selectedResources = getSelectedResources(); if (CollectionUtils.isNotEmpty(selectedResources)) { MoveResourceWindow moveResourceWindow = new MoveResourceWindow(selectedResources); UI.getCurrent().addWindow(moveResourceWindow); } else { NotificationUtil.showWarningNotification("Please select at least one item to move"); } } }); moveToBtn.setIcon(FontAwesome.ARROWS); moveToBtn.addStyleName(UIConstants.THEME_BROWN_LINK); moveToBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); moveToBtn.setDescription("Move to"); navButton.addButton(moveToBtn); Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Collection<Resource> selectedResources = getSelectedResources(); if (CollectionUtils.isEmpty(selectedResources)) { NotificationUtil.showWarningNotification("Please select at least one item to delete"); } else { deleteResourceAction(); } } }); deleteBtn.setIcon(FontAwesome.TRASH_O); deleteBtn.addStyleName(UIConstants.THEME_RED_LINK); deleteBtn.setDescription("Delete resource"); deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); navButton.addButton(deleteBtn); controllGroupBtn.addComponent(navButton); mainBodyLayout.addComponent(controllGroupBtn); resourcesContainer = new ResourcesContainer(baseFolder); mainBodyLayout.addComponent(resourcesContainer); this.addComponent(mainBodyLayout); }
From source file:com.esofthead.mycollab.module.project.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"); ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock);/*w w w .j a v a2s . c om*/ 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(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.project.ui.components.ProjectCommentInput.java
License:Open Source License
ProjectCommentInput(final ReloadableComponent component, final CommentType typeVal, final Integer extraTypeIdVal, final boolean cancelButtonEnable, final boolean isSendingEmailRelay, final Class<? extends SendingRelayEmailNotificationAction> emailHandler) { super();// www . j ava2s . co m this.withWidth("100%").withStyleName("message"); final SimpleUser currentUser = AppContext.getSession(); MVerticalLayout userBlock = new MVerticalLayout().withMargin(false).withWidth("80px"); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); ClickListener gotoUser = new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new ProjectMemberEvent.GotoRead(this, currentUser.getUsername())); } }; Button userAvatarBtn = UserAvatarControlFactory.createUserAvatarButtonLink(currentUser.getAvatarid(), currentUser.getDisplayName()); userAvatarBtn.addClickListener(gotoUser); userBlock.addComponent(userAvatarBtn); Button userName = new Button(currentUser.getDisplayName()); userName.setStyleName("user-name"); userName.addStyleName("link"); userName.addStyleName(UIConstants.WORD_WRAP); userName.addClickListener(gotoUser); userBlock.addComponent(userName); this.addComponent(userBlock); MVerticalLayout textAreaWrap = new MVerticalLayout().withWidth("100%").withStyleName("message-container"); this.addComponent(textAreaWrap); this.setExpandRatio(textAreaWrap, 1.0f); type = typeVal; extraTypeId = extraTypeIdVal; commentArea = new RichTextArea(); commentArea.setWidth("100%"); commentArea.setHeight("200px"); final AttachmentPanel attachments = new AttachmentPanel(); final MHorizontalLayout controlsLayout = new MHorizontalLayout().withSpacing(true).withMargin(false) .withWidth("100%"); final MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.with(uploadExt).withAlign(uploadExt, Alignment.TOP_LEFT).expand(uploadExt); final Label emptySpace = new Label(); controlsLayout.addComponent(emptySpace); controlsLayout.setExpandRatio(emptySpace, 1.0f); 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); } 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) { 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 = commentService.saveWithSession(comment, AppContext.getUsername(), isSendingEmailRelay, emailHandler); String attachmentPath = AttachmentUtils.getProjectEntityCommentAttachmentPath(typeVal, AppContext.getAccountId(), CurrentProjectVariables.getProjectId(), 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.THEME_GREEN_LINK); newCommentBtn.setIcon(FontAwesome.SEND); controlsLayout.with(newCommentBtn).withAlign(newCommentBtn, Alignment.TOP_RIGHT); textAreaWrap.addComponent(commentArea); textAreaWrap.addComponent(controlsLayout); }
From source file:com.esofthead.mycollab.module.project.ui.components.ProjectFollowersComp.java
License:Open Source License
public void displayFollowers(final V bean) { this.bean = bean; this.removeAllComponents(); this.withSpacing(true).withMargin(new MarginInfo(false, false, false, true)); MHorizontalLayout header = new MHorizontalLayout().withSpacing(true); Label followerHeader = new Label( FontAwesome.EYE.getHtml() + " " + AppContext.getMessage(FollowerI18nEnum.OPT_SUB_INFO_WATCHERS), ContentMode.HTML);// www. j ava2s . 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"); editBtn.addStyleName("info-hdr"); header.addComponent(editBtn); } this.addComponent(header); Label sep = new Label("/"); sep.setStyleName("info-hdr"); header.addComponent(sep); currentUserFollow = isUserWatching(bean); final Button toogleWatching = new Button(""); toogleWatching.setStyleName("link"); toogleWatching.addStyleName("info-hdr"); 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().withWidth("100%").withSpacing(true) .withMargin(new MarginInfo(false, false, false, true)); 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.project.ui.components.TagViewComponent.java
License:Open Source License
private Button createAddTagBtn() { final Button addTagBtn = new Button("Add tag", FontAwesome.PLUS_CIRCLE); addTagBtn.addClickListener(new Button.ClickListener() { @Override// w w w. j a v a2 s .c om public void buttonClick(Button.ClickEvent clickEvent) { TagViewComponent.this.removeComponent(addTagBtn); TagViewComponent.this.addComponent(createSaveTagComp()); } }); addTagBtn.setStyleName("link"); return addTagBtn; }
From source file:com.esofthead.mycollab.module.project.ui.components.TagViewComponent.java
License:Open Source License
private HorizontalLayout createSaveTagComp() { final MHorizontalLayout layout = new MHorizontalLayout(); final SuggestField field = new SuggestField(); field.setInputPrompt("Enter tag name"); field.setMinimumQueryCharacters(2);// w w w . j a v a 2 s .co m field.setSuggestionConverter(new TagSuggestionConverter()); field.setSuggestionHandler(new SuggestField.SuggestionHandler() { @Override public List<Object> searchItems(String query) { tagQuery = query; return handleSearchQuery(query); } }); Button addBtn = new Button("Add"); addBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { String tagName = (field.getValue() == null) ? tagQuery : field.getValue().toString().trim(); if (!tagName.equals("")) { Tag tag = new Tag(); tag.setName(tagName); tag.setType(type); tag.setTypeid(typeId + ""); tag.setSaccountid(AppContext.getAccountId()); tag.setExtratypeid(CurrentProjectVariables.getProjectId()); int result = tagService.saveWithSession(tag, AppContext.getUsername()); if (result > 0) { TagViewComponent.this.removeComponent(layout); TagViewComponent.this.addComponent(new TagBlock(tag)); TagViewComponent.this.addComponent(createAddTagBtn()); } else { TagViewComponent.this.removeComponent(layout); TagViewComponent.this.addComponent(createAddTagBtn()); } } else { NotificationUtil.showWarningNotification("The tag value must have more than 2 characters"); } tagQuery = ""; } }); layout.with(field, addBtn); return layout; }
From source file:com.esofthead.mycollab.module.project.view.bug.BugSimpleSearchPanel.java
License:Open Source License
private void createBasicSearchLayout() { layoutSearchPane = new GridLayout(5, 3); layoutSearchPane.setSpacing(true);// www.j av a 2 s. c o m addTextFieldSearch(); final CheckBox chkIsOpenBug = new CheckBox("Only Open Bugs"); layoutSearchPane.addComponent(chkIsOpenBug, 2, 0); layoutSearchPane.setComponentAlignment(chkIsOpenBug, Alignment.MIDDLE_CENTER); Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH)); searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK); searchBtn.setIcon(FontAwesome.SEARCH); searchBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { searchCriteria = new BugSearchCriteria(); searchCriteria.setProjectId( new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId())); searchCriteria.setSummary(new StringSearchField(textValueField.getValue().trim())); if (chkIsOpenBug.getValue()) { searchCriteria.setStatuses(new SetSearchField<>(SearchField.AND, new String[] { BugStatus.InProgress.name(), BugStatus.Open.name(), BugStatus.ReOpened.name() })); } BugSimpleSearchPanel.this.notifySearchHandler(searchCriteria); } }); layoutSearchPane.addComponent(searchBtn, 3, 0); layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER); Button clearBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLEAR)); clearBtn.setStyleName(UIConstants.THEME_GRAY_LINK); clearBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { textValueField.setValue(""); } }); layoutSearchPane.addComponent(clearBtn, 4, 0); layoutSearchPane.setComponentAlignment(clearBtn, Alignment.MIDDLE_CENTER); this.setCompositionRoot(layoutSearchPane); }
From source file:com.esofthead.mycollab.module.project.view.bug.BugTableDisplay.java
License:Open Source License
public BugTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) { super(ApplicationContextUtil.getSpringBean(BugService.class), SimpleBug.class, viewId, requiredColumn, displayColumns);//from w w w . ja v a 2 s .c o m this.addGeneratedColumn("id", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(final Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); final Button bugSettingBtn = new Button(null, FontAwesome.COG); bugSettingBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY); final ContextMenu contextMenu = new ContextMenu(); contextMenu.setAsContextMenuOf(bugSettingBtn); contextMenu.addItemClickListener(new ContextMenuItemClickListener() { @Override public void contextMenuItemClicked(ContextMenuItemClickEvent event) { if (((ContextMenuItem) event.getSource()).getData() == null) { return; } String category = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData()) .getAction(); String value = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData()).getKey(); if ("status".equals(category)) { if (AppContext.getMessage(BugStatus.Verified).equals(value)) { UI.getCurrent().addWindow(new ApproveInputWindow(BugTableDisplay.this, bug)); } else if (AppContext.getMessage(BugStatus.InProgress).equals(value)) { bug.setStatus(BugStatus.InProgress.name()); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateWithSession(bug, AppContext.getUsername()); } else if (AppContext.getMessage(BugStatus.Open).equals(value)) { UI.getCurrent().addWindow(new ReOpenWindow(BugTableDisplay.this, bug)); } else if (AppContext.getMessage(BugStatus.Resolved).equals(value)) { UI.getCurrent().addWindow(new ResolvedInputWindow(BugTableDisplay.this, bug)); } } else if ("severity".equals(category)) { bug.setSeverity(value); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateWithSession(bug, AppContext.getUsername()); refresh(); } else if ("priority".equals(category)) { bug.setPriority(value); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateWithSession(bug, AppContext.getUsername()); refresh(); } else if ("action".equals(category)) { if ("edit".equals(value)) { EventBusFactory.getInstance() .post(new BugEvent.GotoEdit(BugTableDisplay.this, bug)); } else if ("delete".equals(value)) { 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()) { BugService bugService = ApplicationContextUtil .getSpringBean(BugService.class); bugService.removeWithSession(bug.getId(), AppContext.getUsername(), AppContext.getAccountId()); refresh(); } } }); } } } }); bugSettingBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)); bugSettingBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { displayContextMenuItem(contextMenu, bug, event.getClientX(), event.getClientY()); } }); return bugSettingBtn; } }); this.addGeneratedColumn("assignuserFullName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(), bug.getAssignuserFullName()); } }); this.addGeneratedColumn("loguserFullName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new ProjectUserLink(bug.getLogby(), bug.getLoguserAvatarId(), bug.getLoguserFullName()); } }); this.addGeneratedColumn("summary", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); String bugname = "[%s-%s] %s"; bugname = String.format(bugname, CurrentProjectVariables.getProject().getShortname(), bug.getBugkey(), bug.getSummary()); LabelLink b = new LabelLink(bugname, ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName())); if (StringUtils.isNotBlank(bug.getPriority())) { b.setIconLink(ProjectResources.getIconResourceLink12ByBugPriority(bug.getPriority())); } b.setDescription(ProjectTooltipGenerator.generateToolTipBug(AppContext.getUserLocale(), bug, AppContext.getSiteUrl(), AppContext.getTimezone())); if (bug.isCompleted()) { b.addStyleName(UIConstants.LINK_COMPLETED); } else if (bug.isOverdue()) { b.addStyleName(UIConstants.LINK_OVERDUE); } return b; } }); this.addGeneratedColumn("severity", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); Resource iconPriority = new ExternalResource( ProjectResources.getIconResourceLink12ByBugSeverity(bug.getPriority())); Embedded iconEmbedded = new Embedded(null, iconPriority); Label lbPriority = new Label(AppContext.getMessage(BugSeverity.class, bug.getSeverity())); HorizontalLayout containerField = new HorizontalLayout(); containerField.setSpacing(true); containerField.addComponent(iconEmbedded); containerField.addComponent(lbPriority); containerField.setExpandRatio(lbPriority, 1.0f); return containerField; } }); this.addGeneratedColumn("duedate", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDate(bug.getDuedate())); } }); this.addGeneratedColumn("createdtime", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDateTime(bug.getCreatedtime())); } }); this.addGeneratedColumn("resolution", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.getMessage(BugResolution.class, bug.getResolution())); } }); this.setWidth("100%"); }
From source file:com.esofthead.mycollab.module.project.view.bug.components.BugSelectionField.java
License:Open Source License
@Override protected Component initContent() { MHorizontalLayout layout = new MHorizontalLayout(); Button browseBtn = new Button(FontAwesome.ELLIPSIS_H); browseBtn.addStyleName(UIConstants.BUTTON_OPTION); browseBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING); browseBtn.addClickListener(new Button.ClickListener() { @Override//from w ww. j a v a2 s. c o m public void buttonClick(Button.ClickEvent event) { UI.getCurrent().addWindow(new BugSelectionWindow(BugSelectionField.this)); } }); layout.with(suggestField, new Label("or browse"), browseBtn); return layout; }