public ProjectUserLink(String username, String userAvatarId, String displayName) { if (StringUtils.isBlank(username)) { return; } this.setContentMode(ContentMode.HTML); DivLessFormatter div = new DivLessFormatter(); String uid = UUID.randomUUID().toString(); Img avatarLink = new Img("", StorageFactory.getInstance().getAvatarPath(userAvatarId, 16)); A memberLink = new A() .setId("tag" + uid) .setHref( ProjectLinkBuilder.generateProjectMemberFullLink( CurrentProjectVariables.getProjectId(), username)) .appendText(StringUtils.trim(displayName, 30, true)); memberLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(uid, username)); memberLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid)); div.appendChild( avatarLink, DivLessFormatter.EMPTY_SPACE(), memberLink, DivLessFormatter.EMPTY_SPACE(), TooltipHelper.buildDivTooltipEnable(uid)); this.setValue(div.write()); }
private String buildTaskLink() { String uid = UUID.randomUUID().toString(); String linkName = String.format( "[#%d] - %s", task.getTaskkey(), StringUtils.trim(task.getTaskname(), maxLength, true)); A taskLink = new A() .setId("tag" + uid) .setHref( ProjectLinkBuilder.generateTaskPreviewFullLink( task.getTaskkey(), CurrentProjectVariables.getShortName())) .appendText(linkName) .setStyle("display:inline"); Div resultDiv = new DivLessFormatter().appendChild(taskLink); if (task.isOverdue()) { taskLink.setCSSClass("overdue"); resultDiv.appendChild( new Span() .setCSSClass(UIConstants.LABEL_META_INFO) .appendText(" - Due in " + AppContext.formatDuration(task.getDeadline()))); } else if (task.isCompleted()) { taskLink.setCSSClass("completed"); } taskLink.setAttribute( "onmouseover", TooltipHelper.projectHoverJsFunction(uid, ProjectTypeConstants.TASK, task.getId() + "")); taskLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid)); resultDiv.appendChild(TooltipHelper.buildDivTooltipEnable(uid)); return resultDiv.write(); }
private void loadUserList(List<SimpleProjectMember> memberList) { for (SimpleProjectMember member : memberList) { this.addItem(member); this.setItemCaption(member, StringUtils.trim(member.getDisplayName(), 25, true)); this.setItemIcon( member, UserAvatarControlFactory.createAvatarResource(member.getMemberAvatarId(), 16)); } }
void displayPageInfo(Page beanItem) { MVerticalLayout header = new MVerticalLayout().withMargin(false); Label titleLbl = new Label(beanItem.getSubject()); titleLbl.setStyleName("headerName"); header.with(titleLbl); Div footer = new Div().setStyle("width:100%").setCSSClass("footer2"); Span lastUpdatedTimeTxt = new Span() .appendText( AppContext.getMessage( DayI18nEnum.LAST_UPDATED_ON, AppContext.formatPrettyTime(beanItem.getLastUpdatedTime().getTime()))) .setTitle(AppContext.formatDateTime(beanItem.getLastUpdatedTime().getTime())); String uid = UUID.randomUUID().toString(); ProjectMemberService projectMemberService = ApplicationContextUtil.getSpringBean(ProjectMemberService.class); SimpleProjectMember member = projectMemberService.findMemberByUsername( beanItem.getCreatedUser(), CurrentProjectVariables.getProjectId(), AppContext.getAccountId()); if (member != null) { Img userAvatar = new Img("", StorageFactory.getInstance().getAvatarPath(member.getMemberAvatarId(), 16)); A userLink = new A() .setId("tag" + uid) .setHref( ProjectLinkBuilder.generateProjectMemberFullLink( member.getProjectid(), member.getUsername())) .appendText(StringUtils.trim(member.getMemberFullName(), 30, true)); userLink.setAttribute( "onmouseover", TooltipHelper.userHoverJsFunction(uid, member.getUsername())); userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid)); footer.appendChild( lastUpdatedTimeTxt, new Text(" - Created by: "), userAvatar, DivLessFormatter.EMPTY_SPACE(), userLink, DivLessFormatter.EMPTY_SPACE(), TooltipHelper.buildDivTooltipEnable(uid)); } else { footer.appendChild(lastUpdatedTimeTxt); } header.addComponent(new Label(footer.write(), ContentMode.HTML)); this.addHeader(header); }
private void updateFieldValue(TextField editField) { removeComponent(editField); addComponent(taskLinkLbl); addStyleName("editable-field"); String newValue = editField.getValue(); if (StringUtils.isNotBlank(newValue) && !newValue.equals(task.getTaskname())) { task.setTaskname(newValue); taskLinkLbl.setValue(buildTaskLink()); ProjectTaskService taskService = ApplicationContextUtil.getSpringBean(ProjectTaskService.class); taskService.updateWithSession(task, AppContext.getUsername()); } isRead = !isRead; }
public UserLink(String username, String userAvatarId, String displayName) { if (StringUtils.isBlank(username)) { return; } this.setContentMode(ContentMode.HTML); String uid = UUID.randomUUID().toString(); DivLessFormatter div = new DivLessFormatter(); Img userAvatar = new Img("", StorageFactory.getInstance().getAvatarPath(userAvatarId, 16)); A userLink = new A() .setId("tag" + uid) .setHref( AccountLinkGenerator.generatePreviewFullUserLink(AppContext.getSiteUrl(), username)) .appendText(StringUtils.trim(displayName, 30, true)); userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(uid, username)); userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid)); div.appendChild( userAvatar, DivLessFormatter.EMPTY_SPACE(), userLink, DivLessFormatter.EMPTY_SPACE(), TooltipHelper.buildDivTooltipEnable(uid)); this.setValue(div.write()); }
@Override protected SearchCriteria fillUpSearchCriteria() { OpportunitySearchCriteria searchCriteria = new OpportunitySearchCriteria(); searchCriteria.setSaccountid(new NumberSearchField(AppContext.getAccountId())); if (StringUtils.isNotBlank(this.nameField.getValue().trim())) { searchCriteria.setOpportunityName(StringSearchField.and(this.nameField.getValue().trim())); } if (this.myItemCheckbox.getValue()) { searchCriteria.setAssignUsers(new SetSearchField<>(AppContext.getUsername())); } else { searchCriteria.setAssignUsers(null); } return searchCriteria; }
private void showTaskGroupInfo() { if (this.isDisplayTaskListInfo) { this.layoutHelper = new GridFormLayoutHelper(2, 3, "100%", "180px", Alignment.MIDDLE_LEFT); this.layoutHelper.getLayout().setWidth("100%"); this.layoutHelper.getLayout().addStyleName("colored-gridlayout"); this.layoutHelper.getLayout().setMargin(false); this.addComponent(this.layoutHelper.getLayout()); final Label descLbl = (Label) this.layoutHelper.addComponent( new Label(), "Description", 0, 0, 2, "100%", Alignment.TOP_RIGHT); descLbl.setContentMode(ContentMode.HTML); descLbl.setValue(StringUtils.preStringFormat(this.taskList.getDescription())); this.layoutHelper.addComponent( new ProjectUserFormLinkField( this.taskList.getOwner(), this.taskList.getOwnerAvatarId(), this.taskList.getOwnerFullName()), LocalizationHelper.getMessage(GenericI18Enum.FORM_ASSIGNEE_FIELD), 0, 1, Alignment.TOP_RIGHT); final DefaultFormViewFieldFactory.FormLinkViewField milestoneLink = new DefaultFormViewFieldFactory.FormLinkViewField( this.taskList.getMilestoneName(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { EventBus.getInstance() .fireEvent( new MilestoneEvent.GotoRead( this, TaskDisplayComponent.this.taskList.getMilestoneid())); } }, MyCollabResource.newResource("icons/16/project/milestone.png")); this.layoutHelper.addComponent( milestoneLink, LocalizationHelper.getMessage(TaskI18nEnum.FORM_PHASE_FIELD), 1, 1, Alignment.TOP_RIGHT); this.taskListProgress = (ProgressPercentageIndicator) this.layoutHelper.addComponent( new ProgressPercentageIndicator(this.taskList.getPercentageComplete()), "Progress", 0, 2); this.taskListProgress.setWidth("100px"); HorizontalLayout taskNumberProgress = new HorizontalLayout(); taskNumberProgress.setSpacing(true); taskNumberProgress = (HorizontalLayout) this.layoutHelper.addComponent(taskNumberProgress, "Number of open tasks", 1, 2); this.taskNumberLbl = new Label( "(" + this.taskList.getNumOpenTasks() + "/" + this.taskList.getNumAllTasks() + ")"); taskNumberProgress.addComponent(this.taskNumberLbl); } this.taskDisplay = new TaskTableDisplay( new String[] { "id", "taskname", "startdate", "deadline", "percentagecomplete", "assignUserFullName" }, new String[] { "", LocalizationHelper.getMessage(TaskI18nEnum.TABLE_TASK_NAME_HEADER), LocalizationHelper.getMessage(TaskI18nEnum.TABLE_START_DATE_HEADER), LocalizationHelper.getMessage(TaskI18nEnum.TABLE_DUE_DATE_HEADER), LocalizationHelper.getMessage(TaskI18nEnum.TABLE_PER_COMPLETE_HEADER), LocalizationHelper.getMessage(TaskI18nEnum.TABLE_ASSIGNEE_HEADER) }); this.addComponent(this.taskDisplay); this.taskDisplay.addTableListener( new ApplicationEventListener<TableClickEvent>() { private static final long serialVersionUID = 1L; @Override public Class<? extends ApplicationEvent> getEventType() { return TableClickEvent.class; } @Override public void handle(final TableClickEvent event) { final SimpleTask task = (SimpleTask) event.getData(); if ("taskname".equals(event.getFieldName())) { EventBus.getInstance() .fireEvent(new TaskEvent.GotoRead(TaskDisplayComponent.this, task.getId())); } else if ("closeTask".equals(event.getFieldName()) || "reopenTask".equals(event.getFieldName()) || "pendingTask".equals(event.getFieldName()) || "deleteTask".equals(event.getFieldName())) { TaskDisplayComponent.this.removeAllComponents(); final ProjectTaskListService taskListService = ApplicationContextUtil.getSpringBean(ProjectTaskListService.class); TaskDisplayComponent.this.taskList = taskListService.findById( TaskDisplayComponent.this.taskList.getId(), AppContext.getAccountId()); TaskDisplayComponent.this.showTaskGroupInfo(); } } }); this.createTaskBtn = new Button( LocalizationHelper.getMessage(TaskI18nEnum.NEW_TASK_ACTION), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { TaskDisplayComponent.this.removeAllComponents(); final TaskAddPopup taskAddView = new TaskAddPopup(TaskDisplayComponent.this, TaskDisplayComponent.this.taskList); if (TaskDisplayComponent.this.layoutHelper != null) { TaskDisplayComponent.this.addComponent( TaskDisplayComponent.this.layoutHelper.getLayout(), 0); TaskDisplayComponent.this.addComponent(TaskDisplayComponent.this.taskDisplay, 1); TaskDisplayComponent.this.addComponent(taskAddView, 2); } else { TaskDisplayComponent.this.addComponent(TaskDisplayComponent.this.taskDisplay, 0); TaskDisplayComponent.this.addComponent(taskAddView, 1); } TaskDisplayComponent.this.removeComponent(TaskDisplayComponent.this.createTaskBtn); } }); this.createTaskBtn.setEnabled( CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); this.createTaskBtn.setIcon(MyCollabResource.newResource("icons/16/addRecord.png")); this.createTaskBtn.setStyleName(UIConstants.THEME_BLUE_LINK); final VerticalLayout taskGroupFooter = new VerticalLayout(); taskGroupFooter.setMargin(true); taskGroupFooter.addStyleName("task-list-footer"); taskGroupFooter.addComponent(this.createTaskBtn); taskGroupFooter.setComponentAlignment(this.createTaskBtn, Alignment.MIDDLE_RIGHT); this.addComponent(taskGroupFooter); this.taskDisplay.setItems(this.taskList.getSubTasks()); }
public String getAssignUserFullName() { if (org.apache.commons.lang3.StringUtils.isBlank(assignUserFullName)) { return StringUtils.extractNameFromEmail(getAssignuser()); } return assignUserFullName; }
public String getCreatedUserFullName() { if (org.apache.commons.lang3.StringUtils.isBlank(createdUserFullName)) { return StringUtils.extractNameFromEmail(getCreateduser()); } return createdUserFullName; }
@Override public Component generateRow(final SimpleMessage message, final int rowIndex) { final HorizontalLayout messageLayout = new HorizontalLayout(); messageLayout.setStyleName("message"); messageLayout.setSpacing(true); if (message.getIsstick() != null && message.getIsstick()) { messageLayout.addStyleName("important-message"); } messageLayout.setWidth("100%"); VerticalLayout userBlock = new VerticalLayout(); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); userBlock.setWidth("80px"); userBlock.setSpacing(true); userBlock.addComponent( UserAvatarControlFactory.createUserAvatarButtonLink( message.getPostedUserAvatarId(), message.getFullPostedUserName())); Label userName = new Label(message.getFullPostedUserName()); userName.setStyleName("user-name"); userBlock.addComponent(userName); messageLayout.addComponent(userBlock); final CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); final Button title = new Button( message.getTitle(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBus.getInstance() .fireEvent( new MessageEvent.GotoRead(MessageListViewImpl.this, message.getId())); } }); title.setWidth("550px"); title.setStyleName("link"); title.addStyleName(UIConstants.WORD_WRAP); final HorizontalLayout messageHeader = new HorizontalLayout(); messageHeader.setStyleName("message-header"); messageHeader.setMargin(new MarginInfo(true, true, false, true)); final VerticalLayout leftHeader = new VerticalLayout(); title.addStyleName("message-title"); leftHeader.addComponent(title); final HorizontalLayout rightHeader = new HorizontalLayout(); rightHeader.setSpacing(true); final Label timePostLbl = new Label(DateTimeUtils.getStringDateFromNow(message.getPosteddate())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); final HorizontalLayout notification = new HorizontalLayout(); notification.setStyleName("notification"); notification.setSizeUndefined(); notification.setSpacing(true); if (message.getCommentsCount() > 0) { final HorizontalLayout commentNotification = new HorizontalLayout(); final Label commentCountLbl = new Label(Integer.toString(message.getCommentsCount())); commentCountLbl.setStyleName("comment-count"); commentCountLbl.setSizeUndefined(); commentNotification.addComponent(commentCountLbl); final Image commentIcon = new Image(null, MyCollabResource.newResource("icons/16/project/message.png")); commentNotification.addComponent(commentIcon); notification.addComponent(commentNotification); } ResourceService attachmentService = ApplicationContextUtil.getSpringBean(ResourceService.class); List<Content> attachments = attachmentService.getContents( AttachmentUtils.getProjectEntityAttachmentPath( AppContext.getAccountId(), message.getProjectid(), AttachmentType.PROJECT_MESSAGE, message.getId())); if (attachments != null && !attachments.isEmpty()) { final HorizontalLayout attachmentNotification = new HorizontalLayout(); final Label attachmentCountLbl = new Label(Integer.toString(attachments.size())); attachmentCountLbl.setStyleName("attachment-count"); attachmentCountLbl.setSizeUndefined(); attachmentNotification.addComponent(attachmentCountLbl); final Image attachmentIcon = new Image(null, MyCollabResource.newResource("icons/16/attachment.png")); attachmentNotification.addComponent(attachmentIcon); notification.addComponent(attachmentNotification); } Button deleteBtn = new Button( "", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show( UI.getCurrent(), LocalizationHelper.getMessage( GenericI18Enum.DELETE_DIALOG_TITLE, SiteConfiguration.getSiteName()), LocalizationHelper.getMessage( GenericI18Enum.CONFIRM_DELETE_RECORD_DIALOG_MESSAGE), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_YES_LABEL), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_NO_LABEL), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(final ConfirmDialog dialog) { if (dialog.isConfirmed()) { final MessageService messageService = ApplicationContextUtil.getSpringBean(MessageService.class); messageService.removeWithSession( message.getId(), AppContext.getUsername(), AppContext.getAccountId()); MessageListViewImpl.this.tableItem.setSearchCriteria(searchCriteria); } } }); } }); deleteBtn.setIcon(MyCollabResource.newResource("icons/12/project/icon_x.png")); deleteBtn.addStyleName("link"); deleteBtn.setEnabled( CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MESSAGES)); rightHeader.addComponent(timePostLbl); rightHeader.addComponent(deleteBtn); rightHeader.setExpandRatio(timePostLbl, 1.0f); messageHeader.addComponent(leftHeader); messageHeader.setExpandRatio(leftHeader, 1.0f); messageHeader.addComponent(rightHeader); messageHeader.setWidth("100%"); rowLayout.addComponent(messageHeader); final Label messageContent = new Label(StringUtils.formatExtraLink(message.getMessage()), ContentMode.HTML); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); if (notification.getComponentCount() > 0) { VerticalLayout messageFooter = new VerticalLayout(); messageFooter.setWidth("100%"); messageFooter.setStyleName("message-footer"); messageFooter.addComponent(notification); messageFooter.setMargin(true); messageFooter.setComponentAlignment(notification, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } messageLayout.addComponent(rowLayout); messageLayout.setExpandRatio(rowLayout, 1.0f); return messageLayout; }
public static String generateTooltipUser( Locale locale, SimpleUser user, String siteURL, TimeZone timeZone) { try { if (user == null) { return generateTolltipNull(locale); } Div div = new Div(); H3 userFullName = new H3() .setStyle( "font: 12px Arial, Verdana, Helvetica, sans-serif !important;line-height: normal;"); userFullName.setStyle("padding-left:10px;").appendText(user.getDisplayName()); div.appendChild(userFullName); Table table = new Table(); table.setStyle("padding-left:10px; width :380px; color: #5a5a5a; font-size:11px;"); Tr trRow1 = new Tr() .appendChild( new Td() .setStyle("width: 110px; vertical-align: top; text-align: right;") .appendText(LocalizationHelper.getMessage(locale, UserI18nEnum.FORM_EMAIL))) .appendChild( new Td() .setStyle("vertical-align: top;") .appendChild( new A() .setHref("mailto:" + user.getEmail()) .appendText(StringUtils.trimHtmlTags(user.getEmail())))); Td trRow1_value = new Td() .setStyle("width:150px;text-align: right; vertical-align: top;") .appendChild( new Img("", StorageFactory.getInstance().getAvatarPath(user.getAvatarid(), 100))); trRow1_value.setAttribute("rowspan", "5"); trRow1.appendChild( new Td() .setStyle("width: 0px; vertical-align: top; text-align: right;") .appendChild(trRow1_value)); Tr trRow2 = new Tr() .appendChild( new Td() .setStyle("width: 110px; vertical-align: top; text-align: right;") .appendText( LocalizationHelper.getMessage(locale, UserI18nEnum.FORM_TIMEZONE))) .appendChild( new Td() .setStyle("vertical-align: top;") .appendText( TimezoneMapper.getTimezoneExt(user.getTimezone()).getDisplayName())); Tr trRow3 = new Tr() .appendChild( new Td() .setStyle("width: 110px; vertical-align: top; text-align: right;") .appendText(LocalizationHelper.getMessage(locale, UserI18nEnum.FORM_COUNTRY))) .appendChild( new Td() .setStyle("vertical-align: top;") .appendText(StringUtils.trimHtmlTags(user.getCountry()))); Tr trRow4 = new Tr() .appendChild( new Td() .setStyle("width: 110px; vertical-align: top; text-align: right;") .appendText( LocalizationHelper.getMessage(locale, UserI18nEnum.FORM_WORK_PHONE))) .appendChild( new Td() .setStyle("vertical-align: top;") .appendText(StringUtils.trimHtmlTags(user.getWorkphone()))); Tr trRow5 = new Tr() .appendChild( new Td() .setStyle("width: 110px; vertical-align: top; text-align: right;") .appendText( LocalizationHelper.getMessage( locale, GenericI18Enum.FORM_LAST_ACCESSED_TIME))) .appendChild( new Td() .setStyle( "word-wrap: break-word; white-space: normal;vertical-align: top; word-break: break-all;") .appendText( DateTimeUtils.getPrettyDateValue(user.getLastaccessedtime(), locale))); table.appendChild(trRow1, trRow2, trRow3, trRow4, trRow5); div.appendChild(table); return div.write(); } catch (Exception e) { LOG.error("Error while generate tooltip for servlet project-task tooltip", e); return null; } }