Example usage for com.vaadin.ui CssLayout addComponent

List of usage examples for com.vaadin.ui CssLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui CssLayout addComponent.

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

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

License:Open Source License

private void initContent() {
    previewForm = initPreviewForm();/*ww w. j a  v  a  2  s. co  m*/
    ComponentContainer actionControls = createButtonControls();
    if (actionControls != null) {
        actionControls.addStyleName("control-buttons");
        addHeaderRightContent(actionControls);
    }

    CssLayout contentWrapper = new CssLayout();
    contentWrapper.setStyleName("content-wrapper");

    if (previewLayout == null)
        previewLayout = new DefaultReadViewLayout("");

    contentWrapper.addComponent(previewLayout);

    RightSidebarLayout bodyContainer = new RightSidebarLayout();
    bodyContainer.setSizeFull();
    bodyContainer.addStyleName("readview-body-wrap");

    bodyContent = new MVerticalLayout().withSpacing(false).withMargin(false).with(previewForm);
    bodyContainer.setContent(bodyContent);

    sidebarContent = new MVerticalLayout().withWidth("250px").withSpacing(true)
            .withStyleName("readview-sidebar");
    bodyContainer.setSidebar(sidebarContent);

    FloatingComponent floatSidebar = FloatingComponent.floatThis(sidebarContent);
    floatSidebar.setContainerId("main-body");

    previewLayout.addBody(bodyContainer);

    this.addComponent(contentWrapper);
}

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

License:Open Source License

public AbstractPreviewItemComp2(String headerText, Resource iconResource) {
    if (iconResource != null)
        this.titleIcon = new Image(null, iconResource);
    this.addComponent(constructHeader(headerText));

    previewForm = initPreviewForm();/*from   w  ww .  j av a2  s. c  om*/
    ComponentContainer actionControls = createButtonControls();
    if (actionControls != null) {
        actionControls.addStyleName("control-buttons");
        addHeaderRightContent(actionControls);
    }

    CssLayout contentWrapper = new CssLayout();
    contentWrapper.setStyleName("content-wrapper");

    previewLayout = new ReadViewLayout("");

    contentWrapper.addComponent(previewLayout);

    bodyContainer = new HorizontalLayout();
    bodyContainer.setSizeFull();
    bodyContainer.setStyleName("readview-body-wrap");

    bodyContent = new VerticalLayout();
    bodyContent.addComponent(previewForm);
    bodyContainer.addComponent(bodyContent);
    bodyContainer.setExpandRatio(bodyContent, 1);

    sidebarContent = new VerticalLayout();
    sidebarContent.setWidth("250px");
    sidebarContent.setSpacing(true);
    sidebarContent.setStyleName("readview-sidebar");
    bodyContainer.addComponent(sidebarContent);

    FloatingComponent floatSidebar = FloatingComponent.floatThis(sidebarContent);
    floatSidebar.setContainerId("main-body");

    previewLayout.addBody(bodyContainer);

    this.addComponent(contentWrapper);
}

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

License:Open Source License

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

    ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(),
            comment.getOwnerAvatarId(), comment.getOwnerFullName());
    layout.addComponent(memberBlock);/* w  w w  .  ja  v a 2 s . c  om*/

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

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

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

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

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

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

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

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

    rowLayout.addComponent(messageHeader);

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

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

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

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

License:Open Source License

@Override
protected Component initContent() {
    ProjectMemberService projectMemberService = ApplicationContextUtil
            .getSpringBean(ProjectMemberService.class);
    List<SimpleUser> members = projectMemberService.getActiveUsersInProject(projectId,
            AppContext.getAccountId());/*from ww w .j a  va2 s .c  o m*/
    CssLayout container = new CssLayout();
    container.setStyleName("followers-container");
    final CheckBox selectAllCheckbox = new CheckBox("All", defaultSelectAll);
    selectAllCheckbox.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            boolean val = selectAllCheckbox.getValue();
            for (FollowerCheckbox followerCheckbox : memberSelections) {
                followerCheckbox.setValue(val);
            }
        }
    });
    container.addComponent(selectAllCheckbox);
    for (SimpleUser user : members) {
        final FollowerCheckbox memberCheckbox = new FollowerCheckbox(user);
        memberCheckbox.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                if (!memberCheckbox.getValue()) {
                    selectAllCheckbox.setValue(false);
                }
            }
        });
        if (defaultSelectAll || selectedUsers.contains(user.getUsername())) {
            memberCheckbox.setValue(true);
        }
        memberSelections.add(memberCheckbox);
        container.addComponent(memberCheckbox);
    }
    return container;
}

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

License:Open Source License

