Example usage for com.vaadin.ui Label setStyleName

List of usage examples for com.vaadin.ui Label setStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Label setStyleName.

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:com.m4gik.views.component.LicenseScreen.java

/**
 * Method adds Text to the layout.//from  w  w  w.  j  av  a2 s . c o m
 * 
 * @param texts
 *            The layout to add texts.
 * @param string
 *            The text to add to the layout.
 */
private void addText(HorizontalLayout texts, String string, String style) {
    addSpacer(texts);

    Label text = new Label(string, Label.CONTENT_XHTML);

    if (style != null) {
        text.setStyleName(style);
    }

    texts.addComponent(text);
    texts.setExpandRatio(text, 1);
}

From source file:com.morevaadin.vaadin7.sass.SassUI.java

License:Apache License

@Override
protected void init(WrappedRequest request) {

    Button button = new Button("Do nothing");

    Label label = new Label("Rounded borders");

    label.setStyleName("rounded-borders");

    addComponent(button);/*from  w  w w .  j a  va  2s. com*/
    addComponent(label);
}

From source file:com.mycollab.mobile.module.project.view.message.MessageAttachmentField.java

License:Open Source License

@Override
protected void constructUI() {
    content = new VerticalLayout();
    content.setStyleName("attachment-field");

    rowWrap = new VerticalLayout();
    rowWrap.setWidth("100%");
    rowWrap.setStyleName("attachment-row-wrap");

    HorizontalLayout compHeader = new HorizontalLayout();
    compHeader.setWidth("100%");
    compHeader.setStyleName("attachment-field-header");

    Label headerLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_ATTACHMENTS));
    headerLbl.setStyleName("field-caption");

    compHeader.addComponent(headerLbl);//from ww w . j  ava2s .c  o m
    compHeader.setExpandRatio(headerLbl, 1.0f);
    compHeader.addComponent(attachmentBtn);

    content.addComponent(compHeader);
    content.addComponent(rowWrap);
}

From source file:com.mycollab.mobile.module.project.view.message.MessageReadViewImpl.java

License:Open Source License

private void displayItem() {
    mainLayout.removeAllComponents();// www  . ja v  a2 s  . c o  m
    MHorizontalLayout messageBlock = new MHorizontalLayout().withSpacing(false).withFullWidth()
            .withStyleName("message-block");
    Image userAvatarImg = UserAvatarControlFactory
            .createUserAvatarEmbeddedComponent(bean.getPostedUserAvatarId(), 32);
    userAvatarImg.addStyleName(UIConstants.CIRCLE_BOX);
    messageBlock.addComponent(userAvatarImg);

    CssLayout rightCol = new CssLayout();
    rightCol.setWidth("100%");

    MHorizontalLayout metadataRow = new MHorizontalLayout().withFullWidth();

    ELabel userNameLbl = new ELabel(bean.getFullPostedUserName()).withStyleName(UIConstants.META_INFO);
    userNameLbl.addStyleName(UIConstants.TEXT_ELLIPSIS);
    CssLayout userNameWrap = new CssLayout(userNameLbl);

    ELabel messageTimePost = new ELabel().prettyDateTime(bean.getPosteddate())
            .withStyleName(UIConstants.META_INFO).withWidthUndefined();
    metadataRow.with(userNameWrap, messageTimePost).withAlign(messageTimePost, Alignment.TOP_RIGHT)
            .expand(userNameWrap);

    rightCol.addComponent(metadataRow);

    CssLayout titleRow = new CssLayout();
    titleRow.setWidth("100%");
    titleRow.setStyleName("title-row");
    Label messageTitle = new Label(bean.getTitle());
    messageTitle.setStyleName("message-title");
    titleRow.addComponent(messageTitle);
    rightCol.addComponent(titleRow);

    Label messageContent = new Label(StringUtils.trimHtmlTags(bean.getMessage()));
    rightCol.addComponent(messageContent);

    ResourceService attachmentService = AppContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = attachmentService.getContents(AttachmentUtils.getProjectEntityAttachmentPath(
            MyCollabUI.getAccountId(), bean.getProjectid(), ProjectTypeConstants.MESSAGE, "" + bean.getId()));
    if (CollectionUtils.isNotEmpty(attachments)) {
        CssLayout attachmentPanel = new CssLayout();
        attachmentPanel.setStyleName("attachment-panel");
        attachmentPanel.setWidth("100%");

        for (Content attachment : attachments) {
            attachmentPanel.addComponent(MobileAttachmentUtils.renderAttachmentRow(attachment));
        }
        rightCol.addComponent(attachmentPanel);
    }

    messageBlock.with(rightCol).expand(rightCol);
    mainLayout.addComponent(messageBlock);

    Label commentTitleLbl = new Label();
    Component section = FormSectionBuilder.build(FontAwesome.COMMENT, commentTitleLbl);
    MessageCommentListDisplay commentDisplay = new MessageCommentListDisplay(ProjectTypeConstants.MESSAGE,
            bean.getId() + "", bean.getProjectid(), true);
    int numComments = commentDisplay.getNumComments();
    commentTitleLbl.setValue(UserUIContext.getMessage(GenericI18Enum.OPT_COMMENTS_VALUE, numComments));

    mainLayout.addComponent(section);
    mainLayout.addComponent(commentDisplay);
    this.setToolbar(commentDisplay.getCommentBox());
}

