Skip to content

Commit

Permalink
Parameterize client-side Grid.addColumn to return the argument type (…
Browse files Browse the repository at this point in the history
…#16262)

This allows invoking custom methods on the return value.

Change-Id: I5f2749b792db3627b46e676aee82dc672fec7113
  • Loading branch information
jdahlstrom authored and Vaadin Code Review committed Jan 19, 2015
1 parent 94ea98c commit 7ddaaae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions client/src/com/vaadin/client/widgets/Grid.java
Expand Up @@ -3674,7 +3674,7 @@ public void addColumns(Column<?, T>... columns) {
* 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;
} }
Expand All @@ -3692,7 +3692,7 @@ public Column<?, T> addColumn(Column<?, T> 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");
Expand Down
Expand Up @@ -63,7 +63,7 @@ public GridColumnAutoWidthClientWidget() {
} }


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;
Expand Down

0 comments on commit 7ddaaae

Please sign in to comment.