Browse Source

Parameterize client-side Grid.addColumn to return the argument type (#16262)

This allows invoking custom methods on the return value.

Change-Id: I5f2749b792db3627b46e676aee82dc672fec7113
tags/7.4.0.beta3
Johannes Dahlström 9 years ago
parent
commit
7ddaaae384

+ 2
- 2
client/src/com/vaadin/client/widgets/Grid.java View File

* the column to add * the column to add
* @return given column * @return given column
*/ */
public Column<?, T> addColumn(Column<?, T> column) {
public <C extends Column<?, T>> C addColumn(C column) {
addColumn(column, getColumnCount()); addColumn(column, getColumnCount());
return column; return column;
} }
* if Grid's current selection model renders a selection column, * if Grid's current selection model renders a selection column,
* and {@code index} is 0. * and {@code index} is 0.
*/ */
public Column<?, T> addColumn(Column<?, T> column, int index) {
public <C extends Column<?, T>> C addColumn(C column, int index) {
if (column == selectionColumn) { if (column == selectionColumn) {
throw new IllegalArgumentException("The selection column many " throw new IllegalArgumentException("The selection column many "
+ "not be added manually"); + "not be added manually");

+ 1
- 1
uitest/src/com/vaadin/tests/widgetset/client/grid/GridColumnAutoWidthClientWidget.java View File

} }


private Col addColumn(String header) { private Col addColumn(String header) {
Col column = (Col) grid.addColumn(new Col(header));
Col column = grid.addColumn(new Col(header));
grid.getHeaderRow(0).getCell(column) grid.getHeaderRow(0).getCell(column)
.setHtml("<span>" + header + "</span>"); .setHtml("<span>" + header + "</span>");
return column; return column;

Loading…
Cancel
Save