PredecessorWindow(final GanttTreeTable taskTreeTable, final GanttItemWrapper ganttItemWrapper) {
    super("Edit predecessors");
    this.setModal(true);
    this.setResizable(false);
    this.setWidth("650px");
    this.center();
    this.taskTreeTable = taskTreeTable;
    this.ganttItemWrapper = ganttItemWrapper;

    MVerticalLayout content = new MVerticalLayout();
    this.setContent(content);
    Label headerLbl = new Label(
            String.format("Row %d: %s", ganttItemWrapper.getGanttIndex(), ganttItemWrapper.getName()));
    headerLbl.addStyleName(ValoTheme.LABEL_H2);
    content.add(headerLbl);/*from   w  w  w  . j  a v a 2s. co  m*/

    CssLayout preWrapper = new CssLayout();
    content.with(preWrapper);

    MHorizontalLayout headerLayout = new MHorizontalLayout();
    headerLayout.addComponent(new ELabel("Row").withWidth(ROW_WDITH));
    headerLayout.addComponent(new ELabel("Task").withWidth(TASK_WIDTH));
    headerLayout.addComponent(new ELabel("Dependency").withWidth(PRE_TYPE_WIDTH));
    headerLayout.addComponent(new ELabel("Lag").withWidth(LAG_WIDTH));
    predecessorsLayout = new PredecessorsLayout();
    new Restrain(predecessorsLayout).setMaxHeight("600px");

    preWrapper.addComponent(headerLayout);
    preWrapper.addComponent(predecessorsLayout);

    MHorizontalLayout buttonControls = new MHorizontalLayout();
    content.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    PredecessorWindow.this.close();
                }
            });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);

    Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            List<TaskPredecessor> predecessors = predecessorsLayout.buildPredecessors();
            EventBusFactory.getInstance()
                    .post(new GanttEvent.ModifyPredecessors(ganttItemWrapper, predecessors));
            PredecessorWindow.this.close();
        }
    });
    saveBtn.addStyleName(UIConstants.BUTTON_ACTION);
    buttonControls.with(cancelBtn, saveBtn);
}

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

License:Open Source License

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

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

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

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

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

License:Open Source License

