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

The following examples show how to use org.vaadin.viritin.layouts.MHorizontalLayout#with() . 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: TicketRowRenderer.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Component generateRow(IBeanList<ProjectTicket> host, ProjectTicket genericTask, int rowIndex) {
    MHorizontalLayout rowComp = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true))
            .withStyleName(WebThemes.HOVER_EFFECT_NOT_BOX, WebThemes.MARGIN_BOTTOM);
    rowComp.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    rowComp.with(ELabel.fontIcon(ProjectAssetsManager.getAsset(genericTask.getType())).withUndefinedWidth());
    String status;
    if (genericTask.isMilestone()) {
        status = UserUIContext.getMessage(OptionI18nEnum.MilestoneStatus.class, genericTask.getStatus());
    } else {
        status = UserUIContext.getMessage(com.mycollab.common.i18n.OptionI18nEnum.StatusI18nEnum.class, genericTask.getStatus());
    }
    rowComp.with(new ELabel(status).withStyleName(WebThemes.BLOCK).withUndefinedWidth());
    String avatarLink = StorageUtils.getAvatarPath(genericTask.getAssignUserAvatarId(), 16);
    Img img = new Img(genericTask.getAssignUserFullName(), avatarLink).setCSSClass(WebThemes.CIRCLE_BOX)
            .setTitle(genericTask.getAssignUserFullName());

    ToggleTicketSummaryField toggleTicketSummaryField = new ToggleTicketSummaryField(genericTask);
    rowComp.with(ELabel.html(img.write()).withUndefinedWidth(), toggleTicketSummaryField).expand(toggleTicketSummaryField);
    return rowComp;
}
 
Example 2
Source File: SavedFilterComboBox.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected Component initContent() {
    componentsText = new TextField();
    componentsText.setReadOnly(true);
    componentsText.addStyleName("noBorderRight");
    componentsText.setWidth("100%");
    componentPopupSelection = new PopupButton();
    componentPopupSelection.addStyleName(WebThemes.MULTI_SELECT_BG);
    componentPopupSelection.setDirection(Alignment.BOTTOM_LEFT);
    componentPopupSelection.addClickListener(clickEvent -> initContentPopup());

    popupContent = new OptionPopupContent();
    componentPopupSelection.setContent(popupContent);

    MHorizontalLayout content = new MHorizontalLayout(componentsText).withAlign(componentsText, Alignment.MIDDLE_LEFT);

    MHorizontalLayout multiSelectComp = new MHorizontalLayout(componentsText, componentPopupSelection)
            .withSpacing(false).expand(componentsText);
    content.with(multiSelectComp);
    return content;
}
 
Example 3
Source File: VersionSearchPanel.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public ComponentContainer constructBody() {
    MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
    basicSearchBody.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    Label nameLbl = new Label("Name:");
    basicSearchBody.with(nameLbl);

    nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
            .withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
    basicSearchBody.with(nameField);

    MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction())
            .withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
            .withClickShortcut(ShortcutAction.KeyCode.ENTER);
    basicSearchBody.with(searchBtn);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
            .withStyleName(WebThemes.BUTTON_OPTION);
    basicSearchBody.with(cancelBtn);

    return basicSearchBody;
}
 
Example 4
Source File: ComponentSearchPanel.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public ComponentContainer constructBody() {
    MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
    basicSearchBody.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
    basicSearchBody.with(nameLbl);

    nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
            .withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
    basicSearchBody.with(nameField);

    myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
    basicSearchBody.with(myItemCheckbox);

    MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction())
            .withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
            .withClickShortcut(ShortcutAction.KeyCode.ENTER);
    basicSearchBody.with(searchBtn);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
            .withStyleName(WebThemes.BUTTON_OPTION);
    basicSearchBody.with(cancelBtn);

    return basicSearchBody;
}
 
Example 5
Source File: MultiSelectComp.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected Component initContent() {
    MHorizontalLayout content = new MHorizontalLayout().withSpacing(true).withWidth(widthVal).with(componentsText)
            .withAlign(componentsText, Alignment.MIDDLE_LEFT);

    componentPopupSelection.addStyleName(WebThemes.MULTI_SELECT_BG);
    componentPopupSelection.setDirection(Alignment.TOP_LEFT);

    MHorizontalLayout multiSelectComp = new MHorizontalLayout().withSpacing(false).with(componentsText, componentPopupSelection)
            .expand(componentsText);
    content.with(multiSelectComp);

    if (canAddNew) {
        MButton newBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADD), clickEvent -> requestAddNewComp())
                .withStyleName(WebThemes.BUTTON_LINK);
        content.with(newBtn);
    }
    content.expand(multiSelectComp);
    return content;
}
 
