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

The following examples show how to use org.vaadin.viritin.layouts.MHorizontalLayout#addComponent() . 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: RoleReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
public RoleReadViewImpl() {
    this.setMargin(new MarginInfo(false, true, true, true));

    MHorizontalLayout header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)).withFullWidth();
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    ELabel headerText = ELabel.h2(VaadinIcons.USERS.getHtml() + " " + UserUIContext.getMessage(RoleI18nEnum.DETAIL));
    header.with(headerText).expand(headerText);
    this.addComponent(header);

    this.previewForm = new AdvancedPreviewBeanForm<>();
    this.addComponent(this.previewForm);

    Layout controlButtons = createTopPanel();
    if (controlButtons != null) {
        header.addComponent(controlButtons);
    }
}
 
Example 2
Source File: RoleSearchPanel.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)
            .with(new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":"));

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

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

    MButton clearBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
            .withStyleName(WebThemes.BUTTON_OPTION);
    basicSearchBody.addComponent(clearBtn);
    basicSearchBody.setComponentAlignment(clearBtn, Alignment.MIDDLE_LEFT);
    return basicSearchBody;
}
 
Example 3
Source File: RoleListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
private ComponentContainer constructTableActionControls() {
    MHorizontalLayout layout = new MHorizontalLayout();
    MCssLayout layoutWrapper = new MCssLayout(layout).withFullWidth().withStyleName(WebThemes.TABLE_ACTION_CONTROLS);

    selectOptionButton = new SelectionOptionButton(tableItem);
    layout.addComponent(selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();
    if (UserUIContext.canAccess(RolePermissionCollections.ACCOUNT_ROLE)) {
        tableActionControls.addDeleteActionItem();
    }
    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    layout.with(tableActionControls, selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel, Alignment.MIDDLE_LEFT);
    return layoutWrapper;
}
 
Example 4
Source File: ProjectRoleSearchPanel.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);
    basicSearchBody.addComponent(new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":"));
    nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
            .withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
    basicSearchBody.addComponent(nameField);

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

    MButton clearBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
            .withStyleName(WebThemes.BUTTON_OPTION);
    basicSearchBody.addComponent(clearBtn);
    return basicSearchBody;
}
 
