1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
package com.temp.client.foundation.widget.dialog;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import com.temp.client.foundation.widget.table.CachedDataTable;
import com.temp.client.foundation.widget.table.DataRow;
import com.temp.client.foundation.widget.table.DataRowField;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.client.ui.Widget;
@SuppressWarnings("rawtypes")
public class DataTableDialogBox<R extends DataRow<F>,F> extends PopUpDialogBox {
private static final int DEFAULT_WIDTH_IN_PX = 700;
CachedDataTable<R,F> dataTable = new CachedDataTable<R,F>();
/**
* Adds a column
*
* @param fields
* - the column / "field" definitions
*/
public <FIELD extends DataRowField> void addColumns(FIELD... fields) {
dataTable.addColumns(fields);
}
/**
* Adds a column
*
* @param field
* - the column or "field" definition
*/
public <FIELD extends DataRowField> void addColumn(FIELD field) {
dataTable.addColumn(field);
}
/**
* Adds a column
*
* @param column
* - the column
* @param field
* - the column definition "field"
*/
public <FIELD extends DataRowField> void addColumn(Column<R, ?> column, FIELD field) {
dataTable.addColumn(column, field);
}
/**
* Adds a column
*
* @param field
* - the column or "field" definition
* @param comparator - the comparator
*/
public <FIELD extends DataRowField> void addColumn(FIELD field, Comparator comparator) {
dataTable.addColumn(field, comparator);
}
/**
* Adds a column
*
* @param column
* - the column
* @param field
* - the column definition "field"
* @param comparator - the comparator
*/
public <FIELD extends DataRowField> void addColumn(Column<R, ?> column, FIELD field, Comparator comparator) {
dataTable.addColumn(column, field, comparator);
}
public void addColumn(Column<R, ?> column, String columnHeader, String fieldName) {
dataTable.addColumn(column, columnHeader, fieldName);
}
public void addColumn(Column<R, ?> column, String columnHeader, String fieldName, int width, Unit widthUnit) {
dataTable.addColumn(column, columnHeader, fieldName, width, widthUnit);
}
public void addColumn(Column<R, ?> column, String columnHeader, String fieldName, Comparator comparator) {
dataTable.addColumn(column, columnHeader, fieldName, comparator);
}
public void addColumn(Column<R, ?> column, String columnHeader, String fieldName, Comparator comparator, int width, Unit widthUnit) {
dataTable.addColumn(column, columnHeader, fieldName, comparator, width, widthUnit);
}
public void show(String title, List<R> dataList) {
show(title, dataList, DEFAULT_WIDTH_IN_PX);
}
public void show(String title, List<R> dataList, Integer widthInPx) {
dataTable.setData(dataList);
if (widthInPx != null) {
dataTable.setWidth("" + widthInPx + "px");
}
List<Widget> contents = new ArrayList<Widget>();
contents.add(dataTable);
setContentsAndShow(title, contents);
}
}
|