Example 6
Source File: TicketKanbanBoardViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
MemberLayout(SimpleUser member) {
    withMargin(false);
    this.member = member;
    bodyLayout = new MHorizontalLayout();
    for (StatusI18nEnum status : statuses) {
        KanbanBlock kanbanBlock = new KanbanBlock(member.getUsername(), status.name());
        kanbanBlocks.put(new Pair(member.getUsername(), status.name()), kanbanBlock);
        bodyLayout.with(kanbanBlock);
    }

    Img userAvatar = new Img("", StorageUtils.getAvatarPath(member.getAvatarid(), 16))
            .setCSSClass(WebThemes.CIRCLE_BOX);
    A userLink = new A(ProjectLinkGenerator.generateProjectMemberLink(CurrentProjectVariables.getProjectId(), member.getUsername())).appendText(member.getDisplayName());
    Div userDiv = new Div().appendChild(userAvatar, new Text(" "), userLink);
    this.with(ELabel.html(userDiv.write()).withStyleName(ValoTheme.LABEL_H3, WebThemes.MARGIN_TOP, WebThemes.MARGIN_BOTTOM), bodyLayout);
}
 
Example 7
Source File: SubTicketsComp.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
private HorizontalLayout generateSubTicketContent(ProjectTicket subTicket) {
    MHorizontalLayout layout = new MHorizontalLayout().withStyleName(WebThemes.HOVER_EFFECT_NOT_BOX).withMargin(new MarginInfo(false, false, false, true));
    layout.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    layout.with(ELabel.fontIcon(ProjectAssetsManager.getAsset(subTicket.getType())));

    Span priorityLink = new Span().appendText(ProjectAssetsManager.getPriorityHtml(subTicket.getPriority()))
            .setTitle(subTicket.getPriority());
    layout.with(ELabel.html(priorityLink.write()).withUndefinedWidth());

    String taskStatus = UserUIContext.getMessage(StatusI18nEnum.class, subTicket.getStatus());
    ELabel statusLbl = new ELabel(taskStatus).withStyleName(WebThemes.FIELD_NOTE).withUndefinedWidth();
    layout.with(statusLbl);

    String avatarLink = StorageUtils.getAvatarPath(subTicket.getAssignUserAvatarId(), 16);
    Img avatarImg = new Img(subTicket.getAssignUserFullName(), avatarLink).setCSSClass(WebThemes.CIRCLE_BOX)
            .setTitle(subTicket.getAssignUserFullName());
    layout.with(ELabel.html(avatarImg.write()).withUndefinedWidth());

    ToggleTicketSummaryWithParentRelationshipField toggleTaskSummaryField = new ToggleTicketSummaryWithParentRelationshipField(parentTicket, subTicket);
    layout.with(toggleTaskSummaryField).expand(toggleTaskSummaryField);
    return layout;
}
 
Example 8
Source File: TicketKanbanBoardViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
NotAssigneeLayout() {
    withMargin(false);
    bodyLayout = new MHorizontalLayout();
    for (StatusI18nEnum status : statuses) {
        KanbanBlock kanbanBlock = new KanbanBlock("", status.name());
        kanbanBlocks.put(new Pair("", status.name()), kanbanBlock);
        bodyLayout.with(kanbanBlock);
    }

    with(new ELabel(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)).withStyleName(ValoTheme.LABEL_NO_MARGIN, ValoTheme.LABEL_H3), bodyLayout);
}
 
