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

The following examples show how to use org.vaadin.viritin.layouts.MHorizontalLayout#setDefaultComponentAlignment() . 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: 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 2
Source File: ProjectAddViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public AbstractComponent getLayout() {
    MHorizontalLayout header = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true, false, true, false));
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    final AddViewLayout projectAddLayout = new AddViewLayout(header);

    if (SiteConfiguration.isCommunityEdition())
        wrappedLayoutFactory = new DefaultDynaFormLayout(ProjectTypeConstants.PROJECT, ProjectDefaultFormLayoutFactory.getAddForm(), Project.Field.clientid.name());
    else
        wrappedLayoutFactory = new DefaultDynaFormLayout(ProjectTypeConstants.PROJECT, ProjectDefaultFormLayoutFactory.getAddForm());
    projectAddLayout.addHeaderTitle(buildHeaderTitle());
    projectAddLayout.addHeaderRight(createButtonControls());

    projectAddLayout.addBody(wrappedLayoutFactory.getLayout());

    return projectAddLayout;
}
 
Example 3
Source File: ProjectActivityStreamPagedList.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void feedBlocksPut(LocalDate currentDate, LocalDate nextDate, ComponentContainer currentBlock) {
    MHorizontalLayout blockWrapper = new MHorizontalLayout().withSpacing(false).withFullWidth().withStyleName
            ("feed-block-wrap");

    blockWrapper.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    if (currentDate.getYear() != nextDate.getYear()) {
        int currentYear = nextDate.getYear();
        ELabel yearLbl = ELabel.html("<div>" + currentYear + "</div>").withStyleName("year-lbl").withUndefinedWidth();
        this.addComponent(yearLbl);
    } else {
        blockWrapper.setMargin(new MarginInfo(true, false, false, false));
    }
    ELabel dateLbl = new ELabel(UserUIContext.formatShortDate(nextDate)).withStyleName("date-lbl").withUndefinedWidth();
    blockWrapper.with(dateLbl, currentBlock).expand(currentBlock);

    this.addComponent(blockWrapper);
}
 
Example 4
Source File: StandupListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
private MHorizontalLayout constructHeader() {
    MHorizontalLayout header = new MHorizontalLayout().withSpacing(false).withMargin((new MarginInfo(true, false, true, false))).withFullWidth();
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    MHorizontalLayout headerLeft = new MHorizontalLayout();

    HeaderWithIcon titleLbl = ComponentUtils.headerH2(ProjectTypeConstants.STANDUP,
            UserUIContext.getMessage(StandupI18nEnum.VIEW_LIST_TITLE));

    headerLeft.with(titleLbl, standupCalendar);
    header.with(headerLeft).withAlign(headerLeft, Alignment.TOP_LEFT);

    MButton newReportBtn = new MButton(UserUIContext.getMessage(StandupI18nEnum.BUTTON_ADD_REPORT_LABEL), clickEvent -> {
        if (selectedProject != null) {
            UI.getCurrent().addWindow(new StandupAddWindow(selectedProject, onDate));
        } else {
            NotificationUtil.showErrorNotification("You do not select any project");
        }
    }).withIcon(VaadinIcons.PLUS).withStyleName(WebThemes.BUTTON_ACTION);

    header.with(newReportBtn).withAlign(newReportBtn, Alignment.TOP_RIGHT);
    return header;
}
 
