diff options
author | elmot <elmot@vaadin.com> | 2016-11-23 12:30:54 +0200 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2016-11-29 12:09:55 +0000 |
commit | 5eaac7ac6e18f9eda7e083617cf07dd631924e0c (patch) | |
tree | 46a8cfadbaa75bbf567556f773f809ea2e89d164 /client | |
parent | 5ab990325f370d767a5ad76b016a852fb2b5330c (diff) | |
download | vaadin-framework-5eaac7ac6e18f9eda7e083617cf07dd631924e0c.tar.gz vaadin-framework-5eaac7ac6e18f9eda7e083617cf07dd631924e0c.zip |
Grid merging footer cells
Change-Id: I24895c7ae602ffc9a7812dcc441e99ac670356e2
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java | 61 |
1 files changed, 18 insertions, 43 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java index 617a0480ba..bcae476cf3 100644 --- a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java @@ -232,22 +232,26 @@ public class GridConnector extends AbstractListingConnector grid.setDefaultHeaderRow(row); } - rowState.cells.forEach((columnId, cellState) -> { - updateHeaderCellFromState(row.getCell(getColumn(columnId)), - cellState); - }); - for (Map.Entry<CellState, Set<String>> cellGroupEntry : rowState.cellGroups.entrySet()) { - Set<String> group = cellGroupEntry.getValue(); - - Grid.Column<?, ?>[] columns = - group.stream().map(idToColumn::get).toArray(size->new Grid.Column<?, ?>[size]); - // Set state to be the same as first in group. - updateHeaderCellFromState(row.join(columns), cellGroupEntry.getKey()); - } + updateStaticRow(rowState, row); + } + } + + private void updateStaticRow(RowState rowState, Grid.StaticSection.StaticRow row) { + rowState.cells.forEach((columnId, cellState) -> { + updateStaticCellFromState(row.getCell(getColumn(columnId)), + cellState); + }); + for (Map.Entry<CellState, Set<String>> cellGroupEntry : rowState.cellGroups.entrySet()) { + Set<String> group = cellGroupEntry.getValue(); + + Grid.Column<?, ?>[] columns = + group.stream().map(idToColumn::get).toArray(size->new Grid.Column<?, ?>[size]); + // Set state to be the same as first in group. + updateStaticCellFromState(row.join(columns), cellGroupEntry.getKey()); } } - private void updateHeaderCellFromState(HeaderCell cell, + private void updateStaticCellFromState(Grid.StaticSection.StaticCell cell, CellState cellState) { switch (cellState.type) { case TEXT: @@ -288,39 +292,10 @@ public class GridConnector extends AbstractListingConnector for (RowState rowState : state.rows) { FooterRow row = grid.appendFooterRow(); - rowState.cells.forEach((columnId, cellState) -> { - updateFooterCellFromState(row.getCell(getColumn(columnId)), - cellState); - }); + updateStaticRow(rowState, row); } } - private void updateFooterCellFromState(FooterCell cell, - CellState cellState) { - switch (cellState.type) { - case TEXT: - cell.setText(cellState.text); - break; - case HTML: - cell.setHtml(cellState.html); - break; - case WIDGET: - ComponentConnector connector = (ComponentConnector) cellState.connector; - if (connector != null) { - cell.setWidget(connector.getWidget()); - } else { - // This happens if you do setVisible(false) on the component on - // the server side - cell.setWidget(null); - } - break; - default: - throw new IllegalStateException( - "unexpected cell type: " + cellState.type); - } - cell.setStyleName(cellState.styleName); - } - @Override public void setDataSource(DataSource<JsonObject> dataSource) { super.setDataSource(dataSource); |