Example 5
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 6
Source File: MilestoneListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private Component buildBody() {
    CustomLayout bodyContent = CustomLayoutExt.createLayout("milestoneView");

    MHorizontalLayout closedHeaderLayout = new MHorizontalLayout();

    closedHeader = ELabel.html("").withUndefinedWidth();
    closedHeaderLayout.with(closedHeader).withAlign(closedHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(closedHeaderLayout, "closed-header");
    closeContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth();
    bodyContent.addComponent(closeContainer, "closed-milestones");

    MHorizontalLayout inProgressHeaderLayout = new MHorizontalLayout();
    inProgressHeader = ELabel.html("").withUndefinedWidth();
    inProgressHeaderLayout.addComponent(inProgressHeader);
    inProgressHeaderLayout.setComponentAlignment(inProgressHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(inProgressHeaderLayout, "in-progress-header");
    inProgressContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth();
    bodyContent.addComponent(this.inProgressContainer, "in-progress-milestones");

    MHorizontalLayout futureHeaderLayout = new MHorizontalLayout();
    futureHeader = ELabel.html("").withUndefinedWidth();
    futureHeaderLayout.addComponent(futureHeader);
    futureHeaderLayout.setComponentAlignment(futureHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(futureHeaderLayout, "future-header");
    futureContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth();
    bodyContent.addComponent(this.futureContainer, "future-milestones");

    return bodyContent;
}
 
Example 7
Source File: ProjectListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private ComponentContainer constructTableActionControls() {
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withStyleName(WebThemes.TABLE_ACTION_CONTROLS);

    selectOptionButton = new SelectionOptionButton(tableItem);
    selectOptionButton.setWidthUndefined();
    layout.addComponent(selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();

    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    tableActionControls.setVisible(false);
    tableActionControls.setWidthUndefined();

    layout.addComponent(tableActionControls);
    selectedItemsNumberLabel.setWidth("100%");
    layout.with(selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel, Alignment.MIDDLE_CENTER).expand(selectedItemsNumberLabel);

    MButton customizeViewBtn = new MButton("", clickEvent -> UI.getCurrent().addWindow(new ProjectListCustomizeWindow(tableItem)))
            .withStyleName(WebThemes.BUTTON_ACTION).withIcon(VaadinIcons.ADJUST);
    customizeViewBtn.setDescription(UserUIContext.getMessage(GenericI18Enum.OPT_LAYOUT_OPTIONS));
    layout.with(customizeViewBtn).withAlign(customizeViewBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}
 
Example 8
Source File: ProjectPagedList.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected MHorizontalLayout createPageControls() {
    MHorizontalLayout pageControls = super.createPageControls();
    if (pageControls != null) {
        Button browseProjectsBtn = new Button(UserUIContext.getMessage(ProjectI18nEnum.ACTION_BROWSE),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoList(this, null)));
        browseProjectsBtn.addStyleName(WebThemes.BUTTON_LINK);
        pageControls.addComponent(browseProjectsBtn, 0);
        pageControls.setComponentAlignment(browseProjectsBtn, Alignment.MIDDLE_LEFT);
    }
    return pageControls;
}
 
Example 9
Source File: SubTicketsComp.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected Component initContent() {
    MHorizontalLayout contentLayout = new MHorizontalLayout().withFullWidth();
    ticketsLayout = new VerticalRemoveInlineComponentMarker().withFullWidth().withMargin(new MarginInfo(false, true, true, false));
    contentLayout.with(ticketsLayout).expand(ticketsLayout);

    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
        MButton addNewTaskBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADD), clickEvent -> {
            MWindow newTicketWindow = AppContextUtil.getSpringBean(TicketComponentFactory.class)
                    .createNewTicketWindow(null, parentTicket.getProjectId(), parentTicket.getMilestoneId(), true, null);
            UI.getCurrent().addWindow(newTicketWindow);
        }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(VaadinIcons.PLUS);

        SplitButton splitButton = new SplitButton(addNewTaskBtn);
        splitButton.setWidthUndefined();
        splitButton.addStyleName(WebThemes.BUTTON_ACTION);

        OptionPopupContent popupButtonsControl = new OptionPopupContent();
        Button selectBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT), clickEvent -> {
            splitButton.setPopupVisible(false);
            UI.getCurrent().addWindow(new SelectChildTicketWindow(parentTicket));
        });
        popupButtonsControl.addOption(selectBtn);
        splitButton.setContent(popupButtonsControl);
        contentLayout.addComponent(splitButton);
    }

    ProjectTicketService projectTicketService = AppContextUtil.getSpringBean(ProjectTicketService.class);
    List<ProjectTicket> subTickets = projectTicketService.findSubTickets(ProjectTypeConstants.TASK, parentTicket.getTypeId());
    if (CollectionUtils.isNotEmpty(subTickets)) {
        for (ProjectTicket subTicket : subTickets) {
            ticketsLayout.addComponent(generateSubTicketContent(subTicket));
        }
    }
    return contentLayout;
}
 
Example 10
Source File: StandupListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Component generateRow(IBeanList<SimpleStandupReport> host, SimpleStandupReport report, int rowIndex) {
    MHorizontalLayout rowLayout = new MHorizontalLayout().withStyleName(WebThemes.BORDER);

    MVerticalLayout userInfo = new MVerticalLayout().withWidth("200px").withFullHeight().withStyleName(WebThemes
            .HOVER_EFFECT_NOT_BOX);
    userInfo.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Image userAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(report.getLogByAvatarId(), 100);
    userAvatar.addStyleName(WebThemes.CIRCLE_BOX);
    userInfo.addComponent(userAvatar);
    Label memberLink = ELabel.html(buildMemberLink(report));
    userInfo.with(memberLink).expand(memberLink).withAlign(memberLink, Alignment.TOP_CENTER);
    rowLayout.addComponent(userInfo);

    MVerticalLayout reportContent = new MVerticalLayout().withStyleName(WebThemes.BORDER_LEFT, WebThemes.HOVER_EFFECT_NOT_BOX);

    reportContent.addComponent(ELabel.h3(UserUIContext.getMessage(StandupI18nEnum.STANDUP_LASTDAY)).withStyleName(WebThemes.LABEL_WORD_WRAP).withFullWidth());
    Label whatYesterdayField = new SafeHtmlLabel(report.getWhatlastday());
    whatYesterdayField.setWidth("100%");
    reportContent.addComponent(whatYesterdayField);

    reportContent.addComponent(ELabel.h3(UserUIContext.getMessage(StandupI18nEnum.STANDUP_TODAY)).withStyleName(WebThemes.LABEL_WORD_WRAP).withFullWidth());
    Label whatTodayField = new SafeHtmlLabel(report.getWhattoday());
    whatTodayField.setWidth("100%");
    reportContent.addComponent(whatTodayField);

    reportContent.addComponent(ELabel.h3(UserUIContext.getMessage(StandupI18nEnum.STANDUP_ISSUE)).withStyleName(WebThemes.LABEL_WORD_WRAP).withFullWidth());
    Label whatProblemField = new SafeHtmlLabel(report.getWhatproblem());
    whatProblemField.setWidth("100%");
    reportContent.addComponent(whatProblemField);

    rowLayout.with(reportContent).expand(reportContent);
    return rowLayout;
}
 
