diff options
author | Leif Åstrand <leif@vaadin.com> | 2014-12-31 10:56:20 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-31 10:41:08 +0000 |
commit | 68e50ff6371bbe68e19d9145e7dfa787a7f18e89 (patch) | |
tree | 73394bdfff9064cb9dc640266331040a3d362c34 | |
parent | ba0b15576c08074f1959100a3b7d81abc1efba8a (diff) | |
download | vaadin-framework-68e50ff6371bbe68e19d9145e7dfa787a7f18e89.tar.gz vaadin-framework-68e50ff6371bbe68e19d9145e7dfa787a7f18e89.zip |
Add Table-compatible constructors to Grid (#15447)
Change-Id: I894a03a29e6ac15e0fa7e586f2a667934a1e8c1e
-rw-r--r-- | server/src/com/vaadin/ui/Grid.java | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index 7d8ec59533..3d203296d7 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -2528,21 +2528,50 @@ public class Grid extends AbstractComponent implements SelectionNotifier, .findMethod(SortListener.class, "sort", SortEvent.class); /** - * Creates a new Grid with a new {@link IndexedContainer} as the datasource. + * Creates a new Grid with a new {@link IndexedContainer} as the data + * source. */ public Grid() { - internalSetContainerDataSource(new IndexedContainer()); - initGrid(); + this(null, null); } /** - * Creates a new Grid using the given datasource. + * Creates a new Grid using the given data source. * - * @param datasource - * the data source for the grid + * @param dataSource + * the indexed container to use as a data source */ - public Grid(final Container.Indexed datasource) { - setContainerDataSource(datasource); + public Grid(final Container.Indexed dataSource) { + this(null, dataSource); + } + + /** + * Creates a new Grid with the given caption and a new + * {@link IndexedContainer} data source. + * + * @param caption + * the caption of the grid + */ + public Grid(String caption) { + this(caption, null); + } + + /** + * Creates a new Grid with the given caption and data source. If the data + * source is null, a new {@link IndexedContainer} will be used. + * + * @param caption + * the caption of the grid + * @param dataSource + * the indexed container to use as a data source + */ + public Grid(String caption, Container.Indexed dataSource) { + if (dataSource == null) { + internalSetContainerDataSource(new IndexedContainer()); + } else { + setContainerDataSource(dataSource); + } + setCaption(caption); initGrid(); } |