|
@@ -15,27 +15,25 @@ |
15 |
15 |
|
*/ |
16 |
16 |
|
package com.google.gwt.gen2.table.client; |
17 |
17 |
|
|
18 |
|
- |
import java.util.*; |
19 |
|
- |
|
20 |
18 |
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment.*; |
21 |
19 |
|
import com.google.gwt.user.client.ui.HasVerticalAlignment.*; |
22 |
20 |
|
import com.google.gwt.user.client.ui.*; |
23 |
21 |
|
|
|
22 |
+ |
import java.util.*; |
|
23 |
+ |
|
24 |
24 |
|
/** |
25 |
25 |
|
* A collection of {@link ColumnDefinition ColumnDefinitions} that define a |
26 |
26 |
|
* table. |
27 |
27 |
|
* |
28 |
28 |
|
* @param <RowType> the type of the row values |
29 |
29 |
|
*/ |
30 |
|
- |
public interface TableDefinition<RowType> |
31 |
|
- |
{ |
|
30 |
+ |
public interface TableDefinition<RowType> { |
32 |
31 |
|
/** |
33 |
32 |
|
* A hook into where the rendered cell will be displayed. |
34 |
33 |
|
* |
35 |
34 |
|
* @param <RowType> the type of the row values |
36 |
35 |
|
*/ |
37 |
|
- |
public abstract static class AbstractCellView<RowType> |
38 |
|
- |
{ |
|
36 |
+ |
public abstract static class AbstractCellView<RowType> { |
39 |
37 |
|
private int cellIndex = 0; |
40 |
38 |
|
private int rowIndex = 0; |
41 |
39 |
|
private HasTableDefinition<RowType> source; |
|
@@ -46,32 +44,28 @@ |
46 |
44 |
|
* @param sourceTableDef the {@link HasTableDefinition} that defined the |
47 |
45 |
|
* cell view |
48 |
46 |
|
*/ |
49 |
|
- |
public AbstractCellView( HasTableDefinition<RowType> sourceTableDef ) |
50 |
|
- |
{ |
|
47 |
+ |
public AbstractCellView( HasTableDefinition<RowType> sourceTableDef ) { |
51 |
48 |
|
this.source = sourceTableDef; |
52 |
49 |
|
} |
53 |
50 |
|
|
54 |
51 |
|
/** |
55 |
52 |
|
* @return the actual cell index being rendered |
56 |
53 |
|
*/ |
57 |
|
- |
public int getCellIndex() |
58 |
|
- |
{ |
|
54 |
+ |
public int getCellIndex() { |
59 |
55 |
|
return cellIndex; |
60 |
56 |
|
} |
61 |
57 |
|
|
62 |
58 |
|
/** |
63 |
59 |
|
* @return the actual row index being rendered |
64 |
60 |
|
*/ |
65 |
|
- |
public int getRowIndex() |
66 |
|
- |
{ |
|
61 |
+ |
public int getRowIndex() { |
67 |
62 |
|
return rowIndex; |
68 |
63 |
|
} |
69 |
64 |
|
|
70 |
65 |
|
/** |
71 |
66 |
|
* @return the source of the {@link TableDefinition} |
72 |
67 |
|
*/ |
73 |
|
- |
public HasTableDefinition<RowType> getSourceTableDefinition() |
74 |
|
- |
{ |
|
68 |
+ |
public HasTableDefinition<RowType> getSourceTableDefinition() { |
75 |
69 |
|
return source; |
76 |
70 |
|
} |
77 |
71 |
|
|
|
@@ -134,8 +128,7 @@ |
134 |
128 |
|
* @param rowValue the row value associated with the row |
135 |
129 |
|
* @param columnDef the {@link ColumnDefinition} associated with the column |
136 |
130 |
|
*/ |
137 |
|
- |
protected void renderCellImpl( int rowIndex, int cellIndex, RowType rowValue, ColumnDefinition<RowType, ?> columnDef ) |
138 |
|
- |
{ |
|
131 |
+ |
protected void renderCellImpl( int rowIndex, int cellIndex, RowType rowValue, ColumnDefinition<RowType, ?> columnDef ) { |
139 |
132 |
|
this.rowIndex = rowIndex; |
140 |
133 |
|
this.cellIndex = cellIndex; |
141 |
134 |
|
renderRowValue( rowValue, columnDef ); |
|
@@ -147,8 +140,7 @@ |
147 |
140 |
|
* @param rowValue the row value associated with the row |
148 |
141 |
|
* @param columnDef the {@link ColumnDefinition} associated with the column |
149 |
142 |
|
*/ |
150 |
|
- |
protected void renderRowValue( RowType rowValue, ColumnDefinition columnDef ) |
151 |
|
- |
{ |
|
143 |
+ |
protected void renderRowValue( RowType rowValue, ColumnDefinition columnDef ) { |
152 |
144 |
|
columnDef.getCellRenderer().renderRowValue( rowValue, columnDef, this ); |
153 |
145 |
|
} |
154 |
146 |
|
} |
|
@@ -158,8 +150,7 @@ |
158 |
150 |
|
* |
159 |
151 |
|
* @param <RowType> the type of the row values |
160 |
152 |
|
*/ |
161 |
|
- |
public abstract static class AbstractRowView<RowType> |
162 |
|
- |
{ |
|
153 |
+ |
public abstract static class AbstractRowView<RowType> { |
163 |
154 |
|
private int rowIndex = 0; |
164 |
155 |
|
private AbstractCellView<RowType> cellView; |
165 |
156 |
|
|
|
@@ -168,24 +159,21 @@ |
168 |
159 |
|
* |
169 |
160 |
|
* @param cellView the view of the cell |
170 |
161 |
|
*/ |
171 |
|
- |
public AbstractRowView( AbstractCellView<RowType> cellView ) |
172 |
|
- |
{ |
|
162 |
+ |
public AbstractRowView( AbstractCellView<RowType> cellView ) { |
173 |
163 |
|
this.cellView = cellView; |
174 |
164 |
|
} |
175 |
165 |
|
|
176 |
166 |
|
/** |
177 |
167 |
|
* @return the actual row index being rendered |
178 |
168 |
|
*/ |
179 |
|
- |
public int getRowIndex() |
180 |
|
- |
{ |
|
169 |
+ |
public int getRowIndex() { |
181 |
170 |
|
return rowIndex; |
182 |
171 |
|
} |
183 |
172 |
|
|
184 |
173 |
|
/** |
185 |
174 |
|
* @return the source of the {@link TableDefinition} |
186 |
175 |
|
*/ |
187 |
|
- |
public HasTableDefinition<RowType> getSourceTableDefinition() |
188 |
|
- |
{ |
|
176 |
+ |
public HasTableDefinition<RowType> getSourceTableDefinition() { |
189 |
177 |
|
return cellView.getSourceTableDefinition(); |
190 |
178 |
|
} |
191 |
179 |
|
|
|
@@ -211,13 +199,11 @@ |
211 |
199 |
|
* @param rowRenderer the renderer used to render the rows |
212 |
200 |
|
* @param visibleColumns the list of visible {@link ColumnDefinition} |
213 |
201 |
|
*/ |
214 |
|
- |
protected void renderRowImpl( int rowIndex, RowType rowValue, RowRenderer<RowType> rowRenderer, List<ColumnDefinition<RowType, ?>> visibleColumns ) |
215 |
|
- |
{ |
|
202 |
+ |
protected void renderRowImpl( int rowIndex, RowType rowValue, RowRenderer<RowType> rowRenderer, List<ColumnDefinition<RowType, ?>> visibleColumns ) { |
216 |
203 |
|
this.rowIndex = rowIndex; |
217 |
204 |
|
renderRowValue( rowValue, rowRenderer ); |
218 |
205 |
|
int numColumns = visibleColumns.size(); |
219 |
|
- |
for ( int i = 0; i < numColumns; i++ ) |
220 |
|
- |
{ |
|
206 |
+ |
for ( int i = 0; i < numColumns; i++ ) { |
221 |
207 |
|
cellView.renderCellImpl( rowIndex, i, rowValue, visibleColumns.get( i ) ); |
222 |
208 |
|
} |
223 |
209 |
|
} |
|
@@ -231,11 +217,10 @@ |
231 |
217 |
|
* @param rowRenderer the renderer used to render the rows |
232 |
218 |
|
* @param visibleColumns the list of visible {@link ColumnDefinition} |
233 |
219 |
|
*/ |
234 |
|
- |
protected void renderRowsImpl( int startRowIndex, Iterator<RowType> rowValues, RowRenderer<RowType> rowRenderer, List<ColumnDefinition<RowType, ?>> visibleColumns ) |
235 |
|
- |
{ |
|
220 |
+ |
protected void renderRowsImpl( int startRowIndex, Iterator<RowType> rowValues, RowRenderer<RowType> rowRenderer, |
|
221 |
+ |
List<ColumnDefinition<RowType, ?>> visibleColumns ) { |
236 |
222 |
|
int curRow = startRowIndex; |
237 |
|
- |
while ( rowValues.hasNext() ) |
238 |
|
- |
{ |
|
223 |
+ |
while ( rowValues.hasNext() ) { |
239 |
224 |
|
renderRowImpl( curRow, rowValues.next(), rowRenderer, visibleColumns ); |
240 |
225 |
|
curRow++; |
241 |
226 |
|
} |
|
@@ -247,8 +232,7 @@ |
247 |
232 |
|
* @param rowValue the row value associated with the row |
248 |
233 |
|
* @param rowRenderer the renderer used to render the rows |
249 |
234 |
|
*/ |
250 |
|
- |
protected void renderRowValue( RowType rowValue, RowRenderer<RowType> rowRenderer ) |
251 |
|
- |
{ |
|
235 |
+ |
protected void renderRowValue( RowType rowValue, RowRenderer<RowType> rowRenderer ) { |
252 |
236 |
|
rowRenderer.renderRowValue( rowValue, this ); |
253 |
237 |
|
} |
254 |
238 |
|
} |