Example 5
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 6
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 7
Source File: BuildCriterionComponent.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public BuildCriterionComponent(SearchLayout<S> searchLayout, Param[] paramFields, String searchCategory) {
    this.hostSearchLayout = searchLayout;
    this.paramFields = paramFields;
    this.searchCategory = searchCategory;

    MHorizontalLayout headerBox = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, true));
    headerBox.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    addComponent(headerBox);

    Label filterLbl = new Label(UserUIContext.getMessage(GenericI18Enum.OPT_SAVED_FILTER));
    headerBox.with(filterLbl).withAlign(filterLbl, Alignment.TOP_LEFT);

    filterBox = new MHorizontalLayout();
    headerBox.with(filterBox).withAlign(filterBox, Alignment.TOP_LEFT);

    buildFilterBox(null);

    searchContainer = new MVerticalLayout().withMargin(false);
    searchContainer.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    MButton addCriteriaBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADD_CRITERIA), clickEvent -> {
        CriteriaSelectionLayout newCriteriaBar = new CriteriaSelectionLayout(searchContainer.getComponentCount() + 1);
        searchContainer.addComponent(newCriteriaBar);
    }).withIcon(VaadinIcons.PLUS).withStyleName(WebThemes.BUTTON_ACTION);

    this.with(searchContainer, new MHorizontalLayout(addCriteriaBtn).withMargin(true));
}
 
Example 8
Source File: TicketKanbanBoardViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public TicketKanbanBoardViewImpl() {
    this.withSpacing(true).withMargin(new MarginInfo(false, true, true, true));
    searchPanel = new TicketSearchPanel();
    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    searchPanel.addHeaderRight(groupWrapLayout);

    MButton allFilterBtn = new MButton("All").withStyleName(WebThemes.BUTTON_OPTION).withListener((Button.ClickListener) clickEvent -> {
        statuses = OptionI18nEnum.statuses;
        baseCriteria.setTypes(new SetSearchField<>(ProjectTypeConstants.BUG, ProjectTypeConstants.TASK, ProjectTypeConstants.RISK));
        queryTickets(baseCriteria);
    });

    MButton filterBugsBtn = new MButton(UserUIContext.getMessage(BugI18nEnum.SINGLE)).withStyleName(WebThemes.BUTTON_OPTION).withListener((Button.ClickListener) clickEvent -> {
        statuses = OptionI18nEnum.bugStatuses;
        baseCriteria.setTypes(new SetSearchField<>(ProjectTypeConstants.BUG));
        queryTickets(baseCriteria);
    });

    MButton filterTasksBtn = new MButton(UserUIContext.getMessage(TaskI18nEnum.SINGLE)).withStyleName(WebThemes.BUTTON_OPTION).withListener((Button.ClickListener) clickEvent -> {
        statuses = OptionI18nEnum.taskStatuses;
        baseCriteria.setTypes(new SetSearchField<>(ProjectTypeConstants.TASK));
        queryTickets(baseCriteria);
    });

    MButton filterRisksBtn = new MButton(UserUIContext.getMessage(RiskI18nEnum.SINGLE)).withStyleName(WebThemes.BUTTON_OPTION).withListener((Button.ClickListener) clickEvent -> {
        statuses = OptionI18nEnum.riskStatuses;
        baseCriteria.setTypes(new SetSearchField<>(ProjectTypeConstants.RISK));
        queryTickets(baseCriteria);
    });

    ButtonGroup group = new ButtonGroup(allFilterBtn, filterBugsBtn, filterTasksBtn, filterRisksBtn).withDefaultButton(allFilterBtn);

    MHorizontalLayout controlLayout = new MHorizontalLayout(ELabel.html("Filter by: "), group)
            .withDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    kanbanLayout = new MCssLayout().withStyleName("kanban-layout", WebThemes.NO_SCROLLABLE_CONTAINER);
    this.with(searchPanel, controlLayout, kanbanLayout).expand(kanbanLayout);
}
 
Example 9
Source File: PreviewFormControlsGenerator.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public PreviewFormControlsGenerator(AdvancedPreviewBeanForm<T> editForm) {
    this.previewForm = editForm;
    layout = new MHorizontalLayout();
    layout.setSizeUndefined();
    popupButtonsControl = new OptionPopupContent();
    editButtons = new MHorizontalLayout();
    editButtons.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
}
 
Example 10
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 11
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 12
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 13
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 14
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 15
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 16
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;
}
 
Example 17
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 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: 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 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);
}