From source file:com.mycollab.mobile.shell.view.MainView.java

License:Open Source License

public MainView() {
    super();/*from   ww  w.j a va 2  s.  c  o  m*/
    this.setSizeFull();

    MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth();
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png"));
    contentLayout.addComponent(mainLogo);

    Label introText = new Label(
            "MyCollab helps you do all your office jobs on the computers, phones and tablets you use");
    introText.setStyleName("intro-text");
    contentLayout.addComponent(introText);

    CssLayout welcomeTextWrapper = new CssLayout();
    welcomeTextWrapper.setStyleName("welcometext-wrapper");
    welcomeTextWrapper.setWidth("100%");
    welcomeTextWrapper.setHeight("15px");
    contentLayout.addComponent(welcomeTextWrapper);

    Button crmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM),
            clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)));
    crmButton.addStyleName(MobileUIConstants.BUTTON_ACTION);
    crmButton.setWidth("100%");

    contentLayout.addComponent(crmButton);

    Button pmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT),
            clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null)));
    pmButton.setWidth("100%");
    pmButton.addStyleName(MobileUIConstants.BUTTON_ACTION);
    contentLayout.addComponent(pmButton);

    this.addComponent(contentLayout);
}

From source file:com.mycollab.module.crm.ui.components.DateInfoComp.java

License:Open Source License