Example 11
Source File: FormControlsGenerator.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public static <T> ComponentContainer generateEditFormControls(final AdvancedEditBeanForm<T> editForm, boolean
        isSaveBtnVisible, boolean isSaveAndNewBtnVisible, boolean isCancelBtnVisible) {
    MHorizontalLayout layout = new MHorizontalLayout();

    if (isCancelBtnVisible) {
        MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> editForm.fireCancelForm())
                .withStyleName(WebThemes.BUTTON_OPTION);
        layout.addComponent(cancelBtn);
    }

    if (isSaveAndNewBtnVisible) {
        MButton saveAndNewBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE_NEW), clickEvent -> {
            if (editForm.validateForm()) {
                editForm.fireSaveAndNewForm();
            }
        }).withIcon(VaadinIcons.CLIPBOARD_CROSS).withStyleName(WebThemes.BUTTON_ACTION);
        if (!isSaveBtnVisible) {
            saveAndNewBtn.withClickShortcut(KeyCode.ENTER);
        }
        layout.addComponent(saveAndNewBtn);
    }

    if (isSaveBtnVisible) {
        MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
            if (editForm.validateForm()) {
                editForm.fireSaveForm();
            }
        }).withIcon(VaadinIcons.CLIPBOARD).withStyleName(WebThemes.BUTTON_ACTION)
                .withClickShortcut(KeyCode.ENTER);
        layout.addComponent(saveBtn);
    }

    return layout;
}
 
Example 12
Source File: UserWorkloadReportViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public UserWorkloadReportViewImpl() {
    projectRoleService = AppContextUtil.getSpringBean(ProjectRoleService.class);
    projectTicketService = AppContextUtil.getSpringBean(ProjectTicketService.class);
    searchPanel = new TicketCrossProjectsSearchPanel();

    wrapBody = new ResponsiveLayout();
    withSpacing(true).with(searchPanel, wrapBody).expand(wrapBody);

    MHorizontalLayout extraCompsHeaderLayout = new MHorizontalLayout();
    extraCompsHeaderLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    savedFilterComboBox = new TicketSavedFilterComboBox();
    savedFilterComboBox.addQuerySelectListener((SavedFilterComboBox.QuerySelectListener) querySelectEvent -> {
        List<SearchFieldInfo<ProjectTicketSearchCriteria>> fieldInfos = querySelectEvent.getSearchFieldInfos();
        ProjectTicketSearchCriteria criteria = SearchFieldInfo.buildSearchCriteria(ProjectTicketSearchCriteria.class,
                fieldInfos);
        EventBusFactory.getInstance().post(new TicketEvent.SearchRequest(UserWorkloadReportViewImpl.this, criteria));
        queryTickets(criteria);
    });

    extraCompsHeaderLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.SAVE_FILTER_VALUE)));
    extraCompsHeaderLayout.addComponent(savedFilterComboBox);

    extraCompsHeaderLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.ACTION_SORT)));
    StringValueComboBox sortCombo = new StringValueComboBox(false, UserUIContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING),
            UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING));
    sortCombo.setWidth("130px");
    sortCombo.addValueChangeListener(valueChangeEvent -> {
        String sortValue = sortCombo.getValue();
        if (UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) {
            sortDirection = SearchCriteria.ASC;
        } else {
            sortDirection = SearchCriteria.DESC;
        }
        displayProjectTickets(selectedProject);
    });
    sortDirection = SearchCriteria.DESC;
    extraCompsHeaderLayout.addComponent(sortCombo);

    extraCompsHeaderLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.OPT_GROUP)));
    StringValueComboBox groupCombo = new StringValueComboBox(false, UserUIContext.getMessage(GenericI18Enum.FORM_DUE_DATE),
            UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE), UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME),
            UserUIContext.getMessage(GenericI18Enum.OPT_PLAIN), UserUIContext.getMessage(GenericI18Enum.OPT_USER),
            UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
    groupByState = UserUIContext.getMessage(MilestoneI18nEnum.SINGLE);
    groupCombo.setValue(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
    groupCombo.addValueChangeListener(valueChangeEvent -> {
        groupByState = groupCombo.getValue();
        displayProjectTickets(selectedProject);
    });
    groupCombo.setWidth("130px");

    extraCompsHeaderLayout.addComponent(groupCombo);

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

    searchPanel.addHeaderRight(extraCompsHeaderLayout);
}
 
