Convert to gwt-maven project.
[online-glom:gwt-glom.git] / src / main / java / org / glom / web / client / LayoutList.java
1 package org.glom.web.client;
2
3 import com.google.gwt.user.cellview.client.CellTable;
4 import com.google.gwt.user.cellview.client.SimplePager;
5 import com.google.gwt.user.cellview.client.TextColumn;
6 import com.google.gwt.user.client.ui.Composite;
7 import com.google.gwt.user.client.ui.VerticalPanel;
8
9 public class LayoutList extends Composite {
10
11         private CellTable<String[]> table = null;
12
13         public LayoutList(String[] headers) {
14                 table = new CellTable<String[]>();
15                 LayoutListDataProvider dataProvider = new LayoutListDataProvider();
16                 dataProvider.addDataDisplay(table);
17
18                 // TODO wire up the pager
19                 SimplePager pager = new SimplePager(SimplePager.TextLocation.CENTER);
20                 pager.setDisplay(table);
21
22                 // a panel to hold our widgets
23                 VerticalPanel panel = new VerticalPanel();
24                 panel.add(table);
25                 panel.add(pager);
26
27                 for (int i = 0; i < headers.length; i++) {
28                         // create a new column
29                         final int j = new Integer(i);
30                         TextColumn<String[]> column = new TextColumn<String[]>() {
31                                 @Override
32                                 public String getValue(String[] object) {
33                                         return object[j];
34                                 }
35                         };
36
37                         // add the column to the list
38                         table.addColumn(column, headers[i]);
39
40                 }
41
42                 table.setRowCount(0);
43
44                 // take care of the necessary stuff required for composite widgets
45                 initWidget(panel);
46                 setStyleName("glom-ListLayoutTable");
47         }
48
49 }