Java Code Examples for org.vaadin.viritin.layouts.MHorizontalLayout#addStyleName()

The following examples show how to use org.vaadin.viritin.layouts.MHorizontalLayout#addStyleName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TicketRowDisplayHandler.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Component generateRow(IBeanList<ProjectTicket> host, ProjectTicket ticket, int rowIndex) {
    MHorizontalLayout rowComp = new MHorizontalLayout().withStyleName("list-row").withFullWidth();
    rowComp.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    Div issueDiv = new Div().appendText(ProjectAssetsManager.getAsset(ticket.getType()).getHtml());

    String status = "";
    if (ticket.isBug()) {
        status = UserUIContext.getMessage(StatusI18nEnum.class, ticket.getStatus());
        rowComp.addStyleName("bug");
    } else if (ticket.isMilestone()) {
        status = UserUIContext.getMessage(MilestoneStatus.class, ticket.getStatus());
        rowComp.addStyleName("milestone");
    } else if (ticket.isRisk()) {
        status = UserUIContext.getMessage(StatusI18nEnum.class, ticket.getStatus());
        rowComp.addStyleName("risk");
    } else if (ticket.isTask()) {
        status = UserUIContext.getMessage(StatusI18nEnum.class, ticket.getStatus());
        rowComp.addStyleName("task");
    }
    issueDiv.appendChild(new Span().appendText(status).setCSSClass(WebThemes.BLOCK));

    String avatarLink = StorageUtils.getAvatarPath(ticket.getAssignUserAvatarId(), 16);
    Img img = new Img(ticket.getAssignUserFullName(), avatarLink).setCSSClass(WebThemes.CIRCLE_BOX)
            .setTitle(ticket.getAssignUserFullName());
    issueDiv.appendChild(img, DivLessFormatter.EMPTY_SPACE);

    A ticketLink = new A().setId("tag" + TooltipHelper.TOOLTIP_ID);
    ticketLink.setAttribute("onmouseover", TooltipHelper.projectHoverJsFunction(ticket.getType(), ticket.getTypeId() + ""));
    ticketLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());

    if (displayPrjShortname) {
        ticketLink.appendText(String.format("[%s] - %s", ticket.getProjectShortName(), ticket.getName()));
    } else {
        ticketLink.appendText(ticket.getName());
    }
    ticketLink.setHref(ProjectLinkGenerator.generateProjectItemLink(ticket.getProjectShortName(),
            ticket.getProjectId(), ticket.getType(), ticket.getExtraTypeId() + ""));

    issueDiv.appendChild(ticketLink);
    if (ticket.isClosed()) {
        ticketLink.setCSSClass("completed");
    } else if (ticket.isOverdue()) {
        ticketLink.setCSSClass("overdue");
        issueDiv.appendChild(new Span().appendText(" - " + UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_DUE_IN,
                UserUIContext.formatDuration(ticket.getDueDate()))).setCSSClass(WebThemes.META_INFO));
    }

    rowComp.with(ELabel.html(issueDiv.write()).withFullWidth());
    return rowComp;
}
 