Example 9
Source File: MilestoneListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private HorizontalLayout createHeaderRight() {
    MHorizontalLayout layout = new MHorizontalLayout();

    MButton createBtn = new MButton(UserUIContext.getMessage(MilestoneI18nEnum.NEW), clickEvent -> {
        SimpleMilestone milestone = new SimpleMilestone();
        milestone.setSaccountid(AppUI.getAccountId());
        milestone.setProjectid(CurrentProjectVariables.getProjectId());
        UI.getCurrent().addWindow(new MilestoneAddWindow(milestone));
    }).withIcon(VaadinIcons.PLUS).withStyleName(WebThemes.BUTTON_ACTION)
            .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES));
    layout.with(createBtn);

    MButton printBtn = new MButton("", clickEvent -> UI.getCurrent().addWindow(new
            MilestoneCustomizeReportOutputWindow(new LazyValueInjector() {
        @Override
        protected Object doEval() {
            return baseCriteria;
        }
    }))).withIcon(VaadinIcons.PRINT).withStyleName(WebThemes.BUTTON_OPTION)
            .withDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    layout.addComponent(printBtn);

    MButton boardBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_BOARD)).withIcon(VaadinIcons.SERVER).withWidth("100px");

    MButton roadmapBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_LIST),
            clickEvent -> EventBusFactory.getInstance().post(new MilestoneEvent.GotoRoadmap(MilestoneListViewImpl.this)))
            .withIcon(VaadinIcons.BULLETS).withWidth("100px");

    layout.with(new ButtonGroup(roadmapBtn, boardBtn).withDefaultButton(boardBtn));

    return layout;
}
 
Example 10
Source File: TicketRelationSelectField.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected Component initContent() {
    ticketField = new MTextField().withReadOnly(true).withWidth(WebThemes.FORM_CONTROL_WIDTH);
    MHorizontalLayout layout = new MHorizontalLayout();
    MButton browseBtn = new MButton(VaadinIcons.ELLIPSIS_H)
            .withListener(clickEvent -> UI.getCurrent().addWindow(new TicketSelectionWindow(TicketRelationSelectField.this)))
            .withStyleName(WebThemes.BUTTON_OPTION, WebThemes.BUTTON_SMALL_PADDING);
    layout.with(ticketField, browseBtn);
    return layout;
}
 
Example 11
Source File: AccountInfoChangeWindow.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected Component initContent() {
    MHorizontalLayout layout = new MHorizontalLayout().withSpacing(false);
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    Label httpsLabel = new Label("https://");
    Label domainLbl = new Label(".mycollab.com");
    layout.with(httpsLabel, subDomainField, domainLbl);
    return layout;
}
 
Example 12
Source File: MilestoneRoadmapViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
MilestoneBlock(SimpleMilestone milestone) {
    this.withMargin(new MarginInfo(true, false, true, false)).withStyleName("roadmap-block");

    VaadinIcons statusIcon = ProjectAssetsUtil.getPhaseIcon(milestone.getStatus());
    ELabel statusLbl = ELabel.html(statusIcon.getHtml() + " " + UserUIContext.getMessage(MilestoneStatus.class,
            milestone.getStatus())).withStyleName(WebThemes.BLOCK).withUndefinedWidth();
    ToggleMilestoneSummaryField toggleMilestoneSummaryField = new ToggleMilestoneSummaryField(milestone, false, true);
    MHorizontalLayout headerLayout = new MHorizontalLayout(statusLbl, toggleMilestoneSummaryField).expand
            (toggleMilestoneSummaryField).withFullWidth();
    this.with(headerLayout);

    CssLayout metaBlock = new CssLayout();
    MilestoneComponentFactory popupFieldFactory = AppContextUtil.getSpringBean(MilestoneComponentFactory.class);
    metaBlock.addComponent(popupFieldFactory.createMilestoneAssigneePopupField(milestone, true));
    metaBlock.addComponent(popupFieldFactory.createStartDatePopupField(milestone));
    metaBlock.addComponent(popupFieldFactory.createEndDatePopupField(milestone));
    if (!SiteConfiguration.isCommunityEdition()) {
        metaBlock.addComponent(popupFieldFactory.createBillableHoursPopupField(milestone));
        metaBlock.addComponent(popupFieldFactory.createNonBillableHoursPopupField(milestone));
    }

    this.with(metaBlock);

    if (StringUtils.isNotBlank(milestone.getDescription())) {
        this.addComponent(ELabel.html(StringUtils.formatRichText(milestone.getDescription())));
    }

    MHorizontalLayout progressLayout = new MHorizontalLayout();
    progressLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    int openAssignments = milestone.getNumOpenBugs() + milestone.getNumOpenTasks() + milestone.getNumOpenRisks();
    int totalAssignments = milestone.getNumBugs() + milestone.getNumTasks() + milestone.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);
    }

    final MVerticalLayout issueLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, true));
    issueLayout.setVisible(false);

    progressLayout.with(progressInfoLbl);

    if (totalAssignments > 0) {
        MButton viewIssuesBtn = new MButton(UserUIContext.getMessage(ProjectI18nEnum.ACTION_VIEW_TICKETS))
                .withStyleName(WebThemes.BUTTON_LINK);
        viewIssuesBtn.addClickListener(clickEvent -> {
            showIssues = !showIssues;
            if (showIssues) {
                issueLayout.setVisible(true);
                viewIssuesBtn.setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_HIDE_TICKETS));
                ProjectTicketSearchCriteria searchCriteria = new ProjectTicketSearchCriteria();
                searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId()));
                searchCriteria.setTypes(CurrentProjectVariables.getRestrictedTicketTypes());
                searchCriteria.setMilestoneId(new NumberSearchField(milestone.getId()));
                ProjectTicketService genericTaskService = AppContextUtil.getSpringBean(ProjectTicketService.class);
                List<ProjectTicket> tickets = (List<ProjectTicket>) genericTaskService.findPageableListByCriteria(new BasicSearchRequest<>(searchCriteria));
                for (ProjectTicket ticket : tickets) {
                    ToggleTicketSummaryField toggleTicketSummaryField = new ToggleTicketSummaryField(ticket);
                    MHorizontalLayout rowComp = new MHorizontalLayout(ELabel.EMPTY_SPACE());
                    rowComp.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                    rowComp.with(ELabel.fontIcon(ProjectAssetsManager.getAsset(ticket.getType())).withUndefinedWidth());
                    String status = "";
                    if (ticket.isMilestone()) {
                        status = UserUIContext.getMessage(MilestoneStatus.class, ticket.getStatus());
                    } else {
                        status = UserUIContext.getMessage(StatusI18nEnum.class, ticket.getStatus());
                    }
                    rowComp.with(new ELabel(status).withStyleName(WebThemes.BLOCK).withUndefinedWidth());
                    String avatarLink = StorageUtils.getAvatarPath(ticket.getAssignUserAvatarId(), 16);
                    Img img = new Img(ticket.getAssignUserFullName(), avatarLink).setCSSClass(WebThemes.CIRCLE_BOX)
                            .setTitle(ticket.getAssignUserFullName());
                    rowComp.with(ELabel.html(img.write()).withUndefinedWidth());

                    rowComp.with(toggleTicketSummaryField).expand(toggleTicketSummaryField);
                    issueLayout.addComponent(rowComp);
                }
            } else {
                viewIssuesBtn.setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_VIEW_TICKETS));
                issueLayout.removeAllComponents();
                issueLayout.setVisible(false);
            }
        });
        progressLayout.with(viewIssuesBtn);
    }

    this.with(progressLayout, issueLayout);
}
 
