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.esofthead.mycollab.module.project.ui.components.AbstractPreviewItemComp2.java

License:Open Source License

protected ComponentContainer constructHeader(String headerText) {
    Label headerLbl = new Label(headerText);
    headerLbl.setSizeUndefined();/* w  w  w. jav  a  2  s .  c  om*/
    header = new HorizontalLayout();
    headerLbl.setStyleName("hdr-text");

    if (titleIcon != null)
        UiUtils.addComponent(header, titleIcon, Alignment.MIDDLE_LEFT);

    UiUtils.addComponent(header, headerLbl, Alignment.MIDDLE_LEFT);
    header.setExpandRatio(headerLbl, 1.0f);

    header.setStyleName("hdr-view");
    header.setWidth("100%");
    header.setSpacing(true);
    header.setMargin(true);

    return header;
}

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

License:Open Source License

@Override
public Component generateRow(final SimpleComment comment, int rowIndex) {
    final MHorizontalLayout layout = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, false, true, false)).withWidth("100%").withStyleName("message");

    ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(),
            comment.getOwnerAvatarId(), comment.getOwnerFullName());
    layout.addComponent(memberBlock);//  ww  w .  j a v a  2  s  . c  o m

    CssLayout rowLayout = new CssLayout();
    rowLayout.setStyleName("message-container");
    rowLayout.setWidth("100%");

    MHorizontalLayout messageHeader = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, true, false, true)).withWidth("100%")
            .withStyleName("message-header");
    messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    ELabel timePostLbl = new ELabel(AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT,
            comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())),
            ContentMode.HTML).withDescription(AppContext.formatDateTime(comment.getCreatedtime()));

    timePostLbl.setSizeUndefined();
    timePostLbl.setStyleName("time-post");
    messageHeader.with(timePostLbl).expand(timePostLbl);

    // Message delete button
    Button msgDeleteBtn = new Button();
    msgDeleteBtn.setIcon(FontAwesome.TRASH_O);
    msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY);
    messageHeader.addComponent(msgDeleteBtn);

    if (hasDeletePermission(comment)) {
        msgDeleteBtn.setVisible(true);
        msgDeleteBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                ConfirmDialogExt.show(UI.getCurrent(),
                        AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                SiteConfiguration.getSiteName()),
                        AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                        AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                        AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                            private static final long serialVersionUID = 1L;

                            @Override
                            public void onClose(ConfirmDialog dialog) {
                                if (dialog.isConfirmed()) {
                                    CommentService commentService = ApplicationContextUtil
                                            .getSpringBean(CommentService.class);
                                    commentService.removeWithSession(comment.getId(), AppContext.getUsername(),
                                            AppContext.getAccountId());
                                    CommentRowDisplayHandler.this.owner.removeRow(layout);
                                }
                            }
                        });
            }
        });
    } else {
        msgDeleteBtn.setVisible(false);
    }

    rowLayout.addComponent(messageHeader);

    Label messageContent = new SafeHtmlLabel(comment.getComment());
    messageContent.setStyleName("message-body");
    rowLayout.addComponent(messageContent);

    List<Content> attachments = comment.getAttachments();
    if (!CollectionUtils.isEmpty(attachments)) {
        MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withWidth("100%")
                .withStyleName("message-footer");
        AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments);
        attachmentDisplay.setWidth("100%");
        messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT);
        rowLayout.addComponent(messageFooter);
    }

    layout.with(rowLayout).expand(rowLayout);
    return layout;
}

From source file:com.esofthead.mycollab.module.project.ui.components.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 ww .j  av a  2  s . c  om
    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.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 ww .j  a  v a  2 s  . co  m
    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.TimeLogComp.java

License:Open Source License