Example 13
Source File: CommentRowDisplayHandler.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Component generateRow(IBeanList<SimpleComment> host, final SimpleComment comment, int rowIndex) {
    final MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(true, true, true, false))
            .withFullWidth();

    ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName());
    layout.addComponent(memberBlock);

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

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

    ELabel timePostLbl = ELabel.html(UserUIContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(),
            UserUIContext.formatPrettyTime(comment.getCreatedtime())))
            .withDescription(UserUIContext.formatDateTime(comment.getCreatedtime()));
    timePostLbl.setStyleName(WebThemes.META_INFO);

    if (hasDeletePermission(comment)) {
        MButton msgDeleteBtn = new MButton(VaadinIcons.TRASH).withStyleName(WebThemes.BUTTON_ICON_ONLY)
                .withListener(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()) {
                                CommentService commentService = AppContextUtil.getSpringBean(CommentService.class);
                                commentService.removeWithSession(comment, UserUIContext.getUsername(), AppUI.getAccountId());
                                ((BeanList) host).removeRow(layout);
                            }
                        }));
        messageHeader.with(timePostLbl, msgDeleteBtn).expand(timePostLbl);
    } else {
        messageHeader.with(timePostLbl).expand(timePostLbl);
    }

    rowLayout.addComponent(messageHeader);

    Label messageContent = new SafeHtmlLabel(comment.getComment());
    rowLayout.addComponent(messageContent);

    List<Content> attachments = comment.getAttachments();
    if (!CollectionUtils.isEmpty(attachments)) {
        MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withFullWidth();
        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;
}
 
Example 14
Source File: ProjectActivityComponent.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private Component buildAuditBlock(SimpleAuditLog auditLog) {
    List<AuditChangeItem> changeItems = auditLog.getChangeItems();
    if (CollectionUtils.isNotEmpty(changeItems)) {
        MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
                .withFullWidth();

        ProjectMemberBlock memberBlock = new ProjectMemberBlock(auditLog.getCreateduser(), auditLog.getPostedUserAvatarId(),
                auditLog.getPostedUserFullName());
        layout.addComponent(memberBlock);

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

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

        ELabel timePostLbl = ELabel.html(UserUIContext.getMessage(GenericI18Enum.EXT_MODIFIED_ITEM, auditLog.getPostedUserFullName(),
                UserUIContext.formatPrettyTime(auditLog.getCreatedtime())))
                .withDescription(UserUIContext.formatDateTime(auditLog.getCreatedtime()));
        timePostLbl.setStyleName(WebThemes.META_INFO);
        messageHeader.with(timePostLbl).expand(timePostLbl);

        rowLayout.addComponent(messageHeader);

        for (AuditChangeItem item : changeItems) {
            String fieldName = item.getField();

            DefaultFieldDisplayHandler fieldDisplayHandler = groupFormatter.getFieldDisplayHandler(fieldName);
            if (fieldDisplayHandler != null) {
                Span fieldBlock = new Span().appendText(UserUIContext.getMessage(fieldDisplayHandler.getDisplayName()))
                        .setCSSClass(WebThemes.BLOCK);
                Div historyDiv = new Div().appendChild(fieldBlock).appendText(fieldDisplayHandler.getFormat()
                        .toString(item.getOldvalue())).appendText(" " + VaadinIcons.ARROW_RIGHT.getHtml() +
                        " ").appendText(fieldDisplayHandler.getFormat().toString(item.getNewvalue()));
                rowLayout.addComponent(new MCssLayout(ELabel.html(historyDiv.write()).withFullWidth()).withFullWidth());
            }
        }

        layout.with(rowLayout).expand(rowLayout);
        return layout;
    } else {
        return null;
    }
}
 