private void displayReport() {
    final String reportName = reportDashboard[currentReportIndex];

    final CssLayout bodyContent = (CssLayout) this.bodyContent;
    bodyContent.removeAllComponents();/*from w w  w . j  av  a  2s.  c om*/

    if ("BugsByPriority".equals(reportName)) {
        this.setTitle(AppContext.getMessage(BugI18nEnum.WIDGET_CHART_PRIORIY_TITLE));
        IPrioritySummaryChartWidget prioritySummaryChartWidget = ViewManager
                .getCacheComponent(IPrioritySummaryChartWidget.class);
        bodyContent.addComponent(prioritySummaryChartWidget);

        final BugSearchCriteria prioritySearchCriteria = new Cloner().deepClone(baseSearchCriteria);
        prioritySummaryChartWidget.setSearchCriteria(prioritySearchCriteria);
    } else if ("BugsByStatus".equals(reportName)) {
        this.setTitle(AppContext.getMessage(BugI18nEnum.WIDGET_CHART_STATUS_TITLE));
        IStatusSummaryChartWidget statusSummaryChartWidget = ViewManager
                .getCacheComponent(IStatusSummaryChartWidget.class);
        bodyContent.addComponent(statusSummaryChartWidget);

        final BugSearchCriteria statusSearchCriteria = new Cloner().deepClone(baseSearchCriteria);
        statusSummaryChartWidget.setSearchCriteria(statusSearchCriteria);
    } else if ("BugByResolution".equals(reportName)) {
        this.setTitle(AppContext.getMessage(BugI18nEnum.WIDGET_CHART_RESOLUTION_TITLE));
        IBugResolutionSummaryChartWidget resolutionSummaryWdiget = ViewManager
                .getCacheComponent(IBugResolutionSummaryChartWidget.class);
        bodyContent.addComponent(resolutionSummaryWdiget);

        final BugSearchCriteria statusSearchCriteria = new Cloner().deepClone(baseSearchCriteria);
        resolutionSummaryWdiget.setSearchCriteria(statusSearchCriteria);
    }
}

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

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");

    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);//  w  ww . ja v  a2  s.  c  o  m
    layoutWrapper.addStyleName(UIConstants.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);

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

    this.tableActionControls = new DefaultMassItemActionHandlersContainer();
    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.COMPONENTS)) {
        tableActionControls.addActionItem(MassItemActionHandler.DELETE_ACTION, FontAwesome.TRASH_O, "delete",
                AppContext.getMessage(GenericI18Enum.BUTTON_DELETE));
    }

    tableActionControls.addActionItem(MassItemActionHandler.MAIL_ACTION, FontAwesome.ENVELOPE_O, "mail",
            AppContext.getMessage(GenericI18Enum.BUTTON_MAIL));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_PDF_ACTION, FontAwesome.FILE_PDF_O,
            "export", "export.pdf", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_EXCEL_ACTION,
            FontAwesome.FILE_EXCEL_O, "export", "export.xlsx",
            AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_EXCEL));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_CSV_ACTION, FontAwesome.FILE_TEXT_O,
            "export", "export.csv", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_CSV));

    layout.addComponent(this.tableActionControls);
    layout.addComponent(this.selectedItemsNumberLabel);
    layout.setComponentAlignment(this.selectedItemsNumberLabel, Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

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

License:Open Source License

public BugRowComponent(final SimpleBug bug) {
    this.bug = bug;
    withSpacing(true).withMargin(false).withFullWidth().addStyleName(UIConstants.BORDER_LIST_ROW);

    bugSettingPopupBtn = new PopupButton();
    bugSettingPopupBtn.setIcon(FontAwesome.COGS);
    bugSettingPopupBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
    OptionPopupContent filterBtnLayout = createPopupContent();
    bugSettingPopupBtn.setContent(filterBtnLayout);

    final ToggleBugSummaryField bugWrapper = new ToggleBugSummaryField(bug);

    BugPopupFieldFactory popupFieldFactory = ViewManager.getCacheComponent(BugPopupFieldFactory.class);
    MHorizontalLayout headerLayout = new MHorizontalLayout().withFullWidth()
            .withMargin(new MarginInfo(false, true, false, false));
    Component priorityField = popupFieldFactory.createPriorityPopupField(bug);
    Component assigneeField = popupFieldFactory.createAssigneePopupField(bug);
    headerLayout.with(bugSettingPopupBtn, priorityField, assigneeField, bugWrapper).expand(bugWrapper);

    CssLayout footer = new CssLayout();

    Component commentsField = popupFieldFactory.createCommentsPopupField(bug);
    footer.addComponent(commentsField);

    Component followerField = popupFieldFactory.createFollowersPopupField(bug);
    footer.addComponent(followerField);/*w  ww  .j a  v  a 2 s  .  c  o  m*/

    Component statusField = popupFieldFactory.createStatusPopupField(bug);
    footer.addComponent(statusField);

    Component milestoneField = popupFieldFactory.createMilestonePopupField(bug);
    footer.addComponent(milestoneField);

    String deadlineTooltip = String.format("%s: %s", AppContext.getMessage(GenericI18Enum.FORM_DUE_DATE),
            AppContext.formatDate(bug.getDuedate()));
    AbstractComponent deadlineField = popupFieldFactory.createDeadlinePopupField(bug);
    deadlineField.setDescription(deadlineTooltip);
    footer.addComponent(deadlineField);

    Component startDateField = popupFieldFactory.createStartDatePopupField(bug);
    footer.addComponent(startDateField);

    Component endDateField = popupFieldFactory.createEndDatePopupField(bug);
    footer.addComponent(endDateField);

    if (!SiteConfiguration.isCommunityEdition()) {
        Component billableHoursView = popupFieldFactory.createBillableHoursPopupField(bug);
        footer.addComponent(billableHoursView);

        Component nonBillableHoursView = popupFieldFactory.createNonbillableHoursPopupField(bug);
        footer.addComponent(nonBillableHoursView);
    }

    this.with(headerLayout, footer);
}

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

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);/*w  w w .  j  a v  a2  s. com*/
    layoutWrapper.addStyleName(UIConstants.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);

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

    tableActionControls = new DefaultMassItemActionHandlersContainer();

    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.VERSIONS)) {
        tableActionControls.addActionItem(MassItemActionHandler.DELETE_ACTION, FontAwesome.TRASH_O, "delete",
                AppContext.getMessage(GenericI18Enum.BUTTON_DELETE));
    }

    tableActionControls.addActionItem(MassItemActionHandler.MAIL_ACTION, FontAwesome.ENVELOPE_O, "mail",
            AppContext.getMessage(GenericI18Enum.BUTTON_MAIL));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_PDF_ACTION, FontAwesome.FILE_PDF_O,
            "export", "export.pdf", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_EXCEL_ACTION,
            FontAwesome.FILE_EXCEL_O, "export", "export.xlsx",
            AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_EXCEL));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_CSV_ACTION, FontAwesome.FILE_TEXT_O,
            "export", "export.csv", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_CSV));

    layout.addComponent(this.tableActionControls);
    layout.addComponent(this.selectedItemsNumberLabel);
    layout.setComponentAlignment(this.selectedItemsNumberLabel, Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}