public void displayTime(final V bean) {
    this.removeAllComponents();
    this.withSpacing(true).withMargin(new MarginInfo(false, false, false, true));

    HorizontalLayout header = new MHorizontalLayout().withSpacing(true).withMargin(false);

    Label dateInfoHeader = new Label(
            FontAwesome.CLOCK_O.getHtml() + " " + AppContext.getMessage(TimeTrackingI18nEnum.SUB_INFO_TIME),
            ContentMode.HTML);/*from   w  w w  . ja  v a  2 s . c om*/
    dateInfoHeader.setStyleName("info-hdr");
    header.addComponent(dateInfoHeader);

    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) {
                        showEditTimeWindow(bean);

                    }
                });
        editBtn.setStyleName("link");
        editBtn.addStyleName("info-hdr");
        header.addComponent(editBtn);
    }

    this.addComponent(header);

    MVerticalLayout layout = new MVerticalLayout().withWidth("100%").withSpacing(true)
            .withMargin(new MarginInfo(false, false, false, true));

    double billableHours = getTotalBillableHours(bean);
    double nonBillableHours = getTotalNonBillableHours(bean);
    double remainHours = getRemainedHours(bean);
    layout.addComponent(new Label(
            String.format(AppContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS), billableHours)));
    layout.addComponent(new Label(String
            .format(AppContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS), nonBillableHours)));
    layout.addComponent(new Label(
            String.format(AppContext.getMessage(TimeTrackingI18nEnum.OPT_REMAIN_HOURS), remainHours)));
    this.addComponent(layout);
}

From source file:com.esofthead.mycollab.module.project.view.assignments.GanttChartViewImpl.java

License:Open Source License

private void constructUI() {
    MHorizontalLayout header = new MHorizontalLayout().withMargin(new MarginInfo(false, false, true, false))
            .withStyleName("hdr-view").withWidth("100%");
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    Label headerText = new Label(FontAwesome.BAR_CHART_O.getHtml() + " Gantt chart", ContentMode.HTML);
    headerText.setStyleName(ValoTheme.LABEL_H2);
    headerText.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    CssLayout headerWrapper = new CssLayout();
    headerWrapper.addComponent(headerText);

    MHorizontalLayout resWrapper = new MHorizontalLayout();
    Label resLbl = new Label("Resolution: ");
    final ComboBox resValue = new ValueComboBox(false, "Day", "Week");
    resValue.addValueChangeListener(new Property.ValueChangeListener() {
        @Override//w  w w  .ja  v a2 s.c  o m
        public void valueChange(Property.ValueChangeEvent event) {
            String val = (String) resValue.getValue();
            if ("Day".equals(val)) {
                gantt.setResolution(Resolution.Day);
            } else if ("Week".equals(val)) {
                gantt.setResolution(Resolution.Week);
            }
        }
    });
    resWrapper.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    resWrapper.with(resLbl, resValue);

    header.with(headerWrapper, resWrapper).withAlign(headerWrapper, Alignment.MIDDLE_LEFT)
            .expand(headerWrapper);

    mainLayout = new MHorizontalLayout().withSpacing(false);
    mainLayout.addStyleName("gantt_container");
    mainLayout.setSizeFull();
    this.with(header, mainLayout);
}

From source file:com.esofthead.mycollab.module.project.view.bug.BugSearchPanel.java

License:Open Source License

private ComponentContainer constructHeader() {
    Label headerText = new ProjectViewHeader(ProjectTypeConstants.BUG,
            AppContext.getMessage(BugI18nEnum.VIEW_LIST_TITLE));

    final Button createBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_BUG),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//from  w ww  . j  a v a 2  s .com
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new BugEvent.GotoAdd(this, null));
                }
            });
    createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));

    headerText.setStyleName(UIConstants.HEADER_TEXT);

    rightComponent = new MHorizontalLayout();

    MHorizontalLayout header = new MHorizontalLayout().withStyleName(UIConstants.HEADER_VIEW).withWidth("100%")
            .withSpacing(true).withMargin(new MarginInfo(true, false, true, false));

    header.with(headerText, createBtn, rightComponent).withAlign(headerText, Alignment.MIDDLE_LEFT)
            .withAlign(createBtn, Alignment.MIDDLE_RIGHT).withAlign(rightComponent, Alignment.MIDDLE_RIGHT)
            .expand(headerText);

    return header;
}

From source file:com.esofthead.mycollab.module.project.view.bug.components.BugRowDisplayHandler.java

License:Open Source License