Example 15
Source File: ProjectActivityComponent.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private Component buildCommentBlock(final SimpleComment comment) {
    MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
            .withFullWidth();

    ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(), comment.getOwnerAvatarId(),
            comment.getOwnerFullName());
    layout.addComponent(memberBlock);

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

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

    ELabel timePostLbl = ELabel.html(UserUIContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(),
            UserUIContext.formatPrettyTime(comment.getCreatedtime())))
            .withDescription(UserUIContext.formatDateTime(comment.getCreatedtime()))
            .withStyleName(WebThemes.META_INFO);

    if (hasDeletePermission(comment)) {
        MButton msgDeleteBtn = new MButton(VaadinIcons.TRASH).withListener(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()) {
                            CommentService commentService = AppContextUtil.getSpringBean(CommentService.class);
                            commentService.removeWithSession(comment, UserUIContext.getUsername(), AppUI.getAccountId());
                            activityBox.removeComponent(layout);
                        }
                    });
        }).withStyleName(WebThemes.BUTTON_ICON_ONLY);
        messageHeader.with(timePostLbl, msgDeleteBtn).expand(timePostLbl);
    } else {
        messageHeader.with(timePostLbl).expand(timePostLbl);
    }

    rowLayout.addComponent(messageHeader);

    Label messageContent = new SafeHtmlLabel(comment.getComment());
    rowLayout.addComponent(messageContent);

    List<Content> attachments = comment.getAttachments();
    if (!CollectionUtils.isEmpty(attachments)) {
        MVerticalLayout messageFooter = new MVerticalLayout().withMargin(false).withSpacing(false).withFullWidth();
        AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments);
        attachmentDisplay.setWidth("100%");
        messageFooter.with(attachmentDisplay);
        rowLayout.addComponent(messageFooter);
    }

    layout.with(rowLayout).expand(rowLayout);
    return layout;
}
 
Example 16
Source File: ProjectMemberListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public ProjectMemberListViewImpl() {
    this.setMargin(new MarginInfo(false, true, true, true));

    responsiveLayout = new ResponsiveLayout(ResponsiveLayout.ContainerType.FIXED);
    responsiveLayout.setWidth("100%");
    this.add(responsiveLayout);

    MHorizontalLayout viewHeader = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)).withFullWidth();
    viewHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    headerText = ComponentUtils.headerH2(ProjectTypeConstants.MEMBER, UserUIContext.getMessage(ProjectMemberI18nEnum.LIST));
    viewHeader.with(headerText).expand(headerText);

    final MButton sortBtn = new MButton().withIcon(VaadinIcons.CARET_UP).withStyleName(WebThemes.BUTTON_ICON_ONLY);
    sortBtn.addClickListener(clickEvent -> {
        sortAsc = !sortAsc;
        if (sortAsc) {
            sortBtn.setIcon(VaadinIcons.CARET_UP);
            displayMembers();
        } else {
            sortBtn.setIcon(VaadinIcons.CARET_DOWN);
            displayMembers();
        }
    });
    viewHeader.addComponent(sortBtn);

    final SearchTextField searchTextField = new SearchTextField() {
        @Override
        public void doSearch(String value) {
            searchCriteria.setMemberFullName(StringSearchField.and(value));
            displayMembers();
        }

        @Override
        public void emptySearch() {
            searchCriteria.setMemberFullName(null);
            displayMembers();
        }
    };
    searchTextField.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    viewHeader.addComponent(searchTextField);

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

    MButton createBtn = new MButton(UserUIContext.getMessage(ProjectMemberI18nEnum.BUTTON_NEW_INVITEES),
            clickEvent -> EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoInviteMembers(this, null)))
            .withStyleName(WebThemes.BUTTON_ACTION).withIcon(VaadinIcons.PAPERPLANE);
    createBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS));
    viewHeader.addComponent(createBtn);

    ResponsiveRow row = responsiveLayout.addRow();

    ResponsiveColumn column1 = new ResponsiveColumn(12, 12, 12, 12);
    column1.setContent(viewHeader);
    row.addColumn(column1);

    contentLayout = new MCssLayout().withFullWidth();
    row.addComponent(contentLayout);
}
 
