Example usage for com.vaadin.ui VerticalLayout addComponent

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

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout 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.crm.view.SalesDashboardView.java

License:Open Source License

public void displayReport() {
    final String reportName = this.reportDashboard[this.currentReportIndex];

    final VerticalLayout bodyContent = (VerticalLayout) this.bodyContent;
    bodyContent.removeAllComponents();/* w ww.j ava 2  s.c  o m*/
    bodyContent.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    if ("OpportunitySalesStage".equals(reportName)) {
        this.setTitle("Opportunity Sales Stage");
        final IOpportunitySalesStageDashboard salesStageDashboard = ViewManager
                .getCacheComponent(IOpportunitySalesStageDashboard.class);
        bodyContent.addComponent(salesStageDashboard);

        final OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
        criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
        salesStageDashboard.setSearchCriteria(criteria);
    } else if ("OpportunityLeadSource".equals(reportName)) {
        this.setTitle("Opportunity Lead Source");
        final IOpportunityLeadSourceDashboard leadSourceDashboard = ViewManager
                .getCacheComponent(IOpportunityLeadSourceDashboard.class);
        bodyContent.addComponent(leadSourceDashboard);

        final OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
        criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
        leadSourceDashboard.setSearchCriteria(criteria);
    }
}

From source file:com.esofthead.mycollab.module.crm.view.SalesDashboardView.java

License:Open Source License

private void initUI() {
    final PopupButton saleChartPopup = new PopupButton("");
    saleChartPopup.addStyleName("popuplistindicator");

    final VerticalLayout filterBtnLayout = new VerticalLayout();
    filterBtnLayout.setMargin(true);//from  ww w.  j  a v  a2s. c om
    filterBtnLayout.setSpacing(true);
    filterBtnLayout.setWidth("200px");

    final Button btnOpportunitySales = new Button("Opportunity Sales Stage", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            saleChartPopup.setPopupVisible(false);
            SalesDashboardView.this.currentReportIndex = 0;
            SalesDashboardView.this.displayReport();
        }
    });
    btnOpportunitySales.setStyleName("link");
    filterBtnLayout.addComponent(btnOpportunitySales);

    final Button btnOpportunityLead = new Button("Opportunity Lead Source", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            saleChartPopup.setPopupVisible(false);
            SalesDashboardView.this.currentReportIndex = 1;
            SalesDashboardView.this.displayReport();
        }
    });
    btnOpportunityLead.setStyleName("link");
    filterBtnLayout.addComponent(btnOpportunityLead);

    this.displayReport();

    saleChartPopup.setContent(filterBtnLayout);
    this.addHeaderElement(saleChartPopup);
}

From source file:com.esofthead.mycollab.module.file.view.components.ResourcesDisplayComponent.java

License:Open Source License

