|
@@ -15,95 +15,105 @@ |
15 |
15 |
|
*/ |
16 |
16 |
|
package com.google.gwt.gen2.table.client.property; |
17 |
17 |
|
|
18 |
|
- |
import java.util.HashMap; |
19 |
|
- |
import java.util.Map; |
|
18 |
+ |
import java.util.*; |
20 |
19 |
|
|
21 |
20 |
|
/** |
22 |
21 |
|
* Base class that allows for headers or footers on a column. The 0th index |
23 |
22 |
|
* should always refer to the row closest to the data table. |
24 |
23 |
|
*/ |
25 |
|
- |
class HeaderPropertyBase extends ColumnProperty { |
26 |
|
- |
private int headerCount; |
27 |
|
- |
private Map<Integer, Object> headers = new HashMap<Integer, Object>(); |
28 |
|
- |
private boolean isDynamic; |
29 |
|
- |
|
30 |
|
- |
/** |
31 |
|
- |
* If the headers are dymanic, they will be re-rendered on every page load. |
32 |
|
- |
* Set this to true if your headers depend on the data. |
33 |
|
- |
* |
34 |
|
- |
* @return true if the headers are dynamic. |
35 |
|
- |
*/ |
36 |
|
- |
public boolean isDynamic() { |
37 |
|
- |
return isDynamic; |
38 |
|
- |
} |
39 |
|
- |
|
40 |
|
- |
/** |
41 |
|
- |
* Set whether or not the headers are dynamically generated and should be |
42 |
|
- |
* refreshed on every page load. |
43 |
|
- |
* |
44 |
|
- |
* @param isDynamic true if the headers are dynamic |
45 |
|
- |
*/ |
46 |
|
- |
public void setDynamic(boolean isDynamic) { |
47 |
|
- |
this.isDynamic = isDynamic; |
48 |
|
- |
} |
49 |
|
- |
|
50 |
|
- |
/** |
51 |
|
- |
* Get the header at the given row index. |
52 |
|
- |
* |
53 |
|
- |
* @param row the row index from the bottom |
54 |
|
- |
* @return the header for the given row |
55 |
|
- |
*/ |
56 |
|
- |
Object getHeader(int row) { |
57 |
|
- |
return headers.get(new Integer(row)); |
58 |
|
- |
} |
59 |
|
- |
|
60 |
|
- |
/** |
61 |
|
- |
* Get the header at the given row and column index. Override this method if |
62 |
|
- |
* your header includes dynamic content that depends on the column index. |
63 |
|
- |
* |
64 |
|
- |
* @param row the row index from the bottom |
65 |
|
- |
* @param column the column index at runtime |
66 |
|
- |
* @return the header for the given row |
67 |
|
- |
*/ |
68 |
|
- |
Object getHeader(int row, int column) { |
69 |
|
- |
return getHeader(row); |
70 |
|
- |
} |
71 |
|
- |
|
72 |
|
- |
/** |
73 |
|
- |
* @return get the number of headers above the column |
74 |
|
- |
*/ |
75 |
|
- |
int getHeaderCount() { |
76 |
|
- |
return headerCount; |
77 |
|
- |
} |
78 |
|
- |
|
79 |
|
- |
/** |
80 |
|
- |
* Remove the header above this column for the specified row. |
81 |
|
- |
* |
82 |
|
- |
* @param row the row index from the bottom |
83 |
|
- |
*/ |
84 |
|
- |
void removeHeader(int row) { |
85 |
|
- |
headers.remove(new Integer(row)); |
86 |
|
- |
} |
87 |
|
- |
|
88 |
|
- |
/** |
89 |
|
- |
* Set the header above this column. The row index starts with the bottom row, |
90 |
|
- |
* which is reverse of a normal table. The headerCount will automatically be |
91 |
|
- |
* increased to accommodate the row. |
92 |
|
- |
* |
93 |
|
- |
* @param row the row index from the bottom |
94 |
|
- |
* @param header the header |
95 |
|
- |
*/ |
96 |
|
- |
void setHeader(int row, Object header) { |
97 |
|
- |
headers.put(new Integer(row), header); |
98 |
|
- |
headerCount = Math.max(headerCount, row + 1); |
99 |
|
- |
} |
100 |
|
- |
|
101 |
|
- |
/** |
102 |
|
- |
* Set the number of headers above the column. |
103 |
|
- |
* |
104 |
|
- |
* @param headerCount the number of headers |
105 |
|
- |
*/ |
106 |
|
- |
void setHeaderCount(int headerCount) { |
107 |
|
- |
this.headerCount = headerCount; |
108 |
|
- |
} |
|
24 |
+ |
class HeaderPropertyBase extends ColumnProperty |
|
25 |
+ |
{ |
|
26 |
+ |
private int headerCount; |
|
27 |
+ |
private Map<Integer, Object> headers = new HashMap<Integer, Object>(); |
|
28 |
+ |
private boolean isDynamic; |
|
29 |
+ |
|
|
30 |
+ |
/** |
|
31 |
+ |
* If the headers are dymanic, they will be re-rendered on every page load. |
|
32 |
+ |
* Set this to true if your headers depend on the data. |
|
33 |
+ |
* |
|
34 |
+ |
* @return true if the headers are dynamic. |
|
35 |
+ |
*/ |
|
36 |
+ |
public boolean isDynamic() |
|
37 |
+ |
{ |
|
38 |
+ |
return isDynamic; |
|
39 |
+ |
} |
|
40 |
+ |
|
|
41 |
+ |
/** |
|
42 |
+ |
* Set whether or not the headers are dynamically generated and should be |
|
43 |
+ |
* refreshed on every page load. |
|
44 |
+ |
* |
|
45 |
+ |
* @param isDynamic true if the headers are dynamic |
|
46 |
+ |
*/ |
|
47 |
+ |
public void setDynamic( boolean isDynamic ) |
|
48 |
+ |
{ |
|
49 |
+ |
this.isDynamic = isDynamic; |
|
50 |
+ |
} |
|
51 |
+ |
|
|
52 |
+ |
/** |
|
53 |
+ |
* Get the header at the given row index. |
|
54 |
+ |
* |
|
55 |
+ |
* @param row the row index from the bottom |
|
56 |
+ |
* |
|
57 |
+ |
* @return the header for the given row |
|
58 |
+ |
*/ |
|
59 |
+ |
Object getHeader( int row ) |
|
60 |
+ |
{ |
|
61 |
+ |
return headers.get( new Integer( row ) ); |
|
62 |
+ |
} |
|
63 |
+ |
|
|
64 |
+ |
/** |
|
65 |
+ |
* Get the header at the given row and column index. Override this method if |
|
66 |
+ |
* your header includes dynamic content that depends on the column index. |
|
67 |
+ |
* |
|
68 |
+ |
* @param row the row index from the bottom |
|
69 |
+ |
* @param column the column index at runtime |
|
70 |
+ |
* |
|
71 |
+ |
* @return the header for the given row |
|
72 |
+ |
*/ |
|
73 |
+ |
Object getHeader( int row, int column ) |
|
74 |
+ |
{ |
|
75 |
+ |
return getHeader( row ); |
|
76 |
+ |
} |
|
77 |
+ |
|
|
78 |
+ |
/** |
|
79 |
+ |
* @return get the number of headers above the column |
|
80 |
+ |
*/ |
|
81 |
+ |
int getHeaderCount() |
|
82 |
+ |
{ |
|
83 |
+ |
return headerCount; |
|
84 |
+ |
} |
|
85 |
+ |
|
|
86 |
+ |
/** |
|
87 |
+ |
* Remove the header above this column for the specified row. |
|
88 |
+ |
* |
|
89 |
+ |
* @param row the row index from the bottom |
|
90 |
+ |
*/ |
|
91 |
+ |
void removeHeader( int row ) |
|
92 |
+ |
{ |
|
93 |
+ |
headers.remove( new Integer( row ) ); |
|
94 |
+ |
} |
|
95 |
+ |
|
|
96 |
+ |
/** |
|
97 |
+ |
* Set the header above this column. The row index starts with the bottom row, |
|
98 |
+ |
* which is reverse of a normal table. The headerCount will automatically be |
|
99 |
+ |
* increased to accommodate the row. |
|
100 |
+ |
* |
|
101 |
+ |
* @param row the row index from the bottom |
|
102 |
+ |
* @param header the header |
|
103 |
+ |
*/ |
|
104 |
+ |
void setHeader( int row, Object header ) |
|
105 |
+ |
{ |
|
106 |
+ |
headers.put( new Integer( row ), header ); |
|
107 |
+ |
headerCount = Math.max( headerCount, row + 1 ); |
|
108 |
+ |
} |
|
109 |
+ |
|
|
110 |
+ |
/** |
|
111 |
+ |
* Set the number of headers above the column. |
|
112 |
+ |
* |
|
113 |
+ |
* @param headerCount the number of headers |
|
114 |
+ |
*/ |
|
115 |
+ |
void setHeaderCount( int headerCount ) |
|
116 |
+ |
{ |
|
117 |
+ |
this.headerCount = headerCount; |
|
118 |
+ |
} |
109 |
119 |
|
} |