Example 2
Source File: MessageListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Component generateRow(IBeanList<SimpleMessage> host, final SimpleMessage message, int rowIndex) {
    final MHorizontalLayout messageLayout = new MHorizontalLayout().withMargin(new MarginInfo(true, false,
            true, false)).withFullWidth();
    if (Boolean.TRUE.equals(message.getIsstick())) {
        messageLayout.addStyleName("important-message");
    }

    ProjectMemberBlock userBlock = new ProjectMemberBlock(message.getCreateduser(), message.getPostedUserAvatarId(),
            message.getFullPostedUserName());
    messageLayout.addComponent(userBlock);

    MVerticalLayout rowLayout = new MVerticalLayout().withFullWidth().withStyleName(WebThemes.MESSAGE_CONTAINER);

    A messageLink = new A(ProjectLinkGenerator.generateMessagePreviewLink(message.getProjectid(), message.getId()),
            new Text(message.getTitle()));

    MHorizontalLayout messageHeader = new MHorizontalLayout().withMargin(false);
    messageHeader.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    CssLayout leftHeader = new CssLayout();
    leftHeader.addComponent(ELabel.h3(messageLink.write()));
    ELabel timePostLbl = new ELabel().prettyDateTime(message.getCreatedtime()).withStyleName(WebThemes.META_INFO);

    MButton deleteBtn = new MButton("", clickEvent -> ConfirmDialogExt.show(UI.getCurrent(),
            UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppUI.getSiteName()),
            UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
            UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
            UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
            confirmDialog -> {
                if (confirmDialog.isConfirmed()) {
                    MessageService messageService = AppContextUtil.getSpringBean(MessageService.class);
                    messageService.removeWithSession(message, UserUIContext.getUsername(), AppUI.getAccountId());
                    messageList.setSearchCriteria(searchCriteria);
                }
            })).withIcon(VaadinIcons.TRASH).withStyleName(WebThemes.BUTTON_ICON_ONLY)
            .withVisible(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MESSAGES));

    MHorizontalLayout rightHeader = new MHorizontalLayout(timePostLbl, deleteBtn).alignAll(Alignment.MIDDLE_RIGHT);
    messageHeader.with(leftHeader, rightHeader).expand(leftHeader);

    rowLayout.addComponent(messageHeader);

    SafeHtmlLabel messageContent = new SafeHtmlLabel(message.getMessage());
    rowLayout.addComponent(messageContent);

    MHorizontalLayout notification = new MHorizontalLayout().withStyleName("notification").withUndefinedSize();
    if (message.getCommentsCount() > 0) {
        MHorizontalLayout commentNotification = new MHorizontalLayout();
        Label commentCountLbl = ELabel.html(String.format("%s %s", Integer.toString(message.getCommentsCount()), VaadinIcons.COMMENTS.getHtml()));
        commentCountLbl.setSizeUndefined();
        commentNotification.addComponent(commentCountLbl);
        notification.addComponent(commentNotification);
    }
    ResourceService attachmentService = AppContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = attachmentService.getContents(AttachmentUtils
            .getProjectEntityAttachmentPath(AppUI.getAccountId(),
                    message.getProjectid(), ProjectTypeConstants.MESSAGE, "" + message.getId()));
    if (CollectionUtils.isNotEmpty(attachments)) {
        HorizontalLayout attachmentNotification = new HorizontalLayout();
        Label attachmentCountLbl = new Label(Integer.toString(attachments.size()));
        attachmentCountLbl.setSizeUndefined();
        attachmentNotification.addComponent(attachmentCountLbl);
        Button attachmentIcon = new Button(VaadinIcons.PAPERCLIP);
        attachmentIcon.addStyleName(WebThemes.BUTTON_ICON_ONLY);
        attachmentNotification.addComponent(attachmentIcon);
        notification.addComponent(attachmentNotification);
    }

    if (notification.getComponentCount() > 0) {
        MVerticalLayout messageFooter = new MVerticalLayout(notification).withMargin(false).withSpacing(false).withFullWidth().withAlign(notification, Alignment.MIDDLE_RIGHT);
        rowLayout.addComponent(messageFooter);
    }

    messageLayout.with(rowLayout).expand(rowLayout);
    return messageLayout;
}
 