public ResourcesDisplayComponent(final String rootPath, final Folder rootFolder) {
    this.setSpacing(true);
    this.baseFolder = rootFolder;
    this.rootPath = rootPath;
    externalResourceService = ApplicationContextUtil.getSpringBean(ExternalResourceService.class);
    externalDriveService = ApplicationContextUtil.getSpringBean(ExternalDriveService.class);
    resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    VerticalLayout mainBodyLayout = new VerticalLayout();
    mainBodyLayout.setSpacing(true);/*from   ww  w . j  av a  2s .  com*/
    mainBodyLayout.addStyleName("box-no-border-left");

    // file breadcrum ---------------------
    HorizontalLayout breadcrumbContainer = new HorizontalLayout();
    breadcrumbContainer.setMargin(false);
    fileBreadCrumb = new FileBreadcrumb(rootPath);
    breadcrumbContainer.addComponent(fileBreadCrumb);
    mainBodyLayout.addComponent(breadcrumbContainer);

    // Construct controllGroupBtn
    controllGroupBtn = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true));

    final Button selectAllBtn = new Button();
    selectAllBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    selectAllBtn.setIcon(FontAwesome.SQUARE_O);
    selectAllBtn.setData(false);
    selectAllBtn.setImmediate(true);
    selectAllBtn.setDescription("Select all");

    selectAllBtn.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (!(Boolean) selectAllBtn.getData()) {
                selectAllBtn.setIcon(FontAwesome.CHECK_SQUARE_O);
                selectAllBtn.setData(true);
                resourcesContainer.setAllValues(true);
            } else {
                selectAllBtn.setData(false);
                selectAllBtn.setIcon(FontAwesome.SQUARE_O);
                resourcesContainer.setAllValues(false);
            }
        }
    });
    controllGroupBtn.with(selectAllBtn).withAlign(selectAllBtn, Alignment.MIDDLE_LEFT);

    Button goUpBtn = new Button("Up");
    goUpBtn.setIcon(FontAwesome.ARROW_UP);

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

        @Override
        public void buttonClick(ClickEvent event) {
            Folder parentFolder;
            if (baseFolder instanceof ExternalFolder) {
                if (baseFolder.getPath().equals("/")) {
                    parentFolder = baseFolder;
                } else {
                    parentFolder = externalResourceService.getParentResourceFolder(
                            ((ExternalFolder) baseFolder).getExternalDrive(), baseFolder.getPath());
                }
            } else if (!baseFolder.getPath().equals(rootPath)) {
                parentFolder = resourceService.getParentFolder(baseFolder.getPath());
            } else {
                parentFolder = baseFolder;
            }

            resourcesContainer.constructBody(parentFolder);
            baseFolder = parentFolder;
            fileBreadCrumb.gotoFolder(baseFolder);
        }
    });
    goUpBtn.setDescription("Back to parent folder");
    goUpBtn.setStyleName(UIConstants.THEME_BROWN_LINK);
    goUpBtn.setDescription("Go up");

    controllGroupBtn.with(goUpBtn).withAlign(goUpBtn, Alignment.MIDDLE_LEFT);

    ButtonGroup navButton = new ButtonGroup();
    navButton.addStyleName(UIConstants.THEME_BROWN_LINK);
    Button createBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CREATE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    AddNewFolderWindow addnewFolderWindow = new AddNewFolderWindow();
                    UI.getCurrent().addWindow(addnewFolderWindow);
                }
            });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    createBtn.setDescription("Create new folder");
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(createBtn);

    Button uploadBtn = new Button("Upload", new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            MultiUploadContentWindow multiUploadWindow = new MultiUploadContentWindow();
            UI.getCurrent().addWindow(multiUploadWindow);
        }
    });
    uploadBtn.setIcon(FontAwesome.UPLOAD);
    uploadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    uploadBtn.setDescription("Upload");

    uploadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(uploadBtn);

    Button downloadBtn = new Button("Download");

    LazyStreamSource streamSource = new LazyStreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        protected StreamSource buildStreamSource() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getStreamSourceSupportExtDrive(selectedResources);
        }

        @Override
        public String getFilename() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getDownloadFileName(selectedResources);
        }
    };
    OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource);
    downloaderExt.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    downloadBtn.setDescription("Download");
    downloadBtn.setEnabled(AppContext.canRead(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(downloadBtn);

    Button moveToBtn = new Button("Move", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Collection<Resource> selectedResources = getSelectedResources();
            if (CollectionUtils.isNotEmpty(selectedResources)) {
                MoveResourceWindow moveResourceWindow = new MoveResourceWindow(selectedResources);
                UI.getCurrent().addWindow(moveResourceWindow);
            } else {
                NotificationUtil.showWarningNotification("Please select at least one item to move");
            }
        }
    });
    moveToBtn.setIcon(FontAwesome.ARROWS);
    moveToBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    moveToBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    moveToBtn.setDescription("Move to");
    navButton.addButton(moveToBtn);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    Collection<Resource> selectedResources = getSelectedResources();
                    if (CollectionUtils.isEmpty(selectedResources)) {
                        NotificationUtil.showWarningNotification("Please select at least one item to delete");
                    } else {
                        deleteResourceAction();
                    }
                }
            });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.THEME_RED_LINK);
    deleteBtn.setDescription("Delete resource");
    deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));

    navButton.addButton(deleteBtn);
    controllGroupBtn.addComponent(navButton);

    mainBodyLayout.addComponent(controllGroupBtn);

    resourcesContainer = new ResourcesContainer(baseFolder);

    mainBodyLayout.addComponent(resourcesContainer);
    this.addComponent(mainBodyLayout);
}

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

License:Open Source License

