List of usage examples for com.vaadin.server FontAwesome EDIT
FontAwesome EDIT
To view the source code for com.vaadin.server FontAwesome EDIT.
Click Source Link
From source file:com.mycollab.module.project.view.milestone.ToggleMilestoneSummaryField.java
License:Open Source License
ToggleMilestoneSummaryField(final SimpleMilestone milestone, int maxLength, boolean toggleStatusSupport, boolean isDeleteSupport) { this.milestone = milestone; this.maxLength = maxLength; this.setWidth("100%"); this.addStyleName("editable-field"); if (toggleStatusSupport && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { toggleStatusSelect = new CssCheckBox(); toggleStatusSelect.setSimpleMode(true); toggleStatusSelect.setValue(milestone.isCompleted()); this.addComponent(toggleStatusSelect); this.addComponent(ELabel.EMPTY_SPACE()); displayTooltip();/*from w w w. j a va 2 s . co m*/ toggleStatusSelect.addValueChangeListener(valueChangeEvent -> { if (milestone.isCompleted()) { milestone.setStatus(MilestoneStatus.InProgress.name()); titleLinkLbl.removeStyleName(WebThemes.LINK_COMPLETED); } else { milestone.setStatus(MilestoneStatus.Closed.name()); titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED); } displayTooltip(); MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class); milestoneService.updateSelectiveWithSession(milestone, UserUIContext.getUsername()); ProjectTicketSearchCriteria searchCriteria = new ProjectTicketSearchCriteria(); searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId())); searchCriteria.setTypes(new SetSearchField<>(ProjectTypeConstants.BUG, ProjectTypeConstants.RISK, ProjectTypeConstants.TASK)); searchCriteria.setMilestoneId(NumberSearchField.equal(milestone.getId())); searchCriteria.setIsOpenned(new SearchField()); ProjectTicketService genericTaskService = AppContextUtil.getSpringBean(ProjectTicketService.class); int openAssignmentsCount = genericTaskService.getTotalCount(searchCriteria); if (openAssignmentsCount > 0) { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.OPT_QUESTION, MyCollabUI.getSiteName()), UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_CLOSE_SUB_ASSIGNMENTS), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { genericTaskService.closeSubAssignmentOfMilestone(milestone.getId()); } }); } }); } titleLinkLbl = ELabel.h3(buildMilestoneLink()).withStyleName(UIConstants.LABEL_WORD_WRAP) .withWidthUndefined(); this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)) .withStyleName("toggle"); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { ToggleMilestoneSummaryField.this.removeComponent(titleLinkLbl); ToggleMilestoneSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(milestone.getName()); editField.setWidth("100%"); editField.focus(); ToggleMilestoneSummaryField.this.addComponent(editField); ToggleMilestoneSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withDescription(UserUIContext.getMessage(MilestoneI18nEnum.OPT_EDIT_PHASE_NAME)) .withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); buttonControls.with(instantEditBtn); } if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MILESTONES)) { MButton removeBtn = new MButton("", clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { AppContextUtil.getSpringBean(MilestoneService.class).removeWithSession(milestone, UserUIContext.getUsername(), MyCollabUI.getAccountId()); BlockRowRender rowRenderer = UIUtils.getRoot(ToggleMilestoneSummaryField.this, BlockRowRender.class); if (rowRenderer != null) { rowRenderer.selfRemoved(); } EventBusFactory.getInstance() .post(new MilestoneEvent.MilestoneDeleted(this, milestone.getId())); } }); }).withIcon(FontAwesome.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); buttonControls.with(removeBtn); } if (buttonControls.getComponentCount() > 0) { this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.milestone.ToggleTicketSummaryField.java
License:Open Source License
public ToggleTicketSummaryField(final ProjectTicket ticket) { this.ticket = ticket; this.setWidth("100%"); titleLinkLbl = ELabel.html(buildTicketLink()) .withStyleName(ValoTheme.LABEL_NO_MARGIN, UIConstants.LABEL_WORD_WRAP).withWidthUndefined(); if (ticket.isClosed()) { titleLinkLbl.addStyleName(WebUIConstants.LINK_COMPLETED); } else if (ticket.isOverdue()) { titleLinkLbl.addStyleName(WebUIConstants.LINK_OVERDUE); }//from w w w. jav a 2 s . co m this.addComponent(titleLinkLbl); if (CurrentProjectVariables.canWriteTicket(ticket)) { this.addStyleName("editable-field"); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { removeComponent(titleLinkLbl); removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(ticket.getName()); editField.setWidth("100%"); editField.focus(); addComponent(editField); removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ONLY, ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_CLICK_TO_EDIT)); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.page.PageListViewImpl.java
License:Open Source License
private Layout displayFolderBlock(final Folder resource) { MVerticalLayout container = new MVerticalLayout().withFullWidth().withStyleName("page-item-block"); A folderHtml = new A(ProjectLinkBuilder.generatePageFolderFullLink(CurrentProjectVariables.getProjectId(), resource.getPath())).appendText(FontAwesome.FOLDER_OPEN.getHtml() + " " + resource.getName()); ELabel folderLink = ELabel.h3(folderHtml.write()); container.addComponent(folderLink);/*from www . j a v a 2s . c o m*/ if (StringUtils.isNotBlank(resource.getDescription())) { container.addComponent(new Label(StringUtils.trimHtmlTags(resource.getDescription()))); } Label lastUpdateInfo = new ELabel(UserUIContext.getMessage(PageI18nEnum.LABEL_LAST_UPDATE, ProjectLinkBuilder.generateProjectMemberHtmlLink(CurrentProjectVariables.getProjectId(), resource.getCreatedUser(), true), UserUIContext.formatPrettyTime(resource.getCreatedTime().getTime())), ContentMode.HTML) .withDescription(UserUIContext.formatDateTime(resource.getCreatedTime().getTime())); lastUpdateInfo.addStyleName(UIConstants.META_INFO); container.addComponent(lastUpdateInfo); MButton editBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT), clickEvent -> UI.getCurrent().addWindow(new GroupPageAddWindow(resource))) .withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING) .withIcon(FontAwesome.EDIT); editBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES)); MButton deleteBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DELETE), clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { PageService pageService = AppContextUtil.getSpringBean(PageService.class); pageService.removeResource(resource.getPath()); resources.remove(resource); displayPages(resources); } }); }).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING); deleteBtn.setVisible(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PAGES)); container.addComponent(new MHorizontalLayout(editBtn, deleteBtn)); return container; }
From source file:com.mycollab.module.project.view.page.PageListViewImpl.java
License:Open Source License
private Layout displayPageBlock(final Page resource) { MVerticalLayout container = new MVerticalLayout().withFullWidth().withStyleName("page-item-block"); A pageHtml = new A( ProjectLinkBuilder.generatePageFullLink(CurrentProjectVariables.getProjectId(), resource.getPath())) .appendText(FontAwesome.FILE_WORD_O.getHtml() + " " + resource.getSubject()); ELabel pageLink = ELabel.h3(pageHtml.write()); container.with(pageLink, new SafeHtmlLabel(resource.getContent(), 400)); Label lastUpdateInfo = new ELabel(UserUIContext.getMessage(PageI18nEnum.LABEL_LAST_UPDATE, ProjectLinkBuilder.generateProjectMemberHtmlLink(CurrentProjectVariables.getProjectId(), resource.getLastUpdatedUser(), true), UserUIContext.formatPrettyTime(resource.getLastUpdatedTime().getTime())), ContentMode.HTML) .withDescription(UserUIContext.formatDateTime(resource.getLastUpdatedTime().getTime())); lastUpdateInfo.addStyleName(UIConstants.META_INFO); container.addComponent(lastUpdateInfo); MButton editBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT), clickEvent -> EventBusFactory.getInstance() .post(new PageEvent.GotoEdit(PageListViewImpl.this, resource))).withIcon(FontAwesome.EDIT) .withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING); editBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES)); MButton deleteBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DELETE), clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { PageService pageService = AppContextUtil.getSpringBean(PageService.class); pageService.removeResource(resource.getPath()); resources.remove(resource); displayPages(resources); }// w ww. java 2s. co m }); }).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING); deleteBtn.setVisible(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PAGES)); container.addComponent(new MHorizontalLayout(editBtn, deleteBtn)); return container; }
From source file:com.mycollab.module.project.view.settings.ProjectMemberListViewImpl.java
License:Open Source License
private Component generateMemberBlock(final SimpleProjectMember member) { HorizontalLayout blockContent = new HorizontalLayout(); blockContent.setStyleName("member-block"); if (ProjectMemberStatusConstants.NOT_ACCESS_YET.equals(member.getStatus())) { blockContent.addStyleName("inactive"); }/*from www. ja v a2s.c o m*/ blockContent.setWidth("350px"); Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(), 100); memberAvatar.addStyleName(UIConstants.CIRCLE_BOX); memberAvatar.setWidthUndefined(); blockContent.addComponent(memberAvatar); MVerticalLayout blockTop = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true)) .withFullWidth(); MButton editBtn = new MButton("", clickEvent -> EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoEdit(this, member))) .withIcon(FontAwesome.EDIT).withStyleName(WebThemes.BUTTON_LINK) .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS)); editBtn.setDescription("Edit user '" + member.getDisplayName() + "' information"); MButton deleteBtn = new MButton("", clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { ProjectMemberService prjMemberService = AppContextUtil .getSpringBean(ProjectMemberService.class); prjMemberService.removeWithSession(member, UserUIContext.getUsername(), MyCollabUI.getAccountId()); EventBusFactory.getInstance() .post(new ProjectMemberEvent.GotoList(ProjectMemberListViewImpl.this, null)); } }); }).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_LINK) .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS)); deleteBtn.setDescription("Remove user '" + member.getDisplayName() + "' out of this project"); MHorizontalLayout buttonControls = new MHorizontalLayout(editBtn, deleteBtn); blockTop.addComponent(buttonControls); blockTop.setComponentAlignment(buttonControls, Alignment.TOP_RIGHT); A memberLink = new A( ProjectLinkBuilder.generateProjectMemberFullLink(member.getProjectid(), member.getUsername())) .appendText(member.getMemberFullName()).setTitle(member.getMemberFullName()); ELabel memberNameLbl = ELabel.h3(memberLink.write()).withStyleName(UIConstants.TEXT_ELLIPSIS) .withFullWidth(); blockTop.with(memberNameLbl, ELabel.hr()); String roleLink = String.format("<a href=\"%s%s%s\"", MyCollabUI.getSiteUrl(), GenericLinkUtils.URL_PREFIX_PARAM, ProjectLinkGenerator.generateRolePreviewLink(member.getProjectid(), member.getProjectroleid())); ELabel memberRole = new ELabel("", ContentMode.HTML).withFullWidth() .withStyleName(UIConstants.TEXT_ELLIPSIS); if (member.isProjectOwner()) { memberRole.setValue(String.format("%sstyle=\"color: #B00000;\">%s</a>", roleLink, UserUIContext.getMessage(ProjectRoleI18nEnum.OPT_ADMIN_ROLE_DISPLAY))); } else { memberRole.setValue( String.format("%sstyle=\"color:gray;font-size:12px;\">%s</a>", roleLink, member.getRoleName())); } blockTop.addComponent(memberRole); if (Boolean.TRUE.equals(MyCollabUI.showEmailPublicly())) { Label memberEmailLabel = ELabel .html(String.format("<a href='mailto:%s'>%s</a>", member.getUsername(), member.getUsername())) .withStyleName(UIConstants.META_INFO).withFullWidth(); blockTop.addComponent(memberEmailLabel); } ELabel memberSinceLabel = ELabel .html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_SINCE, UserUIContext.formatPrettyTime(member.getJoindate()))) .withDescription(UserUIContext.formatDateTime(member.getJoindate())).withFullWidth(); blockTop.addComponent(memberSinceLabel); if (ProjectMemberStatusConstants.ACTIVE.equals(member.getStatus())) { ELabel lastAccessTimeLbl = ELabel .html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_LOGGED_IN, UserUIContext.formatPrettyTime(member.getLastAccessTime()))) .withDescription(UserUIContext.formatDateTime(member.getLastAccessTime())); blockTop.addComponent(lastAccessTimeLbl); } String memberWorksInfo = ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml() + " " + new Span().appendText("" + member.getNumOpenTasks()) .setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_TASKS)) + " " + ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG).getHtml() + " " + new Span().appendText("" + member.getNumOpenBugs()) .setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_BUGS)) + " " + FontAwesome.MONEY.getHtml() + " " + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalBillableLogTime())) .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) + " " + FontAwesome.GIFT.getHtml() + " " + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime())) .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS)); blockTop.addComponent(ELabel.html(memberWorksInfo).withStyleName(UIConstants.META_INFO)); blockContent.addComponent(blockTop); blockContent.setExpandRatio(blockTop, 1.0f); return blockContent; }
From source file:com.mycollab.module.project.view.task.components.TaskRowRenderer.java
License:Open Source License
private OptionPopupContent createPopupContent() { OptionPopupContent filterBtnLayout = new OptionPopupContent(); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { MButton editButton = new MButton(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), clickEvent -> { taskSettingPopupBtn.setPopupVisible(false); EventBusFactory.getInstance().post(new TaskEvent.GotoEdit(TaskRowRenderer.this, task)); }).withIcon(FontAwesome.EDIT); filterBtnLayout.addOption(editButton); filterBtnLayout.addSeparator();// w w w .j a v a 2s . c o m } if (!task.isCompleted()) { if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { MButton closeBtn = new MButton(AppContext.getMessage(GenericI18Enum.BUTTON_CLOSE), clickEvent -> { task.setStatus(OptionI18nEnum.StatusI18nEnum.Closed.name()); task.setPercentagecomplete(100d); ProjectTaskService projectTaskService = AppContextUtil.getSpringBean(ProjectTaskService.class); projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername()); taskSettingPopupBtn.setPopupVisible(false); closeTask(); EventBusFactory.getInstance().post(new TaskEvent.HasTaskChange(TaskRowRenderer.this, null)); }).withIcon(FontAwesome.CHECK_CIRCLE_O); filterBtnLayout.addOption(closeBtn); } } else { if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { MButton reOpenBtn = new MButton(AppContext.getMessage(GenericI18Enum.BUTTON_REOPEN), clickEvent -> { taskSettingPopupBtn.setPopupVisible(false); task.setStatus(OptionI18nEnum.StatusI18nEnum.Open.name()); task.setPercentagecomplete(0d); ProjectTaskService projectTaskService = AppContextUtil.getSpringBean(ProjectTaskService.class); projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername()); reOpenTask(); EventBusFactory.getInstance().post(new TaskEvent.HasTaskChange(TaskRowRenderer.this, null)); }).withIcon(FontAwesome.UNLOCK); filterBtnLayout.addOption(reOpenBtn); } } filterBtnLayout.addSeparator(); if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)) { MButton deleteBtn = new MButton(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), clickEvent -> { taskSettingPopupBtn.setPopupVisible(false); 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), confirmDialog -> { if (confirmDialog.isConfirmed()) { ProjectTaskService projectTaskService = AppContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.removeWithSession(task, AppContext.getUsername(), AppContext.getAccountId()); deleteTask(); } }); }).withIcon(FontAwesome.TRASH_O); filterBtnLayout.addDangerOption(deleteBtn); } return filterBtnLayout; }
From source file:com.mycollab.module.project.view.task.components.ToggleTaskSummaryField.java
License:Open Source License
public ToggleTaskSummaryField(final SimpleTask task, int maxLength) { this.setWidth("100%"); this.maxLength = maxLength; this.task = task; titleLinkLbl = ELabel.html(buildTaskLink()).withWidthUndefined().withStyleName(UIConstants.LABEL_WORD_WRAP); this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { this.addStyleName("editable-field"); MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { ToggleTaskSummaryField.this.removeComponent(titleLinkLbl); ToggleTaskSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(task.getTaskname()); editField.setWidth("100%"); editField.focus();// ww w. j a va2 s . com ToggleTaskSummaryField.this.addComponent(editField); ToggleTaskSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ONLY, ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setDescription("Edit task name"); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.task.ToggleTaskSummaryField.java
License:Open Source License
public ToggleTaskSummaryField(final SimpleTask task, int maxLength, boolean toggleStatusSupport, boolean canRemove) { this.setWidth("100%"); this.maxLength = maxLength; this.task = task; titleLinkLbl = ELabel.html(buildTaskLink()).withWidthUndefined().withStyleName(UIConstants.LABEL_WORD_WRAP); if (toggleStatusSupport && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { toggleStatusSelect = new CssCheckBox(); toggleStatusSelect.setSimpleMode(true); toggleStatusSelect.setValue(task.isCompleted()); displayTooltip();//from w w w .j av a 2s . co m toggleStatusSelect.addValueChangeListener(valueChangeEvent -> { if (task.isCompleted()) { task.setStatus(StatusI18nEnum.Open.name()); task.setPercentagecomplete(0d); titleLinkLbl.removeStyleName(WebThemes.LINK_COMPLETED); } else { task.setStatus(StatusI18nEnum.Closed.name()); task.setPercentagecomplete(100d); titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED); } displayTooltip(); ProjectTaskService projectTaskService = AppContextUtil.getSpringBean(ProjectTaskService.class); projectTaskService.updateWithSession(task, UserUIContext.getUsername()); if (StatusI18nEnum.Closed.name().equals(task.getStatus())) { Integer countOfOpenSubTasks = projectTaskService.getCountOfOpenSubTasks(task.getId()); if (countOfOpenSubTasks > 0) { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.OPT_QUESTION, MyCollabUI.getSiteName()), UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_CLOSE_SUB_ASSIGNMENTS), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { projectTaskService.massUpdateTaskStatuses(task.getId(), StatusI18nEnum.Closed.name(), MyCollabUI.getAccountId()); } }); } } }); this.addComponent(toggleStatusSelect); this.addComponent(ELabel.EMPTY_SPACE()); } this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)) .withStyleName("toggle"); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { this.addStyleName("editable-field"); MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { ToggleTaskSummaryField.this.removeComponent(titleLinkLbl); ToggleTaskSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(task.getName()); editField.setWidth("100%"); editField.focus(); ToggleTaskSummaryField.this.addComponent(editField); ToggleTaskSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setDescription(UserUIContext.getMessage(TaskI18nEnum.OPT_EDIT_TASK_NAME)); buttonControls.with(instantEditBtn); } if (canRemove && CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)) { MButton removeBtn = new MButton("", clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { AppContextUtil.getSpringBean(ProjectTaskService.class).removeWithSession(task, UserUIContext.getUsername(), MyCollabUI.getAccountId()); BlockRowRender rowRenderer = UIUtils.getRoot(ToggleTaskSummaryField.this, BlockRowRender.class); if (rowRenderer != null) { rowRenderer.selfRemoved(); } EventBusFactory.getInstance().post(new TaskEvent.TaskDeleted(this, task.getId())); } }); }).withIcon(FontAwesome.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); buttonControls.with(removeBtn); } if (buttonControls.getComponentCount() > 0) { this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.ticket.ToggleTicketSummaryField.java
License:Open Source License
public ToggleTicketSummaryField(final ProjectTicket ticket) { this.ticket = ticket; this.setWidth("100%"); titleLinkLbl = ELabel.html(buildTicketLink()) .withStyleName(ValoTheme.LABEL_NO_MARGIN, UIConstants.LABEL_WORD_WRAP).withWidthUndefined(); if (ticket.isClosed()) { titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED); } else if (ticket.isOverdue()) { titleLinkLbl.addStyleName(WebThemes.LINK_OVERDUE); }/* ww w.j ava 2 s .co m*/ this.addComponent(titleLinkLbl); if (CurrentProjectVariables.canWriteTicket(ticket)) { this.addStyleName("editable-field"); buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)) .withStyleName("toggle"); buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT); MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { removeComponent(titleLinkLbl); removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(ticket.getName()); editField.setWidth("100%"); editField.focus(); addComponent(editField); removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_CLICK_TO_EDIT)); buttonControls.with(instantEditBtn); if ((ticket.isRisk() && CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.RISKS)) || (ticket.isBug() && CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.BUGS)) || (ticket.isTask() && CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS))) { MButton removeBtn = new MButton("", clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { AppContextUtil.getSpringBean(ProjectTicketService.class).removeTicket(ticket, UserUIContext.getUsername()); BlockRowRender rowRenderer = UIUtils.getRoot(ToggleTicketSummaryField.this, BlockRowRender.class); if (rowRenderer != null) { rowRenderer.selfRemoved(); } EventBusFactory.getInstance() .post(new TicketEvent.HasTicketPropertyChanged(this, "all")); } }); }).withIcon(FontAwesome.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); buttonControls.with(removeBtn); } this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.user.ProjectInfoComponent.java
License:Open Source License
public ProjectInfoComponent(SimpleProject project) { this.withMargin(false).withFullWidth(); Component projectIcon = ProjectAssetsUtil.buildProjectLogo(project.getShortname(), project.getId(), project.getAvatarid(), 64);//from w w w .j av a2s . c o m this.with(projectIcon).withAlign(projectIcon, Alignment.TOP_LEFT); ProjectBreadcrumb breadCrumb = ViewManager.getCacheComponent(ProjectBreadcrumb.class); breadCrumb.setProject(project); MVerticalLayout headerLayout = new MVerticalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, true)); MHorizontalLayout footer = new MHorizontalLayout().withStyleName(UIConstants.META_INFO, WebThemes.FLEX_DISPLAY); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel createdTimeLbl = ELabel .html(FontAwesome.CLOCK_O.getHtml() + " " + UserUIContext.formatPrettyTime(project.getCreatedtime())) .withDescription(UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(createdTimeLbl); billableHoursLbl = ELabel .html(FontAwesome.MONEY.getHtml() + " " + NumberUtils.roundDouble(2, project.getTotalBillableHours())) .withDescription(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(billableHoursLbl); nonBillableHoursLbl = ELabel.html(FontAwesome.GIFT.getHtml() + " " + project.getTotalNonBillableHours()) .withDescription(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(nonBillableHoursLbl); if (project.getLead() != null) { Div leadAvatar = new DivLessFormatter() .appendChild(new Img("", StorageFactory.getAvatarPath(project.getLeadAvatarId(), 16)) .setCSSClass(UIConstants.CIRCLE_BOX), DivLessFormatter.EMPTY_SPACE(), new A(ProjectLinkBuilder.generateProjectMemberFullLink(project.getId(), project.getLead())) .appendText(StringUtils.trim(project.getLeadFullName(), 30, true))) .setTitle(project.getLeadFullName()); ELabel leadLbl = ELabel .html(UserUIContext.getMessage(ProjectI18nEnum.FORM_LEADER) + ": " + leadAvatar.write()) .withWidthUndefined(); footer.addComponents(leadLbl); } if (project.getHomepage() != null) { ELabel homepageLbl = ELabel .html(FontAwesome.WECHAT.getHtml() + " " + new A(project.getHomepage()) .appendText(project.getHomepage()).setTarget("_blank").write()) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); homepageLbl.setDescription(UserUIContext.getMessage(ProjectI18nEnum.FORM_HOME_PAGE)); } if (project.getNumActiveMembers() > 0) { ELabel activeMembersLbl = ELabel.html(FontAwesome.USERS.getHtml() + " " + project.getNumActiveMembers()) .withDescription(UserUIContext.getMessage(ProjectMemberI18nEnum.OPT_ACTIVE_MEMBERS)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(activeMembersLbl); } if (project.getAccountid() != null && !SiteConfiguration.isCommunityEdition()) { Div clientDiv = new Div(); if (project.getClientAvatarId() == null) { clientDiv.appendText(FontAwesome.INSTITUTION.getHtml() + " "); } else { Img clientImg = new Img("", StorageFactory.getEntityLogoPath(MyCollabUI.getAccountId(), project.getClientAvatarId(), 16)).setCSSClass(UIConstants.CIRCLE_BOX); clientDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE()); } clientDiv.appendChild(new A(ProjectLinkBuilder.generateClientPreviewFullLink(project.getAccountid())) .appendText(StringUtils.trim(project.getClientName(), 30, true))); ELabel accountBtn = ELabel.html(clientDiv.write()).withStyleName(WebThemes.BUTTON_LINK) .withWidthUndefined(); footer.addComponents(accountBtn); } if (!SiteConfiguration.isCommunityEdition()) { MButton tagBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_TAG), clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoTagListView(this, null))) .withIcon(FontAwesome.TAGS) .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK); footer.addComponents(tagBtn); MButton favoriteBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_FAVORITES), clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoFavoriteView(this, null))) .withIcon(FontAwesome.STAR) .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK); footer.addComponents(favoriteBtn); MButton eventBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_CALENDAR), clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoCalendarView(this))) .withIcon(FontAwesome.CALENDAR) .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK); footer.addComponents(eventBtn); MButton ganttChartBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_GANTT_CHART), clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoGanttChart(this, null))) .withIcon(FontAwesome.BAR_CHART_O) .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK); footer.addComponents(ganttChartBtn); } headerLayout.with(breadCrumb, footer); MHorizontalLayout topPanel = new MHorizontalLayout().withMargin(false); this.with(headerLayout, topPanel).expand(headerLayout).withAlign(topPanel, Alignment.TOP_RIGHT); if (project.isProjectArchived()) { MButton activeProjectBtn = new MButton( UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT), clickEvent -> { ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class); project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Open.name()); projectService.updateSelectiveWithSession(project, UserUIContext.getUsername()); PageActionChain chain = new PageActionChain( new ProjectScreenData.Goto(CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this, chain)); }).withStyleName(WebThemes.BUTTON_ACTION); topPanel.with(activeProjectBtn).withAlign(activeProjectBtn, Alignment.MIDDLE_RIGHT); } else { SearchTextField searchField = new SearchTextField() { public void doSearch(String value) { ProjectView prjView = UIUtils.getRoot(this, ProjectView.class); if (prjView != null) { prjView.displaySearchResult(value); } } @Override public void emptySearch() { } }; final PopupButton controlsBtn = new PopupButton(); controlsBtn.addStyleName(WebThemes.BOX); controlsBtn.setIcon(FontAwesome.ELLIPSIS_H); OptionPopupContent popupButtonsControl = new OptionPopupContent(); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS)) { MButton inviteMemberBtn = new MButton( UserUIContext.getMessage(ProjectMemberI18nEnum.BUTTON_NEW_INVITEES), clickEvent -> { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance() .post(new ProjectMemberEvent.GotoInviteMembers(this, null)); }).withIcon(FontAwesome.SEND); popupButtonsControl.addOption(inviteMemberBtn); } MButton settingBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS), clickEvent -> { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance().post(new ProjectNotificationEvent.GotoList(this, null)); }).withIcon(FontAwesome.COG); popupButtonsControl.addOption(settingBtn); popupButtonsControl.addSeparator(); if (UserUIContext.canAccess(RolePermissionCollections.CREATE_NEW_PROJECT)) { final MButton markProjectTemplateBtn = new MButton().withIcon(FontAwesome.ANCHOR); markProjectTemplateBtn.addClickListener(clickEvent -> { Boolean isTemplate = !MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE); project.setIstemplate(isTemplate); ProjectService prjService = AppContextUtil.getSpringBean(ProjectService.class); prjService.updateWithSession(project, UserUIContext.getUsername()); if (project.getIstemplate()) { markProjectTemplateBtn .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE)); } else { markProjectTemplateBtn .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE)); } }); Boolean isTemplate = MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE); if (isTemplate) { markProjectTemplateBtn .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE)); } else { markProjectTemplateBtn .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE)); } popupButtonsControl.addOption(markProjectTemplateBtn); } if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT)) { MButton editProjectBtn = new MButton(UserUIContext.getMessage(ProjectI18nEnum.EDIT), clickEvent -> { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance() .post(new ProjectEvent.GotoEdit(ProjectInfoComponent.this, project)); }).withIcon(FontAwesome.EDIT); popupButtonsControl.addOption(editProjectBtn); } if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) { MButton archiveProjectBtn = new MButton( UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECT), clickEvent -> { controlsBtn.setPopupVisible(false); ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.WINDOW_WARNING_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage( ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_ARCHIVE_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { ProjectService projectService = AppContextUtil .getSpringBean(ProjectService.class); project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Archived.name()); projectService.updateSelectiveWithSession(project, UserUIContext.getUsername()); PageActionChain chain = new PageActionChain(new ProjectScreenData.Goto( CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance() .post(new ProjectEvent.GotoMyProject(this, chain)); } }); }).withIcon(FontAwesome.ARCHIVE); popupButtonsControl.addOption(archiveProjectBtn); } if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) { popupButtonsControl.addSeparator(); MButton deleteProjectBtn = new MButton( UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_DELETE_PROJECT), clickEvent -> { controlsBtn.setPopupVisible(false); ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage( ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_DELETE_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { ProjectService projectService = AppContextUtil .getSpringBean(ProjectService.class); projectService.removeWithSession(CurrentProjectVariables.getProject(), UserUIContext.getUsername(), MyCollabUI.getAccountId()); EventBusFactory.getInstance() .post(new ShellEvent.GotoProjectModule(this, null)); } }); }).withIcon(FontAwesome.TRASH_O); popupButtonsControl.addDangerOption(deleteProjectBtn); } controlsBtn.setContent(popupButtonsControl); controlsBtn.setWidthUndefined(); topPanel.with(searchField, controlsBtn).withAlign(searchField, Alignment.TOP_RIGHT) .withAlign(controlsBtn, Alignment.TOP_RIGHT); } }