|
@@ -16,8 +16,6 @@ |
16 |
16 |
|
|
17 |
17 |
|
package com.google.gwt.gen2.table.client; |
18 |
18 |
|
|
19 |
|
- |
import java.util.*; |
20 |
|
- |
|
21 |
19 |
|
import com.google.gwt.core.client.*; |
22 |
20 |
|
import com.google.gwt.dom.client.*; |
23 |
21 |
|
import com.google.gwt.gen2.table.client.TableDefinition.*; |
|
@@ -28,20 +26,20 @@ |
28 |
26 |
|
import com.google.gwt.user.client.ui.HasVerticalAlignment.*; |
29 |
27 |
|
import com.google.gwt.user.client.ui.*; |
30 |
28 |
|
|
|
29 |
+ |
import java.util.*; |
|
30 |
+ |
|
31 |
31 |
|
/** |
32 |
32 |
|
* Enables bulk rendering of tables. Each subclass that needs special handling |
33 |
33 |
|
* for bulk rendering should have its own bulk renderer. |
34 |
34 |
|
* |
35 |
35 |
|
* @param <RowType> the data type of the row values |
36 |
36 |
|
*/ |
37 |
|
- |
public abstract class TableBulkRenderer<RowType> implements HasTableDefinition<RowType> |
38 |
|
- |
{ |
|
37 |
+ |
public abstract class TableBulkRenderer<RowType> implements HasTableDefinition<RowType> { |
39 |
38 |
|
/** |
40 |
39 |
|
* A simple class that keeps track of a widget that needs to be add to the |
41 |
40 |
|
* table after it finishes loading. |
42 |
41 |
|
*/ |
43 |
|
- |
private static class DelayedWidget |
44 |
|
- |
{ |
|
42 |
+ |
private static class DelayedWidget { |
45 |
43 |
|
public int cellIndex; |
46 |
44 |
|
public int rowIndex; |
47 |
45 |
|
public Widget widget; |
|
@@ -49,8 +47,7 @@ |
49 |
47 |
|
/** |
50 |
48 |
|
* Construct a new {@link DelayedWidget}. |
51 |
49 |
|
*/ |
52 |
|
- |
public DelayedWidget( int rowIndex, int cellIndex, Widget widget ) |
53 |
|
- |
{ |
|
50 |
+ |
public DelayedWidget( int rowIndex, int cellIndex, Widget widget ) { |
54 |
51 |
|
this.rowIndex = rowIndex; |
55 |
52 |
|
this.cellIndex = cellIndex; |
56 |
53 |
|
this.widget = widget; |
|
@@ -62,8 +59,7 @@ |
62 |
59 |
|
* |
63 |
60 |
|
* @param <RowType> the data type of the row values |
64 |
61 |
|
*/ |
65 |
|
- |
protected static class BulkCellView<RowType> extends AbstractCellView<RowType> |
66 |
|
- |
{ |
|
62 |
+ |
protected static class BulkCellView<RowType> extends AbstractCellView<RowType> { |
67 |
63 |
|
/** |
68 |
64 |
|
* A {@link StringBuffer} used to assemble the HTML of the table. |
69 |
65 |
|
*/ |
|
@@ -115,64 +111,54 @@ |
115 |
111 |
|
* |
116 |
112 |
|
* @param bulkRenderer the renderer |
117 |
113 |
|
*/ |
118 |
|
- |
public BulkCellView( TableBulkRenderer<RowType> bulkRenderer ) |
119 |
|
- |
{ |
|
114 |
+ |
public BulkCellView( TableBulkRenderer<RowType> bulkRenderer ) { |
120 |
115 |
|
super( (bulkRenderer.source == null) ? bulkRenderer : bulkRenderer.source ); |
121 |
116 |
|
} |
122 |
117 |
|
|
123 |
118 |
|
@Override |
124 |
|
- |
public void setHorizontalAlignment( HorizontalAlignmentConstant align ) |
125 |
|
- |
{ |
|
119 |
+ |
public void setHorizontalAlignment( HorizontalAlignmentConstant align ) { |
126 |
120 |
|
curCellHorizontalAlign = align; |
127 |
121 |
|
} |
128 |
122 |
|
|
129 |
123 |
|
@Override |
130 |
|
- |
public void setHTML( String html ) |
131 |
|
- |
{ |
|
124 |
+ |
public void setHTML( String html ) { |
132 |
125 |
|
curCellWidget = null; |
133 |
126 |
|
curCellHtml = html; |
134 |
127 |
|
} |
135 |
128 |
|
|
136 |
129 |
|
@Override |
137 |
|
- |
public void setStyleAttribute( String attr, String value ) |
138 |
|
- |
{ |
|
130 |
+ |
public void setStyleAttribute( String attr, String value ) { |
139 |
131 |
|
curCellStyles.put( attr, value ); |
140 |
132 |
|
} |
141 |
133 |
|
|
142 |
134 |
|
@Override |
143 |
|
- |
public void setStyleName( String stylename ) |
144 |
|
- |
{ |
|
135 |
+ |
public void setStyleName( String stylename ) { |
145 |
136 |
|
curCellStyleName = stylename; |
146 |
137 |
|
} |
147 |
138 |
|
|
148 |
139 |
|
@Override |
149 |
|
- |
public void setText( String text ) |
150 |
|
- |
{ |
|
140 |
+ |
public void setText( String text ) { |
151 |
141 |
|
htmlCleaner.setInnerText( text ); |
152 |
142 |
|
setHTML( htmlCleaner.getInnerHTML() ); |
153 |
143 |
|
} |
154 |
144 |
|
|
155 |
145 |
|
@Override |
156 |
|
- |
public void setVerticalAlignment( VerticalAlignmentConstant align ) |
157 |
|
- |
{ |
|
146 |
+ |
public void setVerticalAlignment( VerticalAlignmentConstant align ) { |
158 |
147 |
|
curCellVerticalAlign = align; |
159 |
148 |
|
} |
160 |
149 |
|
|
161 |
150 |
|
@Override |
162 |
|
- |
public void setWidget( Widget widget ) |
163 |
|
- |
{ |
|
151 |
+ |
public void setWidget( Widget widget ) { |
164 |
152 |
|
curCellHtml = null; |
165 |
153 |
|
curCellWidget = widget; |
166 |
154 |
|
} |
167 |
155 |
|
|
168 |
|
- |
protected StringBuffer getStringBuffer() |
169 |
|
- |
{ |
|
156 |
+ |
protected StringBuffer getStringBuffer() { |
170 |
157 |
|
return buffer; |
171 |
158 |
|
} |
172 |
159 |
|
|
173 |
160 |
|
@Override |
174 |
|
- |
protected void renderRowValue( RowType rowValue, ColumnDefinition columnDef ) |
175 |
|
- |
{ |
|
161 |
+ |
protected void renderRowValue( RowType rowValue, ColumnDefinition columnDef ) { |
176 |
162 |
|
curCellHtml = null; |
177 |
163 |
|
curCellWidget = null; |
178 |
164 |
|
curCellStyleName = null; |
|
@@ -182,8 +168,7 @@ |
182 |
168 |
|
super.renderRowValue( rowValue, columnDef ); |
183 |
169 |
|
|
184 |
170 |
|
// Save the widget until rendering is complete |
185 |
|
- |
if ( curCellWidget != null ) |
186 |
|
- |
{ |
|
171 |
+ |
if ( curCellWidget != null ) { |
187 |
172 |
|
int row = getRowIndex(); |
188 |
173 |
|
int cell = getCellIndex(); |
189 |
174 |
|
delayedWidgets.add( new DelayedWidget( row, cell, curCellWidget ) ); |
|
@@ -191,27 +176,22 @@ |
191 |
176 |
|
|
192 |
177 |
|
// Add the open tag |
193 |
178 |
|
buffer.append( "<td" ); |
194 |
|
- |
if ( curCellHorizontalAlign != null ) |
195 |
|
- |
{ |
|
179 |
+ |
if ( curCellHorizontalAlign != null ) { |
196 |
180 |
|
buffer.append( " align=\"" ); |
197 |
181 |
|
buffer.append( curCellHorizontalAlign.getTextAlignString() ); |
198 |
182 |
|
buffer.append( "\"" ); |
199 |
183 |
|
} |
200 |
|
- |
if ( curCellVerticalAlign != null ) |
201 |
|
- |
{ |
|
184 |
+ |
if ( curCellVerticalAlign != null ) { |
202 |
185 |
|
curCellStyles.put( "verticalAlign", curCellVerticalAlign.getVerticalAlignString() ); |
203 |
186 |
|
} |
204 |
|
- |
if ( curCellStyleName != null ) |
205 |
|
- |
{ |
|
187 |
+ |
if ( curCellStyleName != null ) { |
206 |
188 |
|
buffer.append( " class=\"" ); |
207 |
189 |
|
buffer.append( curCellStyleName ); |
208 |
190 |
|
buffer.append( "\"" ); |
209 |
191 |
|
} |
210 |
|
- |
if ( curCellStyles.size() > 0 ) |
211 |
|
- |
{ |
|
192 |
+ |
if ( curCellStyles.size() > 0 ) { |
212 |
193 |
|
buffer.append( " style=\"" ); |
213 |
|
- |
for ( Map.Entry<String, String> entry : curCellStyles.entrySet() ) |
214 |
|
- |
{ |
|
194 |
+ |
for ( Map.Entry<String, String> entry : curCellStyles.entrySet() ) { |
215 |
195 |
|
buffer.append( entry.getKey() ); |
216 |
196 |
|
buffer.append( ":" ); |
217 |
197 |
|
buffer.append( entry.getValue() ); |
|
@@ -222,8 +202,7 @@ |
222 |
202 |
|
buffer.append( ">" ); |
223 |
203 |
|
|
224 |
204 |
|
// Add contents |
225 |
|
- |
if ( curCellHtml != null ) |
226 |
|
- |
{ |
|
205 |
+ |
if ( curCellHtml != null ) { |
227 |
206 |
|
buffer.append( curCellHtml ); |
228 |
207 |
|
} |
229 |
208 |
|
|
|
@@ -236,8 +215,7 @@ |
236 |
215 |
|
* |
237 |
216 |
|
* @return the cell's html contents. |
238 |
217 |
|
*/ |
239 |
|
- |
String getHtml() |
240 |
|
- |
{ |
|
218 |
+ |
String getHtml() { |
241 |
219 |
|
return curCellHtml; |
242 |
220 |
|
} |
243 |
221 |
|
} |
|
@@ -247,8 +225,7 @@ |
247 |
225 |
|
* |
248 |
226 |
|
* @param <RowType> the type of the row values |
249 |
227 |
|
*/ |
250 |
|
- |
protected static class BulkRowView<RowType> extends AbstractRowView<RowType> |
251 |
|
- |
{ |
|
228 |
+ |
protected static class BulkRowView<RowType> extends AbstractRowView<RowType> { |
252 |
229 |
|
/** |
253 |
230 |
|
* A {@link StringBuffer} used to assemble the HTML of the table. |
254 |
231 |
|
*/ |
|
@@ -291,8 +268,7 @@ |
291 |
268 |
|
* @param bulkRenderer the renderer |
292 |
269 |
|
* @param options the {@link RenderingOptions} to apply to the table |
293 |
270 |
|
*/ |
294 |
|
- |
public BulkRowView( BulkCellView<RowType> cellView, TableBulkRenderer<RowType> bulkRenderer, RenderingOptions options ) |
295 |
|
- |
{ |
|
271 |
+ |
public BulkRowView( BulkCellView<RowType> cellView, TableBulkRenderer<RowType> bulkRenderer, RenderingOptions options ) { |
296 |
272 |
|
super( cellView ); |
297 |
273 |
|
this.bulkRenderer = bulkRenderer; |
298 |
274 |
|
this.cellView = cellView; |
|
@@ -304,36 +280,31 @@ |
304 |
280 |
|
} |
305 |
281 |
|
|
306 |
282 |
|
@Override |
307 |
|
- |
public void setStyleAttribute( String attr, String value ) |
308 |
|
- |
{ |
|
283 |
+ |
public void setStyleAttribute( String attr, String value ) { |
309 |
284 |
|
curRowStyles.put( attr, value ); |
310 |
285 |
|
} |
311 |
286 |
|
|
312 |
287 |
|
@Override |
313 |
|
- |
public void setStyleName( String stylename ) |
314 |
|
- |
{ |
|
288 |
+ |
public void setStyleName( String stylename ) { |
315 |
289 |
|
curRowStyleName = stylename; |
316 |
290 |
|
} |
317 |
291 |
|
|
318 |
|
- |
protected StringBuffer getStringBuffer() |
319 |
|
- |
{ |
|
292 |
+ |
protected StringBuffer getStringBuffer() { |
320 |
293 |
|
return buffer; |
321 |
294 |
|
} |
322 |
295 |
|
|
323 |
296 |
|
@Override |
324 |
|
- |
protected void renderRowImpl( int rowIndex, RowType rowValue, RowRenderer<RowType> rowRenderer, List<ColumnDefinition<RowType, ?>> visibleColumns ) |
325 |
|
- |
{ |
|
297 |
+ |
protected void renderRowImpl( int rowIndex, RowType rowValue, RowRenderer<RowType> rowRenderer, List<ColumnDefinition<RowType, ?>> visibleColumns ) { |
326 |
298 |
|
super.renderRowImpl( rowIndex, rowValue, rowRenderer, visibleColumns ); |
327 |
299 |
|
buffer.append( "</tr>" ); |
328 |
300 |
|
} |
329 |
301 |
|
|
330 |
302 |
|
@Override |
331 |
|
- |
protected void renderRowsImpl( int startRowIndex, final Iterator<RowType> rowValues, final RowRenderer<RowType> rowRenderer, final List<ColumnDefinition<RowType, ?>> visibleColumns ) |
332 |
|
- |
{ |
|
303 |
+ |
protected void renderRowsImpl( int startRowIndex, final Iterator<RowType> rowValues, final RowRenderer<RowType> rowRenderer, |
|
304 |
+ |
final List<ColumnDefinition<RowType, ?>> visibleColumns ) { |
333 |
305 |
|
// Create the table |
334 |
306 |
|
buffer.append( "<table><tbody>" ); |
335 |
|
- |
if ( options.headerRow != null ) |
336 |
|
- |
{ |
|
307 |
+ |
if ( options.headerRow != null ) { |
337 |
308 |
|
buffer.append( options.headerRow ); |
338 |
309 |
|
} |
339 |
310 |
|
|
|
@@ -342,30 +313,23 @@ |
342 |
313 |
|
final int myStamp = ++bulkRenderer.requestStamp; |
343 |
314 |
|
|
344 |
315 |
|
// Use an incremental command to render rows in increments |
345 |
|
- |
class RenderTableCommand implements IncrementalCommand |
346 |
|
- |
{ |
347 |
|
- |
public boolean execute() |
348 |
|
- |
{ |
|
316 |
+ |
class RenderTableCommand implements IncrementalCommand { |
|
317 |
+ |
public boolean execute() { |
349 |
318 |
|
// Poor man's cancel() event. |
350 |
|
- |
if ( myStamp != bulkRenderer.requestStamp ) |
351 |
|
- |
{ |
|
319 |
+ |
if ( myStamp != bulkRenderer.requestStamp ) { |
352 |
320 |
|
return false; |
353 |
321 |
|
} |
354 |
322 |
|
int checkRow = ROWS_PER_TIME_CHECK; |
355 |
323 |
|
double endSlice = Duration.currentTimeMillis() + TIME_SLICE; |
356 |
324 |
|
|
357 |
325 |
|
// Loop through the rows |
358 |
|
- |
while ( rowValues.hasNext() ) |
359 |
|
- |
{ |
|
326 |
+ |
while ( rowValues.hasNext() ) { |
360 |
327 |
|
// Check if we've exceed the time slice |
361 |
|
- |
if ( !options.syncCall ) |
362 |
|
- |
{ |
363 |
|
- |
if ( --checkRow == 0 ) |
364 |
|
- |
{ |
|
328 |
+ |
if ( !options.syncCall ) { |
|
329 |
+ |
if ( --checkRow == 0 ) { |
365 |
330 |
|
checkRow = ROWS_PER_TIME_CHECK; |
366 |
331 |
|
double time = Duration.currentTimeMillis(); |
367 |
|
- |
if ( time > endSlice ) |
368 |
|
- |
{ |
|
332 |
+ |
if ( time > endSlice ) { |
369 |
333 |
|
return true; |
370 |
334 |
|
} |
371 |
335 |
|
} |
|
@@ -377,8 +341,7 @@ |
377 |
341 |
|
} |
378 |
342 |
|
|
379 |
343 |
|
// Add the footer row |
380 |
|
- |
if ( options.footerRow != null ) |
381 |
|
- |
{ |
|
344 |
+ |
if ( options.footerRow != null ) { |
382 |
345 |
|
buffer.append( options.footerRow ); |
383 |
346 |
|
} |
384 |
347 |
|
|
|
@@ -387,14 +350,12 @@ |
387 |
350 |
|
bulkRenderer.renderRows( buffer.toString() ); |
388 |
351 |
|
|
389 |
352 |
|
// Add widgets into the table |
390 |
|
- |
for ( DelayedWidget dw : cellView.delayedWidgets ) |
391 |
|
- |
{ |
|
353 |
+ |
for ( DelayedWidget dw : cellView.delayedWidgets ) { |
392 |
354 |
|
bulkRenderer.setWidgetRaw( bulkRenderer.getTable(), dw.rowIndex, dw.cellIndex, dw.widget ); |
393 |
355 |
|
} |
394 |
356 |
|
|
395 |
357 |
|
// Trigger the callback |
396 |
|
- |
if ( options.callback != null ) |
397 |
|
- |
{ |
|
358 |
+ |
if ( options.callback != null ) { |
398 |
359 |
|
options.callback.onRendered(); |
399 |
360 |
|
} |
400 |
361 |
|
return false; |
|
@@ -403,32 +364,27 @@ |
403 |
364 |
|
|
404 |
365 |
|
// Fire the incremental command |
405 |
366 |
|
RenderTableCommand renderTable = new RenderTableCommand(); |
406 |
|
- |
if ( renderTable.execute() ) |
407 |
|
- |
{ |
|
367 |
+ |
if ( renderTable.execute() ) { |
408 |
368 |
|
DeferredCommand.addCommand( renderTable ); |
409 |
369 |
|
} |
410 |
370 |
|
} |
411 |
371 |
|
|
412 |
372 |
|
@Override |
413 |
|
- |
protected void renderRowValue( RowType rowValue, RowRenderer<RowType> rowRenderer ) |
414 |
|
- |
{ |
|
373 |
+ |
protected void renderRowValue( RowType rowValue, RowRenderer<RowType> rowRenderer ) { |
415 |
374 |
|
curRowStyleName = null; |
416 |
375 |
|
curRowStyles.clear(); |
417 |
376 |
|
super.renderRowValue( rowValue, rowRenderer ); |
418 |
377 |
|
|
419 |
378 |
|
// Add the open tag |
420 |
379 |
|
buffer.append( "<tr" ); |
421 |
|
- |
if ( curRowStyleName != null ) |
422 |
|
- |
{ |
|
380 |
+ |
if ( curRowStyleName != null ) { |
423 |
381 |
|
buffer.append( " class=\"" ); |
424 |
382 |
|
buffer.append( curRowStyleName ); |
425 |
383 |
|
buffer.append( "\"" ); |
426 |
384 |
|
} |
427 |
|
- |
if ( curRowStyles.size() > 0 ) |
428 |
|
- |
{ |
|
385 |
+ |
if ( curRowStyles.size() > 0 ) { |
429 |
386 |
|
buffer.append( " style=\"" ); |
430 |
|
- |
for ( Map.Entry<String, String> entry : curRowStyles.entrySet() ) |
431 |
|
- |
{ |
|
387 |
+ |
for ( Map.Entry<String, String> entry : curRowStyles.entrySet() ) { |
432 |
388 |
|
buffer.append( entry.getKey() ); |
433 |
389 |
|
buffer.append( ":" ); |
434 |
390 |
|
buffer.append( entry.getValue() ); |
|
@@ -443,8 +399,7 @@ |
443 |
399 |
|
/** |
444 |
400 |
|
* Convenience class used to specify rendering options for the table. |
445 |
401 |
|
*/ |
446 |
|
- |
protected static class RenderingOptions |
447 |
|
- |
{ |
|
402 |
+ |
protected static class RenderingOptions { |
448 |
403 |
|
public int startRow = 0; |
449 |
404 |
|
public int numRows = MutableTableModel.ALL_ROWS; |
450 |
405 |
|
public boolean syncCall = false; |
|
@@ -498,8 +453,7 @@ |
498 |
453 |
|
* @param tableDefinition the renderer that should be used during bulk |
499 |
454 |
|
* rendering |
500 |
455 |
|
*/ |
501 |
|
- |
public TableBulkRenderer( HTMLTable table, TableDefinition<RowType> tableDefinition ) |
502 |
|
- |
{ |
|
456 |
+ |
public TableBulkRenderer( HTMLTable table, TableDefinition<RowType> tableDefinition ) { |
503 |
457 |
|
this.table = table; |
504 |
458 |
|
this.tableDefinition = tableDefinition; |
505 |
459 |
|
} |
|
@@ -510,14 +464,12 @@ |
510 |
464 |
|
* @param table the table to be bulk rendered |
511 |
465 |
|
* @param sourceTableDef the external source of the table definition |
512 |
466 |
|
*/ |
513 |
|
- |
public TableBulkRenderer( HTMLTable table, HasTableDefinition<RowType> sourceTableDef ) |
514 |
|
- |
{ |
|
467 |
+ |
public TableBulkRenderer( HTMLTable table, HasTableDefinition<RowType> sourceTableDef ) { |
515 |
468 |
|
this( table, sourceTableDef.getTableDefinition() ); |
516 |
469 |
|
this.source = sourceTableDef; |
517 |
470 |
|
} |
518 |
471 |
|
|
519 |
|
- |
public TableDefinition<RowType> getTableDefinition() |
520 |
|
- |
{ |
|
472 |
+ |
public TableDefinition<RowType> getTableDefinition() { |
521 |
473 |
|
return (source == null) ? tableDefinition : source.getTableDefinition(); |
522 |
474 |
|
} |
523 |
475 |
|
|
|
@@ -530,8 +482,7 @@ |
530 |
482 |
|
* |
531 |
483 |
|
* @param rows {@link Iterable} of row values |
532 |
484 |
|
*/ |
533 |
|
- |
public final void renderRows( Iterable<RowType> rows ) |
534 |
|
- |
{ |
|
485 |
+ |
public final void renderRows( Iterable<RowType> rows ) { |
535 |
486 |
|
renderRows( rows, null ); |
536 |
487 |
|
} |
537 |
488 |
|
|
|
@@ -545,8 +496,7 @@ |
545 |
496 |
|
* @param rows {@link Iterable} of row values |
546 |
497 |
|
* @param callback callback to be called after the rows are rendered |
547 |
498 |
|
*/ |
548 |
|
- |
public final void renderRows( Iterable<RowType> rows, RendererCallback callback ) |
549 |
|
- |
{ |
|
499 |
+ |
public final void renderRows( Iterable<RowType> rows, RendererCallback callback ) { |
550 |
500 |
|
IterableTableModel<RowType> tableModel = new IterableTableModel<RowType>( rows ); |
551 |
501 |
|
RenderingOptions options = createRenderingOptions(); |
552 |
502 |
|
options.syncCall = true; |
|
@@ -562,8 +512,7 @@ |
562 |
512 |
|
* @param rows iterator of row values |
563 |
513 |
|
* @param callback callback to be called after the rows are rendered |
564 |
514 |
|
*/ |
565 |
|
- |
public final void renderRows( Iterator<RowType> rows, RendererCallback callback ) |
566 |
|
- |
{ |
|
515 |
+ |
public final void renderRows( Iterator<RowType> rows, RendererCallback callback ) { |
567 |
516 |
|
RenderingOptions options = createRenderingOptions(); |
568 |
517 |
|
options.callback = callback; |
569 |
518 |
|
renderRows( rows, options ); |
|
@@ -579,8 +528,7 @@ |
579 |
528 |
|
* indicates all of them * |
580 |
529 |
|
* @param callback callback to call after the table is finished being rendered |
581 |
530 |
|
*/ |
582 |
|
- |
public final void renderRows( MutableTableModel<RowType> tableModel, int startRow, int numRows, RendererCallback callback ) |
583 |
|
- |
{ |
|
531 |
+ |
public final void renderRows( MutableTableModel<RowType> tableModel, int startRow, int numRows, RendererCallback callback ) { |
584 |
532 |
|
RenderingOptions options = createRenderingOptions(); |
585 |
533 |
|
options.startRow = startRow; |
586 |
534 |
|
options.numRows = numRows; |
|
@@ -595,8 +543,7 @@ |
595 |
543 |
|
* @param tableModel the table model |
596 |
544 |
|
* @param callback callback to call after the table is finished being rendered |
597 |
545 |
|
*/ |
598 |
|
- |
public final void renderRows( MutableTableModel<RowType> tableModel, RendererCallback callback ) |
599 |
|
- |
{ |
|
546 |
+ |
public final void renderRows( MutableTableModel<RowType> tableModel, RendererCallback callback ) { |
600 |
547 |
|
renderRows( tableModel, 0, MutableTableModel.ALL_ROWS, callback ); |
601 |
548 |
|
} |
602 |
549 |
|
|
|
@@ -605,8 +552,7 @@ |
605 |
552 |
|
* |
606 |
553 |
|
* @return the rendering options |
607 |
554 |
|
*/ |
608 |
|
- |
protected RenderingOptions createRenderingOptions() |
609 |
|
- |
{ |
|
555 |
+ |
protected RenderingOptions createRenderingOptions() { |
610 |
556 |
|
return new RenderingOptions(); |
611 |
557 |
|
} |
612 |
558 |
|
|
|
@@ -617,8 +563,7 @@ |
617 |
563 |
|
* |
618 |
564 |
|
* @return the row view |
619 |
565 |
|
*/ |
620 |
|
- |
protected AbstractRowView<RowType> createRowView( final RenderingOptions options ) |
621 |
|
- |
{ |
|
566 |
+ |
protected AbstractRowView<RowType> createRowView( final RenderingOptions options ) { |
622 |
567 |
|
BulkCellView<RowType> cellView = new BulkCellView<RowType>( this ); |
623 |
568 |
|
return new BulkRowView<RowType>( cellView, this, options ); |
624 |
569 |
|
} |
|
@@ -628,8 +573,7 @@ |
628 |
573 |
|
* |
629 |
574 |
|
* @returns the current html table. |
630 |
575 |
|
*/ |
631 |
|
- |
protected HTMLTable getTable() |
632 |
|
- |
{ |
|
576 |
+ |
protected HTMLTable getTable() { |
633 |
577 |
|
return table; |
634 |
578 |
|
} |
635 |
579 |
|
|
|
@@ -639,8 +583,7 @@ |
639 |
583 |
|
* @param rows Iterator of row iterators |
640 |
584 |
|
* @param options rendering options for this table |
641 |
585 |
|
*/ |
642 |
|
- |
protected void renderRows( final Iterator<RowType> rows, final RenderingOptions options ) |
643 |
|
- |
{ |
|
586 |
+ |
protected void renderRows( final Iterator<RowType> rows, final RenderingOptions options ) { |
644 |
587 |
|
getTableDefinition().renderRows( 0, rows, createRowView( options ) ); |
645 |
588 |
|
} |
646 |
589 |
|
|
|
@@ -650,18 +593,14 @@ |
650 |
593 |
|
* @param tableModel table model |
651 |
594 |
|
* @param options options |
652 |
595 |
|
*/ |
653 |
|
- |
protected final void renderRows( TableModel<RowType> tableModel, final RenderingOptions options ) |
654 |
|
- |
{ |
|
596 |
+ |
protected final void renderRows( TableModel<RowType> tableModel, final RenderingOptions options ) { |
655 |
597 |
|
|
656 |
598 |
|
// Create a callback to handle the request |
657 |
|
- |
TableModel.Callback<RowType> requestCallback = new TableModel.Callback<RowType>() |
658 |
|
- |
{ |
659 |
|
- |
public void onFailure( Throwable caught ) |
660 |
|
- |
{ |
|
599 |
+ |
TableModel.Callback<RowType> requestCallback = new TableModel.Callback<RowType>() { |
|
600 |
+ |
public void onFailure( Throwable caught ) { |
661 |
601 |
|
} |
662 |
602 |
|
|
663 |
|
- |
public void onRowsReady( Request request, final Response<RowType> response ) |
664 |
|
- |
{ |
|
603 |
+ |
public void onRowsReady( Request request, final Response<RowType> response ) { |
665 |
604 |
|
final Iterator<RowType> rows = response.getRowValues(); |
666 |
605 |
|
renderRows( rows, options ); |
667 |
606 |
|
} |
|
@@ -670,18 +609,15 @@ |
670 |
609 |
|
tableModel.requestRows( new Request( options.startRow, options.numRows ), requestCallback ); |
671 |
610 |
|
} |
672 |
611 |
|
|
673 |
|
- |
protected void renderRows( String rawHTMLTable ) |
674 |
|
- |
{ |
|
612 |
+ |
protected void renderRows( String rawHTMLTable ) { |
675 |
613 |
|
DOM.setInnerHTML( getWrapperDiv(), rawHTMLTable ); |
676 |
614 |
|
Element tableElement = DOM.getFirstChild( getWrapperDiv() ); |
677 |
615 |
|
Element newBody = replaceBodyElement( table.getElement(), tableElement ); |
678 |
616 |
|
setBodyElement( table, newBody ); |
679 |
617 |
|
} |
680 |
618 |
|
|
681 |
|
- |
private Element getWrapperDiv() |
682 |
|
- |
{ |
683 |
|
- |
if ( WRAPPER_DIV == null ) |
684 |
|
- |
{ |
|
619 |
+ |
private Element getWrapperDiv() { |
|
620 |
+ |
if ( WRAPPER_DIV == null ) { |
685 |
621 |
|
WRAPPER_DIV = DOM.createElement( "div" ); |
686 |
622 |
|
} |
687 |
623 |
|
return WRAPPER_DIV; |