@Override
public ComponentContainer getLayout() {
    VerticalLayout layout = new VerticalLayout();
    int sectionCount = dynaForm.getSectionCount();
    sectionMappings = new HashMap<>();

    for (int i = 0; i < sectionCount; i++) {
        DynaSection section = dynaForm.getSection(i);
        if (section.isDeletedSection()) {
            continue;
        }/* w  w w.j a v  a2  s.  c  o m*/

        GridFormLayoutHelper gridLayout;

        if (section.isDeletedSection() || section.getFieldCount() == 0) {
            continue;
        }

        if (section.getLayoutType() == LayoutType.ONE_COLUMN) {
            gridLayout = new GridFormLayoutHelper(2, 1, "100%", "167px", Alignment.TOP_LEFT);

            for (int j = 0; j < section.getFieldCount(); j++) {
                AbstractDynaField dynaField = section.getField(j);
                if (!excludeFields.contains(dynaField.getFieldName())) {
                    gridLayout.buildCell(dynaField.getDisplayName(), 0, gridLayout.getRows() - 1, 2, "100%",
                            Alignment.TOP_LEFT);
                    if (j < section.getFieldCount() - 1) {
                        gridLayout.appendRow();
                    }
                }
            }
        } else if (section.getLayoutType() == LayoutType.TWO_COLUMN) {
            gridLayout = new GridFormLayoutHelper(2, 1, "100%", "167px", Alignment.TOP_LEFT);
            int columnIndex = 0;
            for (int j = 0; j < section.getFieldCount(); j++) {
                AbstractDynaField dynaField = section.getField(j);
                if (!excludeFields.contains(dynaField.getFieldName())) {
                    if (dynaField.isColSpan()) {
                        if (columnIndex > 0) {
                            gridLayout.appendRow();
                        }
                        LOG.debug("Build cell {}", new Object[] { dynaField.getDisplayName() });
                        gridLayout.buildCell(dynaField.getDisplayName(), 0, gridLayout.getRows() - 1, 2, "100%",
                                Alignment.TOP_LEFT);
                        columnIndex = 0;
                        if (j < section.getFieldCount() - 1) {
                            gridLayout.appendRow();
                        }
                    } else {
                        LOG.debug("Build cell {}", new Object[] { dynaField.getDisplayName() });
                        gridLayout.buildCell(dynaField.getDisplayName(), columnIndex, gridLayout.getRows() - 1);
                        columnIndex++;
                        if (columnIndex == 2) {
                            columnIndex = 0;
                            if (j < section.getFieldCount() - 1) {
                                gridLayout.appendRow();
                            }
                        }
                    }
                }
            }
        } else {
            throw new MyCollabException("Does not support attachForm layout except 1 or 2 columns");
        }

        gridLayout.getLayout().setWidth("100%");
        gridLayout.getLayout().setMargin(false);
        gridLayout.getLayout().setSpacing(false);
        gridLayout.getLayout().addStyleName("colored-gridlayout");
        layout.addComponent(gridLayout.getLayout());

        sectionMappings.put(section, gridLayout);
    }
    return layout;
}

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

License:Open Source License

private void constructSpentTimeEntryPanel() {
    VerticalLayout spentTimePanel = new VerticalLayout();
    spentTimePanel.setSpacing(true);//from w w w. jav a 2s .c  o  m
    headerPanel.addComponent(spentTimePanel);

    final VerticalLayout totalLayout = new VerticalLayout();
    totalLayout.setMargin(true);
    totalLayout.addStyleName("boxTotal");
    totalLayout.setWidth("100%");
    spentTimePanel.addComponent(totalLayout);
    final Label lbTimeInstructTotal = new Label(
            AppContext.getMessage(TimeTrackingI18nEnum.OPT_TOTAL_SPENT_HOURS));
    totalLayout.addComponent(lbTimeInstructTotal);
    this.totalSpentTimeLbl = new Label("_");
    this.totalSpentTimeLbl.addStyleName("numberTotal");
    totalLayout.addComponent(this.totalSpentTimeLbl);

    final MHorizontalLayout addLayout = new MHorizontalLayout();
    addLayout.setSizeUndefined();
    addLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    spentTimePanel.addComponent(addLayout);

    this.newTimeInputField = new NumericTextField();
    this.newTimeInputField.setWidth("80px");

    this.forDateField = new DateFieldExt();
    this.forDateField.setValue(new GregorianCalendar().getTime());

    this.isBillableField = new CheckBox(AppContext.getMessage(TimeTrackingI18nEnum.FORM_IS_BILLABLE), true);

    btnAdd = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD), new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            double d = 0;
            try {
                d = Double.parseDouble(newTimeInputField.getValue());
            } catch (NumberFormatException e) {
                NotificationUtil.showWarningNotification("You must enter a positive number value");
            }
            if (d > 0) {
                saveTimeInvest();
                loadTimeValue();
                newTimeInputField.setValue("0.0");
            }
        }

    });

    btnAdd.setEnabled(TimeLogEditWindow.this.isEnableAdd());
    btnAdd.setStyleName(UIConstants.THEME_GREEN_LINK);
    btnAdd.setIcon(FontAwesome.PLUS);
    addLayout.with(this.newTimeInputField, this.forDateField, this.isBillableField, btnAdd);
}

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

License:Open Source License