public void displayEntryDateTime(ValuedBean bean) {
    this.removeAllComponents();
    this.withMargin(false);
    Label dateInfoHeader = new Label(
            FontAwesome.CALENDAR.getHtml() + " " + UserUIContext.getMessage(CrmCommonI18nEnum.SUB_INFO_DATES),
            ContentMode.HTML);/*  www .j  a va2 s . c  om*/
    dateInfoHeader.setStyleName("info-hdr");
    this.addComponent(dateInfoHeader);

    MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true))
            .withFullWidth();
    try {
        Date createdDate = (Date) PropertyUtils.getProperty(bean, "createdtime");
        Label createdDateLbl = new Label(UserUIContext.getMessage(CrmCommonI18nEnum.ITEM_CREATED_DATE,
                UserUIContext.formatPrettyTime(createdDate)));
        createdDateLbl.setDescription(UserUIContext.formatDateTime(createdDate));

        Date updatedDate = (Date) PropertyUtils.getProperty(bean, "lastupdatedtime");
        Label updatedDateLbl = new Label(UserUIContext.getMessage(CrmCommonI18nEnum.ITEM_UPDATED_DATE,
                UserUIContext.formatPrettyTime(updatedDate)));
        updatedDateLbl.setDescription(UserUIContext.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.mycollab.module.crm.ui.components.PeopleInfoComp.java

License:Open Source License

public void displayEntryPeople(ValuedBean bean) {
    this.removeAllComponents();
    this.withMargin(false);

    Label peopleInfoHeader = new Label(
            FontAwesome.USER.getHtml() + " " + UserUIContext.getMessage(CrmCommonI18nEnum.SUB_INFO_PEOPLE),
            ContentMode.HTML);/*from  w w w  . j  a v a2 s. c o 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(UserUIContext.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(UserUIContext.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.mycollab.module.crm.view.account.AccountCaseListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    MHorizontalLayout controlsBtnWrap = new MHorizontalLayout().withFullWidth();

    MHorizontalLayout notesWrap = new MHorizontalLayout().withFullWidth();
    Label noteLbl = new Label(UserUIContext.getMessage(GenericI18Enum.OPT_NOTE));
    noteLbl.setSizeUndefined();//from ww w . j ava2 s . c  o m
    noteLbl.setStyleName("list-note-lbl");
    notesWrap.addComponent(noteLbl);

    CssLayout noteBlock = new CssLayout();
    noteBlock.setWidth("100%");
    noteBlock.setStyleName("list-note-block");
    for (CaseStatus status : CrmDataTypeFactory.getCasesStatusList()) {
        ELabel note = new ELabel(UserUIContext.getMessage(status))
                .withStyleName("note-label", colorsMap.get(status.name())).withWidthUndefined();
        noteBlock.addComponent(note);
    }
    notesWrap.with(noteBlock).expand(noteBlock);
    controlsBtnWrap.addComponent(notesWrap);

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_CASE)) {
        MButton createBtn = new MButton(UserUIContext.getMessage(CaseI18nEnum.NEW),
                clickEvent -> fireNewRelatedItem("")).withIcon(FontAwesome.PLUS)
                        .withStyleName(WebThemes.BUTTON_ACTION);
        controlsBtnWrap.with(createBtn).withAlign(createBtn, Alignment.TOP_RIGHT);
    }

    return controlsBtnWrap;
}

From source file:com.mycollab.module.project.ui.components.DateInfoComp.java

License:Open Source License

public void displayEntryDateTime(ValuedBean bean) {
    this.removeAllComponents();
    this.withMargin(false);
    Label dateInfoHeader = ELabel.html(FontAwesome.CALENDAR.getHtml() + " "
            + UserUIContext.getMessage(ProjectCommonI18nEnum.SUB_INFO_DATES));
    dateInfoHeader.setStyleName("info-hdr");
    this.addComponent(dateInfoHeader);

    MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true))
            .withFullWidth();//from  w ww  .  j a  v a 2  s .  co m
    try {
        Date createdDate = (Date) PropertyUtils.getProperty(bean, "createdtime");
        ELabel createdDateLbl = new ELabel(UserUIContext.getMessage(ProjectCommonI18nEnum.ITEM_CREATED_DATE,
                UserUIContext.formatPrettyTime(createdDate)))
                        .withDescription(UserUIContext.formatDateTime(createdDate));

        layout.addComponent(createdDateLbl);

        Date updatedDate = (Date) PropertyUtils.getProperty(bean, "lastupdatedtime");
        ELabel updatedDateLbl = new ELabel(UserUIContext.getMessage(ProjectCommonI18nEnum.ITEM_UPDATED_DATE,
                UserUIContext.formatPrettyTime(updatedDate)))
                        .withDescription(UserUIContext.formatDateTime(updatedDate));
        layout.addComponent(updatedDateLbl);

        this.addComponent(layout);
    } catch (Exception e) {
        LOG.error("Get date is failed {}", BeanUtility.printBeanObj(bean));
    }
}

From source file:com.mycollab.module.project.view.user.ProjectActivityStreamPagedList.java

License:Open Source License

protected void feedBlocksPut(Date currentDate, Date nextDate, ComponentContainer currentBlock) {
    MHorizontalLayout blockWrapper = new MHorizontalLayout().withSpacing(false).withFullWidth()
            .withStyleName("feed-block-wrap");

    blockWrapper.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    Calendar cal1 = Calendar.getInstance();
    cal1.setTime(currentDate);//  w  w w .  ja  v  a 2 s  .c  o m

    Calendar cal2 = Calendar.getInstance();
    cal2.setTime(nextDate);

    if (cal1.get(Calendar.YEAR) != cal2.get(Calendar.YEAR)) {
        int currentYear = cal2.get(Calendar.YEAR);
        Label yearLbl = new Label("<div>" + String.valueOf(currentYear) + "</div>", ContentMode.HTML);
        yearLbl.setStyleName("year-lbl");
        yearLbl.setWidthUndefined();
        listContainer.addComponent(yearLbl);
    } else {
        blockWrapper.setMargin(new MarginInfo(true, false, false, false));
    }
    Label dateLbl = new Label(UserUIContext.formatShortDate(nextDate));
    dateLbl.setStyleName("date-lbl");
    dateLbl.setWidthUndefined();
    blockWrapper.with(dateLbl, currentBlock).expand(currentBlock);

    this.listContainer.addComponent(blockWrapper);
}