Example 17
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 18
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 19
Source File: AbstractPagedBeanTable.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private ComponentContainer createPagingControls() {
    controlBarWrapper = new HorizontalLayout();
    controlBarWrapper.setWidth("100%");
    controlBarWrapper.setStyleName("listControl");

    MHorizontalLayout pageManagement = new MHorizontalLayout();

    // defined layout here ---------------------------

    if (currentPage > 1) {
        MButton firstLink = new MButton("1", clickEvent -> pageChange(1)).withStyleName("buttonPaging");
        pageManagement.addComponent(firstLink);
    }
    if (currentPage >= 5) {
        Label ss1 = new Label("...");
        ss1.addStyleName("buttonPaging");
        pageManagement.addComponent(ss1);
    }

    if (currentPage > 3) {
        MButton previous2 = new MButton("" + (currentPage - 2), clickEvent -> pageChange(currentPage - 2))
                .withStyleName("buttonPaging");
        pageManagement.addComponent(previous2);
    }
    if (currentPage > 2) {
        MButton previous1 = new MButton("" + (currentPage - 1), clickEvent -> pageChange(currentPage - 1))
                .withStyleName("buttonPaging");
        pageManagement.addComponent(previous1);
    }
    // Here add current ButtonLinkLegacy
    MButton current = new MButton("" + currentPage, clickEvent -> pageChange(currentPage))
            .withStyleName("buttonPaging", "current");

    pageManagement.addComponent(current);
    final int range = totalPage - currentPage;
    if (range >= 1) {
        MButton next1 = new MButton("" + (currentPage + 1), clickEvent -> pageChange(currentPage + 1))
                .withStyleName("buttonPaging");
        pageManagement.addComponent(next1);
    }
    if (range >= 2) {
        MButton next2 = new MButton("" + (currentPage + 2), clickEvent -> pageChange(currentPage + 2))
                .withStyleName("buttonPaging");
        pageManagement.addComponent(next2);
    }
    if (range >= 4) {
        final Label ss2 = new Label("...");
        ss2.addStyleName("buttonPaging");
        pageManagement.addComponent(ss2);
    }
    if (range >= 3) {
        MButton last = new MButton("" + totalPage, clickEvent -> pageChange(totalPage)).withStyleName("buttonPaging");
        pageManagement.addComponent(last);
    }

    pageManagement.setWidth(null);
    controlBarWrapper.addComponent(pageManagement);
    controlBarWrapper.setComponentAlignment(pageManagement, Alignment.MIDDLE_RIGHT);

    return controlBarWrapper;
}
 
Example 20
Source File: TicketDashboardViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public TicketDashboardViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));
    ticketSearchPanel = new TicketSearchPanel();

    MHorizontalLayout extraCompsHeaderLayout = new MHorizontalLayout();
    extraCompsHeaderLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    extraCompsHeaderLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.ACTION_SORT)));
    StringValueComboBox sortCombo = new StringValueComboBox(false, UserUIContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING),
            UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING));
    sortCombo.setWidth("130px");
    sortCombo.addValueChangeListener(valueChangeEvent -> {
        String sortValue = sortCombo.getValue();
        if (UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) {
            sortDirection = SearchCriteria.ASC;
        } else {
            sortDirection = SearchCriteria.DESC;
        }
        queryAndDisplayTickets();
    });
    sortDirection = SearchCriteria.DESC;
    extraCompsHeaderLayout.addComponent(sortCombo);

    extraCompsHeaderLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.OPT_GROUP)));
    StringValueComboBox groupCombo = new StringValueComboBox(false, UserUIContext.getMessage(GenericI18Enum.FORM_DUE_DATE),
            UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE), UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME),
            UserUIContext.getMessage(GenericI18Enum.OPT_PLAIN), UserUIContext.getMessage(GenericI18Enum.OPT_USER),
            UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
    groupByState = UserUIContext.getMessage(MilestoneI18nEnum.SINGLE);
    groupCombo.setValue(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
    groupCombo.addValueChangeListener(valueChangeEvent -> {
        groupByState = groupCombo.getValue();
        queryAndDisplayTickets();
    });
    groupCombo.setWidth("130px");

    extraCompsHeaderLayout.addComponent(groupCombo);

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

    MButton newTicketBtn = new MButton(UserUIContext.getMessage(TicketI18nEnum.NEW), clickEvent -> {
        UI.getCurrent().addWindow(AppContextUtil.getSpringBean(TicketComponentFactory.class)
                .createNewTicketWindow(null, CurrentProjectVariables.getProjectId(), null, false, null));
    }).withIcon(VaadinIcons.PLUS).withStyleName(WebThemes.BUTTON_ACTION)
            .withVisible(CurrentProjectVariables.canWriteTicket());
    extraCompsHeaderLayout.addComponent(newTicketBtn);

    ticketSearchPanel.addHeaderRight(extraCompsHeaderLayout);

    wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, false, true, false));

    this.with(ticketSearchPanel, wrapBody).expand(wrapBody);
}