Example 3
Source File: ProjectPagedList.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Component generateRow(IBeanList<SimpleProject> host, SimpleProject project, int rowIndex) {
    MHorizontalLayout layout = new MHorizontalLayout().withMargin(false).withFullWidth().withStyleName(WebThemes.BORDER_LIST_ROW);
    layout.addComponent(ProjectAssetsUtil.projectLogoComp(project.getShortname(), project.getId(), project.getAvatarid(), 64));
    if (project.isArchived()) {
        layout.addStyleName("project-archived");
    }
    MVerticalLayout mainLayout = new MVerticalLayout().withMargin(false);

    A projectDiv = new A(ProjectLinkGenerator.generateProjectLink(project.getId())).appendText(project.getName());
    ELabel projectLbl = ELabel.h3(projectDiv.write()).withStyleName(WebThemes.TEXT_ELLIPSIS).withFullWidth();
    projectLbl.setDescription(ProjectTooltipGenerator.generateToolTipProject(UserUIContext.getUserLocale(),
            AppUI.getDateFormat(), project, AppUI.getSiteUrl(), UserUIContext.getUserTimeZone()), ContentMode.HTML);

    mainLayout.addComponent(projectLbl);

    MHorizontalLayout metaInfo = new MHorizontalLayout().withFullWidth();
    metaInfo.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    Div activeMembersDiv = new Div().appendText(VaadinIcons.USERS.getHtml() + " " + project.getNumActiveMembers())
            .setTitle(UserUIContext.getMessage(ProjectMemberI18nEnum.OPT_ACTIVE_MEMBERS));
    Div createdTimeDiv = new Div().appendText(VaadinIcons.CLOCK.getHtml() + " " + UserUIContext
            .formatPrettyTime(project.getCreatedtime())).setTitle(UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME));
    Div billableHoursDiv = new Div().appendText(VaadinIcons.MONEY.getHtml() + " " + NumberUtils.roundDouble(2, project.getTotalBillableHours())).
            setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS));
    Div nonBillableHoursDiv = new Div().appendText(VaadinIcons.GIFT.getHtml() + " " + NumberUtils.roundDouble(2,
            project.getTotalNonBillableHours())).setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS));
    Div metaDiv = new Div().appendChild(activeMembersDiv, DivLessFormatter.EMPTY_SPACE, createdTimeDiv,
            DivLessFormatter.EMPTY_SPACE, billableHoursDiv, DivLessFormatter.EMPTY_SPACE,
            nonBillableHoursDiv, DivLessFormatter.EMPTY_SPACE);
    if (project.getMemlead() != null) {
        Div leadDiv = new Div().appendChild(new Img("", StorageUtils.getAvatarPath(project
                        .getLeadAvatarId(), 16)).setCSSClass(WebThemes.CIRCLE_BOX), DivLessFormatter.EMPTY_SPACE,
                new A(ProjectLinkGenerator.generateProjectMemberLink(project.getId(), project.getMemlead()))
                        .appendText(StringUtils.trim(project.getLeadFullName(), 30, true))).setTitle
                (UserUIContext.getMessage(ProjectI18nEnum.FORM_LEADER));
        metaDiv.appendChild(0, leadDiv);
        metaDiv.appendChild(1, DivLessFormatter.EMPTY_SPACE);
    }

    if (project.getClientid() != null) {
        Div accountDiv = new Div();
        if (project.getClientAvatarId() == null) {
            accountDiv.appendText(VaadinIcons.INSTITUTION.getHtml() + " ");
        } else {
            Img clientImg = new Img("", StorageUtils.getEntityLogoPath(AppUI.getAccountId(),
                    project.getClientAvatarId(), 16)).setCSSClass(WebThemes.CIRCLE_BOX);
            accountDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE);
        }

        accountDiv.appendChild(new A(ProjectLinkGenerator.generateClientPreviewLink(project.getClientid()))
                .appendText(StringUtils.trim(project.getClientName(), 30, true))).setCSSClass(WebThemes.BLOCK)
                .setTitle(project.getClientName());
        metaDiv.appendChild(0, accountDiv);
        metaDiv.appendChild(1, DivLessFormatter.EMPTY_SPACE);
    }
    metaDiv.setCSSClass(WebThemes.FLEX_DISPLAY);
    metaInfo.addComponent(ELabel.html(metaDiv.write()).withStyleName(WebThemes.META_INFO).withUndefinedWidth());

    mainLayout.addComponent(metaInfo);

    int openAssignments = project.getNumOpenBugs() + project.getNumOpenTasks() + project.getNumOpenRisks();
    int totalAssignments = project.getNumBugs() + project.getNumTasks() + project.getNumRisks();
    ELabel progressInfoLbl;
    if (totalAssignments > 0) {
        progressInfoLbl = new ELabel(UserUIContext.getMessage(ProjectI18nEnum.OPT_PROJECT_TICKET,
                (totalAssignments - openAssignments), totalAssignments, (totalAssignments - openAssignments)
                        * 100 / totalAssignments)).withStyleName(WebThemes.META_INFO);
    } else {
        progressInfoLbl = new ELabel(UserUIContext.getMessage(ProjectI18nEnum.OPT_NO_TICKET))
                .withStyleName(WebThemes.META_INFO);
    }
    mainLayout.addComponent(progressInfoLbl);
    layout.with(mainLayout).expand(mainLayout);
    return layout;
}
 
