]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add Table-compatible constructors to Grid (#15447)
authorLeif Åstrand <leif@vaadin.com>
Wed, 31 Dec 2014 08:56:20 +0000 (10:56 +0200)
committerVaadin Code Review <review@vaadin.com>
Wed, 31 Dec 2014 10:41:08 +0000 (10:41 +0000)
Change-Id: I894a03a29e6ac15e0fa7e586f2a667934a1e8c1e

server/src/com/vaadin/ui/Grid.java

index 7d8ec5953320384d3ea2bbd748a36eb30b92f0fd..3d203296d79a1f1841de7203db942df0ea448a1b 100644 (file)
@@ -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();
     }