Example 13
Source File: FollowingTicketSearchPanel.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public ComponentContainer constructBody() {
    MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);

    GridLayout selectionLayout = new GridLayout(5, 2);
    selectionLayout.setSpacing(true);
    selectionLayout.setMargin(true);
    selectionLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
    basicSearchBody.addComponent(selectionLayout);

    Label summaryLb = new Label("Summary:");
    summaryLb.setWidthUndefined();
    selectionLayout.addComponent(summaryLb, 0, 0);

    summaryField = new TextField();
    summaryField.setWidth("100%");
    summaryField.setPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT));
    selectionLayout.addComponent(summaryField, 1, 0);

    Label typeLb = new Label("Type:");
    typeLb.setWidthUndefined();

    selectionLayout.addComponent(typeLb, 0, 1);

    MHorizontalLayout typeSelectWrapper = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, false));
    selectionLayout.addComponent(typeSelectWrapper, 1, 1);

    taskSelect = new CheckBox(UserUIContext.getMessage(TaskI18nEnum.SINGLE), true);
    taskSelect.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK));

    bugSelect = new CheckBox(UserUIContext.getMessage(BugI18nEnum.SINGLE), true);
    bugSelect.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG));

    riskSelect = new CheckBox(UserUIContext.getMessage(RiskI18nEnum.SINGLE), true);
    riskSelect.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.RISK));

    typeSelectWrapper.with(taskSelect, bugSelect, riskSelect);

    Label projectLb = new Label("Project:");
    projectLb.setWidthUndefined();
    selectionLayout.addComponent(projectLb, 2, 0);

    projectField = new UserInvolvedProjectsListSelect();
    projectField.setWidth("300px");
    projectField.setRows(4);
    selectionLayout.addComponent(projectField, 3, 0, 3, 1);

    MButton queryBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SUBMIT), clickEvent -> doSearch())
            .withStyleName(WebThemes.BUTTON_ACTION);
    selectionLayout.addComponent(queryBtn, 4, 0);

    return basicSearchBody;
}
 
