List of usage examples for com.vaadin.ui Label Label
public Label(String text, ContentMode contentMode)
From source file:com.esofthead.mycollab.module.crm.ui.components.DateInfoComp.java
License:Open Source License
public void displayEntryDateTime(ValuedBean bean) { this.removeAllComponents(); this.withMargin(new MarginInfo(true, false, true, true)); Label dateInfoHeader = new Label( FontAwesome.CALENDAR.getHtml() + " " + AppContext.getMessage(CrmCommonI18nEnum.SUB_INFO_DATES), ContentMode.HTML);/*from w ww . j a v a 2 s . c o m*/ dateInfoHeader.setStyleName("info-hdr"); this.addComponent(dateInfoHeader); MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true)) .withWidth("100%"); try { Date createdDate = (Date) PropertyUtils.getProperty(bean, "createdtime"); Label createdDateLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_CREATED_DATE, DateTimeUtils.getPrettyDateValue(createdDate, AppContext.getUserLocale()))); createdDateLbl.setDescription(AppContext.formatDateTime(createdDate)); Date updatedDate = (Date) PropertyUtils.getProperty(bean, "lastupdatedtime"); Label updatedDateLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_UPDATED_DATE, DateTimeUtils.getPrettyDateValue(updatedDate, AppContext.getUserLocale()))); updatedDateLbl.setDescription(AppContext.formatDateTime(updatedDate)); layout.with(createdDateLbl, updatedDateLbl); this.addComponent(layout); } catch (Exception e) { LOG.error("Get date is failed {}", BeanUtility.printBeanObj(bean)); } }
From source file:com.esofthead.mycollab.module.crm.ui.components.PeopleInfoComp.java
License:Open Source License
public void displayEntryPeople(ValuedBean bean) { this.removeAllComponents(); this.withMargin(new MarginInfo(true, false, true, true)); Label peopleInfoHeader = new Label( FontAwesome.USER.getHtml() + " " + AppContext.getMessage(CrmCommonI18nEnum.SUB_INFO_PEOPLE), ContentMode.HTML);/*from ww w. jav a 2 s . co m*/ peopleInfoHeader.setStyleName("info-hdr"); this.addComponent(peopleInfoHeader); GridLayout layout = new GridLayout(2, 2); layout.setSpacing(true); layout.setWidth("100%"); layout.setMargin(new MarginInfo(false, false, false, true)); try { Label createdLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_CREATED_PEOPLE)); createdLbl.setSizeUndefined(); layout.addComponent(createdLbl, 0, 0); String createdUserName = (String) PropertyUtils.getProperty(bean, "createduser"); String createdUserAvatarId = (String) PropertyUtils.getProperty(bean, "createdUserAvatarId"); String createdUserDisplayName = (String) PropertyUtils.getProperty(bean, "createdUserFullName"); UserLink createdUserLink = new UserLink(createdUserName, createdUserAvatarId, createdUserDisplayName); layout.addComponent(createdUserLink, 1, 0); layout.setColumnExpandRatio(1, 1.0f); Label assigneeLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_ASSIGN_PEOPLE)); assigneeLbl.setSizeUndefined(); layout.addComponent(assigneeLbl, 0, 1); String assignUserName = (String) PropertyUtils.getProperty(bean, "assignuser"); String assignUserAvatarId = (String) PropertyUtils.getProperty(bean, "assignUserAvatarId"); String assignUserDisplayName = (String) PropertyUtils.getProperty(bean, "assignUserFullName"); UserLink assignUserLink = new UserLink(assignUserName, assignUserAvatarId, assignUserDisplayName); layout.addComponent(assignUserLink, 1, 1); } catch (Exception e) { LOG.error("Can not build user link {} ", BeanUtility.printBeanObj(bean)); } this.addComponent(layout); }
From source file:com.esofthead.mycollab.module.crm.view.lead.LeadConvertInfoWindow.java
License:Open Source License
private ComponentContainer createBody() { final CssLayout layout = new CssLayout(); layout.setSizeFull();/*ww w . j av a 2 s. co m*/ Label shortDescription = new Label( "<p> By clicking the \"Convert\" button, the following tasks will be done:</p>", ContentMode.HTML); layout.addComponent(shortDescription); VerticalLayout infoLayout = new VerticalLayout(); infoLayout.setMargin(new MarginInfo(false, true, true, true)); infoLayout.setSpacing(true); String createAccountTxt = "Create Account: <span class='" + UIConstants.TEXT_BLUE + "'>" + lead.getAccountname() + "</span>"; Label createAccountLbl = new Label(createAccountTxt, ContentMode.HTML); createAccountLbl.addStyleName(UIConstants.LABEL_CHECKED); infoLayout.addComponent(createAccountLbl); String createContactTxt = "Create Contact: <span class='" + UIConstants.TEXT_BLUE + "'>" + lead.getLastname() + (lead.getFirstname() != null ? " " + lead.getFirstname() : "") + "</span>"; Label createContactLbl = new Label(createContactTxt, ContentMode.HTML); createContactLbl.addStyleName(UIConstants.LABEL_CHECKED); infoLayout.addComponent(createContactLbl); final CheckBox isCreateOpportunityChk = new CheckBox("Create a new opportunity for this account"); isCreateOpportunityChk.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { Boolean isSelected = isCreateOpportunityChk.getValue(); if (isSelected) { opportunityForm = new LeadOpportunityForm(); Opportunity opportunity = new Opportunity(); // this is a trick to pass validation opportunity.setAccountid(0); opportunityForm.setBean(opportunity); layout.addComponent(opportunityForm); } else { layout.removeComponent(opportunityForm); } } }); infoLayout.addComponent(isCreateOpportunityChk); layout.addComponent(infoLayout); return layout; }
From source file:com.esofthead.mycollab.module.project.ui.components.AbstractPreviewItemComp.java
License:Open Source License
public AbstractPreviewItemComp(String headerText, Resource iconResource, ReadViewLayout layout) { Label headerLbl = new Label("", ContentMode.HTML); headerLbl.setSizeUndefined();// ww w .ja v a 2 s .co m headerLbl.setStyleName("hdr-text"); this.previewLayout = layout; header = new MHorizontalLayout(); if (iconResource != null) { if (iconResource instanceof FontAwesome) { String title = ((FontAwesome) iconResource).getHtml() + " " + headerText; headerLbl.setValue(title); } else { Image titleIcon = new Image(null, iconResource); ((MHorizontalLayout) header).with(titleIcon).withAlign(titleIcon, Alignment.MIDDLE_LEFT); headerLbl.setValue(headerText); } } else { headerLbl.setValue(headerText); } ((MHorizontalLayout) header).with(headerLbl).withAlign(headerLbl, Alignment.MIDDLE_LEFT).expand(headerLbl) .withStyleName("hdr-view").withWidth("100%").withSpacing(true).withMargin(true); this.addComponent(header); initContent(); }
From source file:com.esofthead.mycollab.module.project.ui.components.DateInfoComp.java
License:Open Source License
public void displayEntryDateTime(ValuedBean bean) { this.removeAllComponents(); this.withMargin(new MarginInfo(false, false, false, true)); Label dateInfoHeader = new Label( FontAwesome.CALENDAR.getHtml() + " " + AppContext.getMessage(ProjectCommonI18nEnum.SUB_INFO_DATES), ContentMode.HTML);/*w w w. j av a2s . c o m*/ dateInfoHeader.setStyleName("info-hdr"); this.addComponent(dateInfoHeader); MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true)) .withWidth("100%"); try { Date createdDate = (Date) PropertyUtils.getProperty(bean, "createdtime"); Label createdDateLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.ITEM_CREATED_DATE, DateTimeUtils.getPrettyDateValue(createdDate, AppContext.getUserLocale()))); createdDateLbl.setDescription(AppContext.formatDateTime(createdDate)); layout.addComponent(createdDateLbl); Date updatedDate = (Date) PropertyUtils.getProperty(bean, "lastupdatedtime"); Label updatedDateLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.ITEM_UPDATED_DATE, DateTimeUtils.getPrettyDateValue(updatedDate, AppContext.getUserLocale()))); updatedDateLbl.setDescription(AppContext.formatDateTime(updatedDate)); layout.addComponent(updatedDateLbl); this.addComponent(layout); } catch (Exception e) { LOG.error("Get date is failed {}", BeanUtility.printBeanObj(bean)); } }
From source file:com.esofthead.mycollab.module.project.ui.components.GenericTaskRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(AbstractBeanPagedList host, ProjectGenericTask genericTask, int rowIndex) { MHorizontalLayout rowComp = new MHorizontalLayout().withStyleName("list-row").withFullWidth(); rowComp.setDefaultComponentAlignment(Alignment.TOP_LEFT); Div issueDiv = new Div(); issueDiv.appendText(ProjectAssetsManager.getAsset(genericTask.getType()).getHtml()); String status = ""; if (genericTask.isBug()) { status = AppContext.getMessage(OptionI18nEnum.BugStatus.class, genericTask.getStatus()); } else if (genericTask.isMilestone()) { status = AppContext.getMessage(OptionI18nEnum.MilestoneStatus.class, genericTask.getStatus()); } else if (genericTask.isRisk()) { status = AppContext.getMessage(com.esofthead.mycollab.common.i18n.OptionI18nEnum.StatusI18nEnum.class, genericTask.getStatus()); } else if (genericTask.isTask()) { status = AppContext.getMessage(com.esofthead.mycollab.common.i18n.OptionI18nEnum.StatusI18nEnum.class, genericTask.getStatus()); }/*from w ww . ja v a 2s. c o m*/ issueDiv.appendChild(new Span().appendText(status).setCSSClass(UIConstants.FIELD_NOTE)); String avatarLink = StorageFactory.getInstance().getAvatarPath(genericTask.getAssignUserAvatarId(), 16); Img img = new Img(genericTask.getAssignUserFullName(), avatarLink) .setTitle(genericTask.getAssignUserFullName()); issueDiv.appendChild(img, DivLessFormatter.EMPTY_SPACE()); A taskLink = new A().setId("tag" + TOOLTIP_ID); taskLink.setAttribute("onmouseover", TooltipHelper.projectHoverJsFunction(genericTask.getType(), genericTask.getTypeId() + "")); taskLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction()); if (ProjectTypeConstants.BUG.equals(genericTask.getType()) || ProjectTypeConstants.TASK.equals(genericTask.getType())) { taskLink.appendText(genericTask.getName()); taskLink.setHref(ProjectLinkBuilder.generateProjectItemLink(genericTask.getProjectShortName(), genericTask.getProjectId(), genericTask.getType(), genericTask.getExtraTypeId() + "")); } else { taskLink.appendText(genericTask.getName()); taskLink.setHref(ProjectLinkBuilder.generateProjectItemLink(genericTask.getProjectShortName(), genericTask.getProjectId(), genericTask.getType(), genericTask.getTypeId() + "")); } issueDiv.appendChild(taskLink); if (genericTask.isClosed()) { taskLink.setCSSClass("completed"); } else if (genericTask.isOverdue()) { taskLink.setCSSClass("overdue"); issueDiv.appendChild( new Span().appendText(" - Due in " + AppContext.formatDuration(genericTask.getDueDate())) .setCSSClass(UIConstants.META_INFO)); } Label issueLbl = new Label(issueDiv.write(), ContentMode.HTML); rowComp.with(issueLbl); return rowComp; }
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);/* w w w . j a v a 2 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"); 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.ProjectListNoItemView.java
License:Open Source License
public ProjectListNoItemView() { MVerticalLayout layout = new MVerticalLayout(); layout.addStyleName("case-noitem"); layout.setDefaultComponentAlignment(Alignment.TOP_CENTER); Label image = new Label(viewIcon().getHtml(), ContentMode.HTML); image.setSizeUndefined();/*ww w. ja v a2 s .c o m*/ layout.with(image).withAlign(image, Alignment.TOP_CENTER); Label title = new Label(viewTitle()); title.addStyleName("h2"); title.setSizeUndefined(); layout.with(title).withAlign(title, Alignment.TOP_CENTER); Label body = new Label(viewHint()); body.setWidthUndefined(); layout.addComponent(body); Button createBugBtn = new Button(actionMessage(), actionListener()); createBugBtn.setEnabled(hasPermission()); MHorizontalLayout links = new MHorizontalLayout(); links.addComponent(createBugBtn); createBugBtn.addStyleName(UIConstants.THEME_GREEN_LINK); layout.addComponent(links); this.addComponent(layout); this.setComponentAlignment(layout, Alignment.TOP_CENTER); }
From source file:com.esofthead.mycollab.module.project.ui.components.ProjectMemberBlock.java
License:Open Source License
public ProjectMemberBlock(String username, String userAvatarId, String displayName) { withMargin(false).withWidth("80px"); MButton button = new MButton(UserAvatarControlFactory.createAvatarResource(userAvatarId, 48)) .withStyleName("link"); String uid = UUID.randomUUID().toString(); DivLessFormatter div = new DivLessFormatter(); A userLink = new A() .setId("tag" + uid).setHref(ProjectLinkBuilder .generateProjectMemberFullLink(CurrentProjectVariables.getProjectId(), username)) .appendText(displayName);//from ww w. j a v a2s. c o m userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsDunction(uid, username)); userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid)); div.appendChild(userLink, DivLessFormatter.EMPTY_SPACE(), TooltipHelper.buildDivTooltipEnable(uid)); Label userLbl = new Label(div.write(), ContentMode.HTML); with(button, userLbl); }
From source file:com.esofthead.mycollab.module.project.ui.components.ProjectTaskRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(AbstractBeanPagedList host, ProjectGenericTask genericTask, int rowIndex) { MHorizontalLayout rowComp = new MHorizontalLayout().withStyleName("list-row").withWidth("100%"); rowComp.setDefaultComponentAlignment(Alignment.TOP_LEFT); Div issueDiv = new Div(); String uid = UUID.randomUUID().toString(); A taskLink = new A().setId("tag" + uid); taskLink.setAttribute("onmouseover", TooltipHelper.projectHoverJsFunction(uid, genericTask.getType(), genericTask.getTypeId() + "")); taskLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid)); if (ProjectTypeConstants.BUG.equals(genericTask.getType()) || ProjectTypeConstants.TASK.equals(genericTask.getType())) { taskLink.appendText(String.format("[#%d] - %s", genericTask.getExtraTypeId(), genericTask.getName())); taskLink.setHref(ProjectLinkBuilder.generateProjectItemLink(genericTask.getProjectShortName(), genericTask.getProjectId(), genericTask.getType(), genericTask.getExtraTypeId() + "")); } else {/* w w w .j a va 2 s. c o m*/ taskLink.appendText(genericTask.getName()); taskLink.setHref(ProjectLinkBuilder.generateProjectItemLink(genericTask.getProjectShortName(), genericTask.getProjectId(), genericTask.getType(), genericTask.getTypeId() + "")); } issueDiv.appendChild(taskLink); if (genericTask.isClosed()) { taskLink.setCSSClass("completed"); } else if (genericTask.isOverdue()) { taskLink.setCSSClass("overdue"); issueDiv.appendChild( new Span().appendText(" - Due in " + AppContext.formatDuration(genericTask.getDueDate())) .setCSSClass(UIConstants.LABEL_META_INFO)); } issueDiv.appendChild(TooltipHelper.buildDivTooltipEnable(uid)); Label issueLbl = new Label(issueDiv.write(), ContentMode.HTML); String avatarLink = StorageFactory.getInstance().getAvatarPath(genericTask.getAssignUserAvatarId(), 16); Img img = new Img(genericTask.getAssignUserFullName(), avatarLink) .setTitle(genericTask.getAssignUserFullName()); MHorizontalLayout iconsLayout = new MHorizontalLayout().with( new ELabel(ProjectAssetsManager.getAsset(genericTask.getType()).getHtml(), ContentMode.HTML), new ELabel(img.write(), ContentMode.HTML)); MCssLayout issueWrapper = new MCssLayout(issueLbl); rowComp.with(iconsLayout, issueWrapper).expand(issueWrapper); return rowComp; }