Example 4
Source File: ProjectMemberReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Component generateRow(IBeanList<ProjectTicket> host, ProjectTicket ticket, int rowIndex) {
    MHorizontalLayout rowComp = new MHorizontalLayout().withStyleName("list-row").withFullWidth();
    rowComp.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    Div issueDiv = new Div().appendText(ProjectAssetsManager.getAsset(ticket.getType()).getHtml());
    String status = "";
    if (ticket.isBug()) {
        status = UserUIContext.getMessage(StatusI18nEnum.class, ticket.getStatus());
        rowComp.addStyleName("bug");
    } else if (ticket.isMilestone()) {
        status = UserUIContext.getMessage(OptionI18nEnum.MilestoneStatus.class, ticket.getStatus());
        rowComp.addStyleName("milestone");
    } else if (ticket.isRisk()) {
        status = UserUIContext.getMessage(StatusI18nEnum.class, ticket.getStatus());
        rowComp.addStyleName("risk");
    } else if (ticket.isTask()) {
        status = UserUIContext.getMessage(StatusI18nEnum.class, ticket.getStatus());
        rowComp.addStyleName("task");
    }
    issueDiv.appendChild(new Span().appendText(status).setCSSClass(WebThemes.BLOCK));

    String avatarLink = StorageUtils.getAvatarPath(ticket.getAssignUserAvatarId(), 16);
    Img img = new Img(ticket.getAssignUserFullName(), avatarLink).setCSSClass(WebThemes.CIRCLE_BOX)
            .setTitle(ticket.getAssignUserFullName());
    issueDiv.appendChild(img, new Text(" "));

    A ticketLink = new A().setId("tag" + TooltipHelper.TOOLTIP_ID);
    ticketLink.setAttribute("onmouseover", TooltipHelper.projectHoverJsFunction(ticket.getType(), ticket.getTypeId() + ""));
    ticketLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());
    if (ProjectTypeConstants.BUG.equals(ticket.getType()) || ProjectTypeConstants.TASK.equals(ticket.getType())) {
        ticketLink.appendText(ticket.getName());
        ticketLink.setHref(ProjectLinkGenerator.generateProjectItemLink(ticket.getProjectShortName(),
                ticket.getProjectId(), ticket.getType(), ticket.getExtraTypeId() + ""));
    } else {
        ticketLink.appendText(ticket.getName());
        ticketLink.setHref(ProjectLinkGenerator.generateProjectItemLink(ticket.getProjectShortName(),
                ticket.getProjectId(), ticket.getType(), ticket.getTypeId() + ""));
    }

    issueDiv.appendChild(ticketLink);
    if (ticket.isClosed()) {
        ticketLink.setCSSClass("completed");
    } else if (ticket.isOverdue()) {
        ticketLink.setCSSClass("overdue");
    }

    rowComp.with(ELabel.html(issueDiv.write()).withFullWidth());
    return rowComp;
}
 
Example 5
Source File: ProjectMemberListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private Component generateMemberBlock(final SimpleProjectMember member) {
    MHorizontalLayout blockContent = new MHorizontalLayout().withSpacing(false).withStyleName("member-block").withWidth("350px");
    if (ProjectMemberStatusConstants.NOT_ACCESS_YET.equals(member.getStatus())) {
        blockContent.addStyleName("inactive");
    }

    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(), 100);
    memberAvatar.addStyleName(WebThemes.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(VaadinIcons.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, AppUI.getSiteName()),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                confirmDialog -> {
                    if (confirmDialog.isConfirmed()) {
                        ProjectMemberService prjMemberService = AppContextUtil.getSpringBean(ProjectMemberService.class);
                        prjMemberService.removeWithSession(member, UserUIContext.getUsername(), AppUI.getAccountId());
                        EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoList(ProjectMemberListViewImpl.this, CurrentProjectVariables.getProjectId()));
                    }
                });
    }).withIcon(VaadinIcons.TRASH).withStyleName(WebThemes.BUTTON_LINK)
            .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS))
            .withDescription("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(ProjectLinkGenerator.generateProjectMemberLink(member.getProjectid(), member
            .getUsername())).appendText(member.getMemberFullName()).setTitle(member.getMemberFullName());
    ELabel memberNameLbl = ELabel.h3(memberLink.write()).withStyleName(WebThemes.TEXT_ELLIPSIS).withFullWidth();

    blockTop.with(memberNameLbl, ELabel.hr());

    A roleLink = new A(ProjectLinkGenerator.generateRolePreviewLink(member.getProjectid(), member.getProjectroleid()))
            .appendText(member.getRoleName());
    blockTop.addComponent(ELabel.html(roleLink.write()).withFullWidth().withStyleName(WebThemes.TEXT_ELLIPSIS));

    if (Boolean.TRUE.equals(AppUI.showEmailPublicly())) {
        Label memberEmailLabel = ELabel.html(String.format("<a href='mailto:%s'>%s</a>", member.getUsername(), member.getUsername()))
                .withStyleName(WebThemes.META_INFO).withFullWidth();
        blockTop.addComponent(memberEmailLabel);
    }

    ELabel memberSinceLabel = ELabel.html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_SINCE,
            UserUIContext.formatPrettyTime(member.getCreatedtime()))).withDescription(UserUIContext.formatDateTime(member.getCreatedtime()))
            .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)) +
            " " + VaadinIcons.MONEY.getHtml() + " " + new Span().appendText("" + NumberUtils.roundDouble(2,
            member.getTotalBillableLogTime())).setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) +
            "  " + VaadinIcons.GIFT.getHtml() +
            " " + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime()))
            .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS));

    blockTop.addComponent(ELabel.html(memberWorksInfo).withStyleName(WebThemes.META_INFO));

    blockContent.with(blockTop);
    blockContent.setExpandRatio(blockTop, 1.0f);
    return blockContent;
}