Example 14
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 15
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;
}
 
Example 16
Source File: PageListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void initHeader() {
    HeaderWithIcon headerText = ComponentUtils.headerH2(ProjectTypeConstants.PAGE,
            UserUIContext.getMessage(PageI18nEnum.LIST));

    MHorizontalLayout rightLayout = new MHorizontalLayout();
    headerLayout.with(headerText, rightLayout).expand(headerText);

    ELabel sortLbl = new ELabel(UserUIContext.getMessage(PageI18nEnum.OPT_SORT_LABEL)).withUndefinedWidth();
    rightLayout.with(sortLbl);

    SortButton sortDateBtn = new SortButton(UserUIContext.getMessage(PageI18nEnum.OPT_SORT_BY_DATE), clickEvent -> {
        dateSourceAscend = !dateSourceAscend;
        if (dateSourceAscend) {
            resources.sort(Ordering.from(dateSort));
        } else {
            resources.sort(Ordering.from(dateSort).reverse());
        }
        displayPages(resources);
    });

    SortButton sortNameBtn = new SortButton(UserUIContext.getMessage(PageI18nEnum.OPT_SORT_BY_NAME), clickEvent -> {
        nameSortAscend = !nameSortAscend;
        if (nameSortAscend) {
            resources.sort(Ordering.from(nameSort));
        } else {
            resources.sort(Ordering.from(nameSort).reverse());
        }
        displayPages(resources);
    });

    SortButton sortKindBtn = new SortButton(UserUIContext.getMessage(PageI18nEnum.OPT_SORT_BY_KIND), clickEvent -> {
        kindSortAscend = !kindSortAscend;
        if (kindSortAscend) {
            resources.sort(Ordering.from(kindSort));
        } else {
            resources.sort(Ordering.from(kindSort).reverse());
        }
        displayPages(resources);
    });

    ButtonGroup sortGroup = new ButtonGroup(sortDateBtn, sortNameBtn, sortKindBtn).withDefaultButton(sortDateBtn);
    rightLayout.with(sortGroup);

    MButton newGroupBtn = new MButton(UserUIContext.getMessage(PageI18nEnum.NEW_GROUP),
            clickEvent -> UI.getCurrent().addWindow(new GroupPageAddWindow()))
            .withIcon(VaadinIcons.PLUS).withStyleName(WebThemes.BUTTON_ACTION);
    newGroupBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));
    rightLayout.with(newGroupBtn);

    MButton newPageBtn = new MButton(UserUIContext.getMessage(PageI18nEnum.NEW),
            clickEvent -> EventBusFactory.getInstance().post(new PageEvent.GotoAdd(this, null)))
            .withIcon(VaadinIcons.PLUS).withStyleName(WebThemes.BUTTON_ACTION)
            .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));
    rightLayout.with(newPageBtn);
}
 
Example 17
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 18
Source File: GeneralSettingViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void buildLogoPanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true, false, true, false));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    ELabel logoDesc = ELabel.html(UserUIContext.getMessage(AdminI18nEnum.OPT_LOGO_FORMAT_DESCRIPTION)).withFullWidth();
    leftPanel.with(logoDesc).withWidth("250px");

    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    CustomLayout previewLayout = CustomLayoutExt.createLayout("topNavigation");
    previewLayout.setStyleName("example-block");
    previewLayout.setHeight("40px");
    previewLayout.setWidth("520px");

    Button currentLogo = AccountAssetsResolver.createAccountLogoImageComponent(billingAccount.getLogopath(), 150);
    previewLayout.addComponent(currentLogo, "mainLogo");
    final ServiceMenu serviceMenu = new ServiceMenu();

    Button.ClickListener clickListener = new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {

            for (Component comp : serviceMenu) {
                if (comp != event.getButton()) {
                    comp.removeStyleName("selected");
                }
            }
            event.getButton().addStyleName("selected");
        }
    };

    serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), VaadinIcons.MONEY, clickListener);
    serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT), VaadinIcons.TASKS, clickListener);
    serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), VaadinIcons.SUITCASE, clickListener);
    serviceMenu.selectService(0);

    previewLayout.addComponent(serviceMenu, "serviceMenu");

    MHorizontalLayout buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(true, false, false, false));
    buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    final UploadField logoUploadField = new UploadField() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateDisplayComponent() {
            byte[] imageData = this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
                imageData = ImageUtil.convertJpgToPngFormat(imageData);
                if (imageData == null) {
                    throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT));
                } else {
                    mimeType = "image/png";
                }
            }

            if (mimeType.equals("image/png")) {
                UI.getCurrent().addWindow(new LogoEditWindow(imageData));
            } else {
                throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT));
            }
        }
    };
    logoUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE));
    logoUploadField.addStyleName("upload-field");
    logoUploadField.setSizeUndefined();
    logoUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> {
        BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class);
        billingAccount.setLogopath(null);
        billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername());
        UIUtils.reloadPage();
    }).withStyleName(WebThemes.BUTTON_OPTION);
    resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    buttonControls.with(resetButton, logoUploadField);
    rightPanel.with(previewLayout, buttonControls);
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Logo", layout);
    this.with(formContainer);
}
 