private void constructRemainTimeEntryPanel() {
    VerticalLayout remainTimePanel = new VerticalLayout();
    remainTimePanel.setSpacing(true);//from  w ww  . j a va 2 s  .co  m
    this.headerPanel.addComponent(remainTimePanel);

    final VerticalLayout updateLayout = new VerticalLayout();
    updateLayout.setMargin(true);
    updateLayout.addStyleName("boxTotal");
    updateLayout.setWidth("100%");
    remainTimePanel.addComponent(updateLayout);

    final Label lbTimeInstructTotal = new Label(
            AppContext.getMessage(TimeTrackingI18nEnum.OPT_REMAINING_WORK_HOURS));
    updateLayout.addComponent(lbTimeInstructTotal);
    this.remainTimeLbl = new Label("_");
    this.remainTimeLbl.addStyleName("numberTotal");
    updateLayout.addComponent(this.remainTimeLbl);

    final MHorizontalLayout addLayout = new MHorizontalLayout();
    addLayout.setSizeUndefined();
    remainTimePanel.addComponent(addLayout);

    this.remainTimeInputField = new NumericTextField();
    this.remainTimeInputField.setWidth("80px");
    addLayout.addComponent(this.remainTimeInputField);
    addLayout.setComponentAlignment(this.remainTimeInputField, Alignment.MIDDLE_LEFT);

    btnAdd = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_UPDATE_LABEL), new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {

            try {
                double d = 0;
                try {
                    d = Double.parseDouble(remainTimeInputField.getValue());
                } catch (Exception e) {
                    NotificationUtil.showWarningNotification("You must enter a positive number value");
                }
                if (d >= 0) {
                    updateTimeRemain();
                    remainTimeLbl.setValue(remainTimeInputField.getValue());
                    remainTimeInputField.setValue("0.0");
                }
            } catch (final Exception e) {
                remainTimeInputField.setValue("0.0");
            }
        }

    });

    btnAdd.setEnabled(TimeLogEditWindow.this.isEnableAdd());
    btnAdd.setStyleName(UIConstants.THEME_GREEN_LINK);
    addLayout.addComponent(btnAdd);
    addLayout.setComponentAlignment(btnAdd, Alignment.MIDDLE_LEFT);
}

From source file:com.esofthead.mycollab.module.project.ui.form.ProjectFormAttachmentUploadField.java

License:Open Source License

@Override
protected Component initContent() {
    final VerticalLayout layout = new VerticalLayout();
    uploadExt = new MultiFileUploadExt(attachmentPanel);
    uploadExt.addComponent(attachmentPanel);
    layout.addComponent(uploadExt);
    return layout;
}

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

License:Open Source License

AssignBugWindow(final IBugCallbackStatusComp callbackForm, final SimpleBug bug) {
    super("Assign bug '" + bug.getSummary() + "'");
    this.setWidth("750px");
    this.setResizable(false);
    this.setModal(true);

    this.bug = bug;
    this.callbackForm = callbackForm;

    VerticalLayout contentLayout = new VerticalLayout();

    EditForm editForm = new EditForm();
    contentLayout.addComponent(editForm);
    editForm.setBean(bug);//  w w w .  ja v  a 2  s . c o m
    contentLayout.setMargin(new MarginInfo(false, false, true, false));

    this.setContent(contentLayout);
    this.center();
}

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

License:Open Source License

@Override
public Layout getLayout() {
    final VerticalLayout layout = new VerticalLayout();

    this.informationLayout = new GridFormLayoutHelper(2, 9, "100%", "167px", Alignment.TOP_LEFT);
    this.informationLayout.getLayout().setWidth("100%");
    this.informationLayout.getLayout().setMargin(false);
    this.informationLayout.getLayout().addStyleName("colored-gridlayout");
    layout.addComponent(this.informationLayout.getLayout());
    layout.setComponentAlignment(this.informationLayout.getLayout(), Alignment.BOTTOM_CENTER);

    return layout;
}

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

License:Open Source License

private void initHeader() {
    final Label title = new ProjectViewHeader(ProjectTypeConstants.BUG,
            AppContext.getMessage(BugI18nEnum.VIEW_BUG_DASHBOARD_TITLE));
    header.with(title).withAlign(title, Alignment.MIDDLE_LEFT).expand(title);

    final Button createBugBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_BUG),
            new Button.ClickListener() {
                @Override//  w  w  w  . j av a  2  s .  c  om
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new BugEvent.GotoAdd(this, null));
                }
            });
    createBugBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));
    createBugBtn.setIcon(FontAwesome.PLUS);
    final SplitButton controlsBtn = new SplitButton(createBugBtn);
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setWidthUndefined();

    final VerticalLayout btnControlsLayout = new VerticalLayout();
    final Button createComponentBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_COMPONENT),
            new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    controlsBtn.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new BugComponentEvent.GotoAdd(this, null));
                }
            });
    createComponentBtn.setStyleName("link");
    createComponentBtn
            .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS));
    btnControlsLayout.addComponent(createComponentBtn);

    final Button createVersionBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_VERSION),
            new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    controlsBtn.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null));
                }
            });
    createVersionBtn.setStyleName("link");
    createVersionBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS));
    btnControlsLayout.addComponent(createVersionBtn);

    controlsBtn.setContent(btnControlsLayout);
    header.addComponent(controlsBtn);
}