@Override
public Component generateRow(SimpleBug bug, int rowIndex) {
    MVerticalLayout rowContent = new MVerticalLayout().withSpacing(false).withWidth("100%");
    final LabelLink defectLink = new LabelLink(
            "[" + CurrentProjectVariables.getProject().getShortname() + "-" + bug.getBugkey() + "]: "
                    + bug.getSummary(),//from   w  w  w  .  jav a2 s.com
            ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName()));
    defectLink.setWidth("100%");
    defectLink.setIconLink(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG));
    defectLink.setDescription(ProjectTooltipGenerator.generateToolTipBug(AppContext.getUserLocale(), bug,
            AppContext.getSiteUrl(), AppContext.getTimezone()));

    if (bug.isCompleted()) {
        defectLink.addStyleName(UIConstants.LINK_COMPLETED);
    } else if (bug.isOverdue()) {
        defectLink.addStyleName(UIConstants.LINK_OVERDUE);
    }
    rowContent.addComponent(defectLink);

    final LabelHTMLDisplayWidget descInfo = new LabelHTMLDisplayWidget(bug.getDescription());
    descInfo.setWidth("100%");
    rowContent.addComponent(descInfo);

    final Label dateInfo = new Label(AppContext.getMessage(DayI18nEnum.LAST_UPDATED_ON,
            AppContext.formatPrettyTime(bug.getLastupdatedtime())));
    dateInfo.setStyleName(UIConstants.WIDGET_ROW_METADATA);
    rowContent.addComponent(dateInfo);

    final HorizontalLayout hLayoutAssigneeInfo = new HorizontalLayout();
    hLayoutAssigneeInfo.setSpacing(true);
    final Label assignee = new Label(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE) + ": ");
    assignee.setStyleName(UIConstants.WIDGET_ROW_METADATA);
    hLayoutAssigneeInfo.addComponent(assignee);
    hLayoutAssigneeInfo.setComponentAlignment(assignee, Alignment.MIDDLE_CENTER);

    final ProjectUserLink userLink = new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(),
            bug.getAssignuserFullName(), false, true);
    hLayoutAssigneeInfo.addComponent(userLink);
    hLayoutAssigneeInfo.setComponentAlignment(userLink, Alignment.MIDDLE_CENTER);
    rowContent.addComponent(hLayoutAssigneeInfo);

    rowContent.setStyleName(UIConstants.WIDGET_ROW);
    if ((rowIndex + 1) % 2 != 0) {
        rowContent.addStyleName("odd");
    }
    return rowContent;
}

From source file:com.esofthead.mycollab.module.project.view.bug.ComponentSearchPanel.java

License:Open Source License

private HorizontalLayout createSearchTopPanel() {
    final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%").withSpacing(true)
            .withStyleName(UIConstants.HEADER_VIEW).withMargin(new MarginInfo(true, false, true, false));

    final Label componenttitle = new ProjectViewHeader(ProjectTypeConstants.BUG_COMPONENT,
            AppContext.getMessage(ComponentI18nEnum.VIEW_LIST_TITLE));
    componenttitle.setStyleName(UIConstants.HEADER_TEXT);

    layout.with(componenttitle).withAlign(componenttitle, Alignment.MIDDLE_LEFT).expand(componenttitle);

    final Button createBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_COMPONENT),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override/*  w w w  .  ja v  a  2  s.  c  o m*/
                public void buttonClick(final Button.ClickEvent event) {
                    EventBusFactory.getInstance().post(new BugComponentEvent.GotoAdd(this, null));
                }
            });
    createBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS));
    createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setIcon(FontAwesome.PLUS);

    layout.with(createBtn).withAlign(createBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.project.view.bug.VersionSearchPanel.java

License:Open Source License

private HorizontalLayout createSearchTopPanel() {
    final MHorizontalLayout layout = new MHorizontalLayout().withStyleName(UIConstants.HEADER_VIEW)
            .withWidth("100%").withSpacing(true).withMargin(new MarginInfo(true, false, true, false));

    final Label versionTitle = new ProjectViewHeader(ProjectTypeConstants.BUG_VERSION,
            AppContext.getMessage(VersionI18nEnum.VIEW_LIST_TITLE));
    versionTitle.setStyleName(UIConstants.HEADER_TEXT);
    layout.with(versionTitle).withAlign(versionTitle, Alignment.MIDDLE_LEFT).expand(versionTitle);

    final Button createBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_VERSION),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//from   www.  j  a  v a  2 s  .  c  o m
                public void buttonClick(final Button.ClickEvent event) {
                    EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null));
                }
            });
    createBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS));
    createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setIcon(FontAwesome.PLUS);

    layout.with(createBtn).withAlign(createBtn, Alignment.MIDDLE_LEFT);

    return layout;
}