Example 19
Source File: GeneralSettingViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void buildShortcutIconPanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true, false, true, false));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    ELabel logoDesc = ELabel.html(UserUIContext.getMessage(FileI18nEnum.OPT_FAVICON_FORMAT_DESCRIPTION)).withFullWidth();
    leftPanel.with(logoDesc).withWidth("250px");
    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    final Image favIconRes = new Image("", new ExternalResource(StorageUtils.getFavIconPath(billingAccount.getId(),
            billingAccount.getFaviconpath())));

    MHorizontalLayout buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(true, false, false, false));
    buttonControls.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT);
    final UploadField favIconUploadField = new UploadField() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateDisplayComponent() {
            byte[] imageData = this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
                imageData = ImageUtil.convertJpgToPngFormat(imageData);
                if (imageData == null) {
                    throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT));
                } else {
                    mimeType = "image/png";
                }
            }

            if (mimeType.equals("image/png")) {
                try {
                    AccountFavIconService favIconService = AppContextUtil.getSpringBean(AccountFavIconService.class);
                    BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData));
                    String newFavIconPath = favIconService.upload(UserUIContext.getUsername(), image, AppUI.getAccountId());
                    favIconRes.setSource(new ExternalResource(StorageUtils.getFavIconPath(billingAccount.getId(),
                            newFavIconPath)));
                    UIUtils.reloadPage();
                } catch (IOException e) {
                    throw new MyCollabException(e);
                }
            } else {
                throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT));
            }
        }
    };
    favIconUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE));
    favIconUploadField.addStyleName("upload-field");
    favIconUploadField.setSizeUndefined();
    favIconUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> {
        BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class);
        billingAccount.setFaviconpath(null);
        billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername());
        UIUtils.reloadPage();
    }).withStyleName(WebThemes.BUTTON_OPTION);
    resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    buttonControls.with(resetButton, favIconUploadField);
    rightPanel.with(favIconRes, buttonControls);
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Favicon", layout);
    this.with(formContainer);
}
 
Example 20
Source File: PieChartWrapper.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected final ComponentContainer createLegendBox() {
    final CssLayout mainLayout = new CssLayout();
    mainLayout.addStyleName("legend-box");
    mainLayout.setSizeUndefined();
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true))
                .withStyleName("inline-block").withUndefinedWidth();
        layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

        final Comparable key = (Comparable) keys.get(i);
        int colorIndex = i % CHART_COLOR_STR.size();
        final String color = "<div style = \" width:13px;height:13px;background: #"
                + CHART_COLOR_STR.get(colorIndex) + "\" />";
        final ELabel lblCircle = ELabel.html(color);

        String btnCaption;
        if (enumKeyCls == null) {
            if (key instanceof Key) {
                btnCaption = String.format("%s (%d)", StringUtils.trim(((Key) key).getDisplayName(), 20, true),
                        pieDataSet.getValue(key).intValue());
            } else {
                btnCaption = String.format("%s (%d)", key, pieDataSet.getValue(key).intValue());
            }
        } else {
            btnCaption = String.format("%s(%d)", UserUIContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        MButton btnLink = new MButton(StringUtils.trim(btnCaption, 25, true), clickEvent -> {
            if (key instanceof Key) {
                clickLegendItem(((Key) key).getKey());
            } else {
                clickLegendItem(key.toString());
            }
        }).withStyleName(WebThemes.BUTTON_LINK).withDescription(btnCaption);

        layout.with(lblCircle, btnLink);
        mainLayout.addComponent(layout);
    }
    mainLayout.setWidth("100%");
    return mainLayout;
}