Java 类com.vaadin.ui.components.grid.FooterRow 实例源码

项目:vaadin-grid-util    文件:DemoUI.java   
/**
 * generates a simple totalCount footer
 *
 * @param grid
 * @param items
 */
private void initFooterRow(final Grid<Inhabitants> grid, List<Inhabitants> items) {
    final FooterRow footerRow = grid.appendFooterRow();
    footerRow.getCell("id")
            .setHtml("total:");
    final FooterCell footerCell = footerRow.join("gender", "name", "bodySize", "birthday", "onFacebook", "country");
    // inital total count
    footerCell.setHtml("<b>" + items.size() + "</b>");

    // filter change count recalculate
    grid.getDataProvider().addDataProviderListener(event -> {
        List<Inhabitants> data = event.getSource()
                .fetch(new Query<>()).collect(Collectors.toList());
        footerCell.setHtml("<b>" + data.size() + "</b>");
    });
}
项目:vaadin-excel-exporter    文件:ExportToExcel.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
private int addHeaderFooterRow(Sheet sheet, int rowNum,
        final ExportExcelComponentConfiguration<BEANTYPE> componentConfiguration,
        AbstractComponentHeaderFooterConfiguration headerFooterConfig) {
    int tmpRowNum = rowNum;

    Row myRow = sheet.createRow(tmpRowNum);

    int startMerge = -999;
    for (int columns = 0; columns < componentConfiguration.getVisibleProperties().length; columns++) {
        Cell myCell = myRow.createCell(columns, XSSFCell.CELL_TYPE_STRING);
        String columnId = componentConfiguration.getVisibleProperties()[columns];
        if (headerFooterConfig.getMergedCells() != null) {
            startMerge = addMergedCell( sheet, tmpRowNum, componentConfiguration, headerFooterConfig, startMerge,
                                        columns, myCell);
        } else if (headerFooterConfig.getRow() != null) {
            if (headerFooterConfig.getRow() instanceof HeaderRow) {
                ExcelStyleUtil.addGenericGridHeaderRow( ((HeaderRow) headerFooterConfig.getRow()).getCell(columnId),
                                                        myCell);
            } else if (headerFooterConfig.getRow() instanceof FooterRow) {
                ExcelStyleUtil.addGenericGridFooterRow( ((FooterRow) headerFooterConfig.getRow()).getCell(columnId),
                                                        myCell);
            }
        } else if (headerFooterConfig.getColumnKeys() != null) {
            myCell.setCellValue(headerFooterConfig.getColumnKeys()[columns]);
        }
        myCell.setCellStyle(componentConfiguration.getHeaderStyleFunction()
            .apply(this.workbook, columnId));
    }

    if (headerFooterConfig instanceof ComponentHeaderConfiguration
            && ((ComponentHeaderConfiguration) headerFooterConfig).isAutoFilter()) {
        sheet.setAutoFilter(new CellRangeAddress(tmpRowNum, tmpRowNum, 0,
                componentConfiguration.getVisibleProperties().length - 1));
    }

    tmpRowNum++;
    return tmpRowNum;
}
项目:holon-vaadin    文件:AbstractGridItemListingBuilder.java   
public FooterRowWrapper(FooterRow row, Function<P, String> converter) {
    super();
    this.row = row;
    this.converter = converter;
}
项目:vaadin-excel-exporter    文件:DemoUI.java   
@Override
protected void init(final VaadinRequest request) {

    // Creating the Export Tool Bar
    MenuBar exportToolBar = createToolBar();

    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();

    // Adding the Export Tool Bar to the Layout
    layout.addComponent(exportToolBar);

    /*********
     * Adding Components to the Layout namely Tables, Grids and Tree Table
     *******/
    this.gridDefault = new Grid<>(DataModel.class);
    this.gridDefault.setDataProvider(new ListDataProvider<>(DataModelGenerator.generate(20)));
    this.gridDefault.setSizeFull();
    this.gridDefault.setColumns(this.visibleColumns);

    this.gridMergedCells = new Grid<>(DataModel.class);
    this.gridMergedCells.setDataProvider(new ListDataProvider<>(DataModelGenerator.generate(20)));
    this.gridMergedCells.setColumns(this.visibleColumns);
    this.gridMergedCells.setSizeFull();
    HeaderRow headerRow = this.gridMergedCells.addHeaderRowAt(0);
    HeaderCell joinHeaderColumns1 = headerRow.join("country", "productType");
    joinHeaderColumns1.setText("mergedCell");
    HeaderCell joinHeaderColumns2 = headerRow.join("cheapest", "contractor");
    joinHeaderColumns2.setText("mergedCell");
    FooterRow footerRow1 = this.gridMergedCells.addFooterRowAt(0);
    FooterCell joinFooterColumns1 = footerRow1.join("country", "productType");
    joinFooterColumns1.setText("mergedCell");
    FooterCell joinFooterColumns2 = footerRow1.join("cheapest", "contractor");
    joinFooterColumns2.setText("mergedCell");
    FooterRow footerRow2 = this.gridMergedCells.addFooterRowAt(0);
    for (int i = 0; i < this.visibleColumns.length; i++) {
        footerRow2.getCell(this.visibleColumns[i])
            .setText(this.columnHeaders[i]);
    }

    this.gridFrozenColumns = new Grid<>(DataModel.class);
    this.gridFrozenColumns.setDataProvider(new ListDataProvider<>(DataModelGenerator.generate(20)));
    this.gridFrozenColumns.setColumns(this.visibleColumns);
    this.gridFrozenColumns.getColumn("country")
        .setWidth(300);
    this.gridFrozenColumns.getColumn("productType")
        .setWidth(300);
    this.gridFrozenColumns.getColumn("catalogue")
        .setWidth(300);
    this.gridFrozenColumns.setSizeFull();
    this.gridFrozenColumns.setFrozenColumnCount(3);

    TabSheet tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    tabSheet.addTab(this.gridDefault, "Grid (Default)");
    tabSheet.addTab(this.gridMergedCells, "Grid (Merged Cells)");
    tabSheet.addTab(this.gridFrozenColumns, "Grid (Frozen Columns&Rows)");
    layout.addComponent(tabSheet);
    layout.setExpandRatio(tabSheet, 1);

    /*********
     * Adding Components to the Layout namely Tables, Grids and Tree Table
     *******/

    /*********
     * Adding the above data to the containers or components
     *******/

    setContent(layout);
}