|
@@ -15,8 +15,6 @@ |
15 |
15 |
|
*/ |
16 |
16 |
|
package com.google.gwt.gen2.table.client; |
17 |
17 |
|
|
18 |
|
- |
import java.util.*; |
19 |
|
- |
|
20 |
18 |
|
import org.litesoft.commonfoundation.html.*; |
21 |
19 |
|
|
22 |
20 |
|
import com.google.gwt.event.dom.client.*; |
|
@@ -35,6 +33,8 @@ |
35 |
33 |
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment.*; |
36 |
34 |
|
import com.google.gwt.user.client.ui.HasVerticalAlignment.*; |
37 |
35 |
|
|
|
36 |
+ |
import java.util.*; |
|
37 |
+ |
|
38 |
38 |
|
/** |
39 |
39 |
|
* An {@link AbstractScrollTable} that acts as a view for an underlying |
40 |
40 |
|
* {@link MutableTableModel}. |
|
@@ -45,62 +45,52 @@ |
45 |
45 |
|
HasPageCountChangeHandlers, |
46 |
46 |
|
HasPageLoadHandlers, |
47 |
47 |
|
HasPageChangeHandlers, |
48 |
|
- |
HasPagingFailureHandlers |
49 |
|
- |
{ |
|
48 |
+ |
HasPagingFailureHandlers { |
50 |
49 |
|
/** |
51 |
50 |
|
* A custom {@link AbstractCellView} used by the {@link PagingScrollTable}. |
52 |
51 |
|
* |
53 |
52 |
|
* @param <RowType> the type of the row values |
54 |
53 |
|
*/ |
55 |
|
- |
protected static class PagingScrollTableCellView<RowType> extends AbstractCellView<RowType> |
56 |
|
- |
{ |
|
54 |
+ |
protected static class PagingScrollTableCellView<RowType> extends AbstractCellView<RowType> { |
57 |
55 |
|
private PagingScrollTable<RowType> table; |
58 |
56 |
|
|
59 |
|
- |
public PagingScrollTableCellView( PagingScrollTable<RowType> table ) |
60 |
|
- |
{ |
|
57 |
+ |
public PagingScrollTableCellView( PagingScrollTable<RowType> table ) { |
61 |
58 |
|
super( table ); |
62 |
59 |
|
this.table = table; |
63 |
60 |
|
} |
64 |
61 |
|
|
65 |
62 |
|
@Override |
66 |
|
- |
public void setHorizontalAlignment( HorizontalAlignmentConstant align ) |
67 |
|
- |
{ |
|
63 |
+ |
public void setHorizontalAlignment( HorizontalAlignmentConstant align ) { |
68 |
64 |
|
table.getDataTable().getCellFormatter().setHorizontalAlignment( getRowIndex(), getCellIndex(), align ); |
69 |
65 |
|
} |
70 |
66 |
|
|
71 |
67 |
|
@Override |
72 |
|
- |
public void setHTML( String html ) |
73 |
|
- |
{ |
|
68 |
+ |
public void setHTML( String html ) { |
74 |
69 |
|
table.getDataTable().setHTML( getRowIndex(), getCellIndex(), html ); |
75 |
70 |
|
} |
76 |
71 |
|
|
77 |
72 |
|
@Override |
78 |
|
- |
public void setStyleAttribute( String attr, String value ) |
79 |
|
- |
{ |
|
73 |
+ |
public void setStyleAttribute( String attr, String value ) { |
80 |
74 |
|
table.getDataTable().getFixedWidthGridCellFormatter().getRawElement( getRowIndex(), getCellIndex() ).getStyle().setProperty( attr, value ); |
81 |
75 |
|
} |
82 |
76 |
|
|
83 |
77 |
|
@Override |
84 |
|
- |
public void setStyleName( String stylename ) |
85 |
|
- |
{ |
|
78 |
+ |
public void setStyleName( String stylename ) { |
86 |
79 |
|
table.getDataTable().getCellFormatter().setStyleName( getRowIndex(), getCellIndex(), stylename ); |
87 |
80 |
|
} |
88 |
81 |
|
|
89 |
82 |
|
@Override |
90 |
|
- |
public void setText( String text ) |
91 |
|
- |
{ |
|
83 |
+ |
public void setText( String text ) { |
92 |
84 |
|
table.getDataTable().setText( getRowIndex(), getCellIndex(), text ); |
93 |
85 |
|
} |
94 |
86 |
|
|
95 |
87 |
|
@Override |
96 |
|
- |
public void setVerticalAlignment( VerticalAlignmentConstant align ) |
97 |
|
- |
{ |
|
88 |
+ |
public void setVerticalAlignment( VerticalAlignmentConstant align ) { |
98 |
89 |
|
table.getDataTable().getCellFormatter().setVerticalAlignment( getRowIndex(), getCellIndex(), align ); |
99 |
90 |
|
} |
100 |
91 |
|
|
101 |
92 |
|
@Override |
102 |
|
- |
public void setWidget( Widget widget ) |
103 |
|
- |
{ |
|
93 |
+ |
public void setWidget( Widget widget ) { |
104 |
94 |
|
table.getDataTable().setWidget( getRowIndex(), getCellIndex(), widget ); |
105 |
95 |
|
} |
106 |
96 |
|
} |
|
@@ -110,28 +100,23 @@ |
110 |
100 |
|
* |
111 |
101 |
|
* @param <RowType> the type of the row values |
112 |
102 |
|
*/ |
113 |
|
- |
protected static class PagingScrollTableRowView<RowType> extends AbstractRowView<RowType> |
114 |
|
- |
{ |
|
103 |
+ |
protected static class PagingScrollTableRowView<RowType> extends AbstractRowView<RowType> { |
115 |
104 |
|
private PagingScrollTable<RowType> table; |
116 |
105 |
|
|
117 |
|
- |
public PagingScrollTableRowView( PagingScrollTable<RowType> table ) |
118 |
|
- |
{ |
|
106 |
+ |
public PagingScrollTableRowView( PagingScrollTable<RowType> table ) { |
119 |
107 |
|
super( new PagingScrollTableCellView<RowType>( table ) ); |
120 |
108 |
|
this.table = table; |
121 |
109 |
|
} |
122 |
110 |
|
|
123 |
111 |
|
@Override |
124 |
|
- |
public void setStyleAttribute( String attr, String value ) |
125 |
|
- |
{ |
|
112 |
+ |
public void setStyleAttribute( String attr, String value ) { |
126 |
113 |
|
table.getDataTable().getFixedWidthGridRowFormatter().getRawElement( getRowIndex() ).getStyle().setProperty( attr, value ); |
127 |
114 |
|
} |
128 |
115 |
|
|
129 |
116 |
|
@Override |
130 |
|
- |
public void setStyleName( String stylename ) |
131 |
|
- |
{ |
|
117 |
+ |
public void setStyleName( String stylename ) { |
132 |
118 |
|
// If the row is selected, add the selected style name back |
133 |
|
- |
if ( table.getDataTable().isRowSelected( getRowIndex() ) ) |
134 |
|
- |
{ |
|
119 |
+ |
if ( table.getDataTable().isRowSelected( getRowIndex() ) ) { |
135 |
120 |
|
stylename += " selected"; |
136 |
121 |
|
} |
137 |
122 |
|
table.getDataTable().getRowFormatter().setStyleName( getRowIndex(), stylename ); |
|
@@ -141,49 +126,40 @@ |
141 |
126 |
|
/** |
142 |
127 |
|
* Information about a column header. |
143 |
128 |
|
*/ |
144 |
|
- |
private static class ColumnHeaderInfo |
145 |
|
- |
{ |
|
129 |
+ |
private static class ColumnHeaderInfo { |
146 |
130 |
|
private int rowSpan = 1; |
147 |
131 |
|
private Object header; |
148 |
132 |
|
|
149 |
|
- |
public ColumnHeaderInfo( Object header ) |
150 |
|
- |
{ |
|
133 |
+ |
public ColumnHeaderInfo( Object header ) { |
151 |
134 |
|
this.header = (header == null) ? "" : header; |
152 |
135 |
|
} |
153 |
136 |
|
|
154 |
|
- |
public ColumnHeaderInfo( Object header, int rowSpan ) |
155 |
|
- |
{ |
|
137 |
+ |
public ColumnHeaderInfo( Object header, int rowSpan ) { |
156 |
138 |
|
this.header = (header == null) ? HTMLConstants.NBSP : header; |
157 |
139 |
|
this.rowSpan = rowSpan; |
158 |
140 |
|
} |
159 |
141 |
|
|
160 |
142 |
|
@Override |
161 |
|
- |
public boolean equals( Object o ) |
162 |
|
- |
{ |
163 |
|
- |
if ( o == null ) |
164 |
|
- |
{ |
|
143 |
+ |
public boolean equals( Object o ) { |
|
144 |
+ |
if ( o == null ) { |
165 |
145 |
|
return false; |
166 |
146 |
|
} |
167 |
|
- |
if ( o instanceof ColumnHeaderInfo ) |
168 |
|
- |
{ |
|
147 |
+ |
if ( o instanceof ColumnHeaderInfo ) { |
169 |
148 |
|
ColumnHeaderInfo info = (ColumnHeaderInfo) o; |
170 |
149 |
|
return (rowSpan == info.rowSpan) && header.equals( info.header ); |
171 |
150 |
|
} |
172 |
151 |
|
return false; |
173 |
152 |
|
} |
174 |
153 |
|
|
175 |
|
- |
public Object getHeader() |
176 |
|
- |
{ |
|
154 |
+ |
public Object getHeader() { |
177 |
155 |
|
return header; |
178 |
156 |
|
} |
179 |
157 |
|
|
180 |
|
- |
public int getRowSpan() |
181 |
|
- |
{ |
|
158 |
+ |
public int getRowSpan() { |
182 |
159 |
|
return rowSpan; |
183 |
160 |
|
} |
184 |
161 |
|
|
185 |
|
- |
public void incrementRowSpan() |
186 |
|
- |
{ |
|
162 |
+ |
public void incrementRowSpan() { |
187 |
163 |
|
rowSpan++; |
188 |
164 |
|
} |
189 |
165 |
|
} |
|
@@ -191,8 +167,7 @@ |
191 |
167 |
|
/** |
192 |
168 |
|
* An iterator over the visible rows in an iterator over many rows. |
193 |
169 |
|
*/ |
194 |
|
- |
private class VisibleRowsIterator implements Iterator<RowType> |
195 |
|
- |
{ |
|
170 |
+ |
private class VisibleRowsIterator implements Iterator<RowType> { |
196 |
171 |
|
/** |
197 |
172 |
|
* The iterator of row data. |
198 |
173 |
|
*/ |
|
@@ -216,37 +191,31 @@ |
216 |
191 |
|
* @param firstVisibleRow the first visible row in this grid |
217 |
192 |
|
* @param lastVisibleRow the last visible row in this grid |
218 |
193 |
|
*/ |
219 |
|
- |
public VisibleRowsIterator( Iterator<RowType> rows, int firstRow, int firstVisibleRow, int lastVisibleRow ) |
220 |
|
- |
{ |
|
194 |
+ |
public VisibleRowsIterator( Iterator<RowType> rows, int firstRow, int firstVisibleRow, int lastVisibleRow ) { |
221 |
195 |
|
this.curRow = firstRow; |
222 |
196 |
|
this.lastVisibleRow = lastVisibleRow; |
223 |
197 |
|
|
224 |
198 |
|
// Iterate up to the first row |
225 |
|
- |
while ( curRow < firstVisibleRow && rows.hasNext() ) |
226 |
|
- |
{ |
|
199 |
+ |
while ( curRow < firstVisibleRow && rows.hasNext() ) { |
227 |
200 |
|
rows.next(); |
228 |
201 |
|
curRow++; |
229 |
202 |
|
} |
230 |
203 |
|
this.rows = rows; |
231 |
204 |
|
} |
232 |
205 |
|
|
233 |
|
- |
public boolean hasNext() |
234 |
|
- |
{ |
|
206 |
+ |
public boolean hasNext() { |
235 |
207 |
|
return (curRow <= lastVisibleRow && rows.hasNext()); |
236 |
208 |
|
} |
237 |
209 |
|
|
238 |
|
- |
public RowType next() |
239 |
|
- |
{ |
|
210 |
+ |
public RowType next() { |
240 |
211 |
|
// Check that the next row exists |
241 |
|
- |
if ( !hasNext() ) |
242 |
|
- |
{ |
|
212 |
+ |
if ( !hasNext() ) { |
243 |
213 |
|
throw new NoSuchElementException(); |
244 |
214 |
|
} |
245 |
215 |
|
return rows.next(); |
246 |
216 |
|
} |
247 |
217 |
|
|
248 |
|
- |
public void remove() |
249 |
|
- |
{ |
|
218 |
+ |
public void remove() { |
250 |
219 |
|
throw new UnsupportedOperationException( "Remove not supported" ); |
251 |
220 |
|
} |
252 |
221 |
|
} |
|
@@ -315,18 +284,14 @@ |
315 |
284 |
|
/** |
316 |
285 |
|
* The callback that handles page requests. |
317 |
286 |
|
*/ |
318 |
|
- |
private Callback<RowType> pagingCallback = new Callback<RowType>() |
319 |
|
- |
{ |
320 |
|
- |
public void onFailure( Throwable caught ) |
321 |
|
- |
{ |
|
287 |
+ |
private Callback<RowType> pagingCallback = new Callback<RowType>() { |
|
288 |
+ |
public void onFailure( Throwable caught ) { |
322 |
289 |
|
isPageLoading = false; |
323 |
290 |
|
fireEvent( new PagingFailureEvent( caught ) ); |
324 |
291 |
|
} |
325 |
292 |
|
|
326 |
|
- |
public void onRowsReady( Request request, Response<RowType> response ) |
327 |
|
- |
{ |
328 |
|
- |
if ( lastRequest == request ) |
329 |
|
- |
{ |
|
293 |
+ |
public void onRowsReady( Request request, Response<RowType> response ) { |
|
294 |
+ |
if ( lastRequest == request ) { |
330 |
295 |
|
setData( request.getStartRow(), response.getRowValues() ); |
331 |
296 |
|
lastRequest = null; |
332 |
297 |
|
} |
|
@@ -357,10 +322,8 @@ |
357 |
322 |
|
/** |
358 |
323 |
|
* The {@link RendererCallback} used when table rendering completes. |
359 |
324 |
|
*/ |
360 |
|
- |
private RendererCallback tableRendererCallback = new RendererCallback() |
361 |
|
- |
{ |
362 |
|
- |
public void onRendered() |
363 |
|
- |
{ |
|
325 |
+ |
private RendererCallback tableRendererCallback = new RendererCallback() { |
|
326 |
+ |
public void onRendered() { |
364 |
327 |
|
onDataTableRendered(); |
365 |
328 |
|
} |
366 |
329 |
|
}; |
|
@@ -381,8 +344,7 @@ |
381 |
344 |
|
* @param tableModel the underlying table model |
382 |
345 |
|
* @param tableDefinition the column definitions |
383 |
346 |
|
*/ |
384 |
|
- |
public PagingScrollTable( TableModel<RowType> tableModel, TableDefinition<RowType> tableDefinition ) |
385 |
|
- |
{ |
|
347 |
+ |
public PagingScrollTable( TableModel<RowType> tableModel, TableDefinition<RowType> tableDefinition ) { |
386 |
348 |
|
this( tableModel, new FixedWidthGrid(), new FixedWidthFlexTable(), tableDefinition ); |
387 |
349 |
|
isHeaderGenerated = true; |
388 |
350 |
|
isFooterGenerated = true; |
|
@@ -396,8 +358,8 @@ |
396 |
358 |
|
* @param headerTable the header table |
397 |
359 |
|
* @param tableDefinition the column definitions |
398 |
360 |
|
*/ |
399 |
|
- |
public PagingScrollTable( TableModel<RowType> tableModel, FixedWidthGrid dataTable, FixedWidthFlexTable headerTable, TableDefinition<RowType> tableDefinition ) |
400 |
|
- |
{ |
|
361 |
+ |
public PagingScrollTable( TableModel<RowType> tableModel, FixedWidthGrid dataTable, FixedWidthFlexTable headerTable, |
|
362 |
+ |
TableDefinition<RowType> tableDefinition ) { |
401 |
363 |
|
super( dataTable, headerTable ); |
402 |
364 |
|
this.tableModel = tableModel; |
403 |
365 |
|
setTableDefinition( tableDefinition ); |
|
@@ -414,47 +376,34 @@ |
414 |
376 |
|
setEmptyTableWidgetVisible( false ); |
415 |
377 |
|
|
416 |
378 |
|
// Listen to table model events |
417 |
|
- |
tableModel.addRowCountChangeHandler( new RowCountChangeHandler() |
418 |
|
- |
{ |
419 |
|
- |
public void onRowCountChange( RowCountChangeEvent event ) |
420 |
|
- |
{ |
|
379 |
+ |
tableModel.addRowCountChangeHandler( new RowCountChangeHandler() { |
|
380 |
+ |
public void onRowCountChange( RowCountChangeEvent event ) { |
421 |
381 |
|
int pageCount = getPageCount(); |
422 |
|
- |
if ( pageCount != oldPageCount ) |
423 |
|
- |
{ |
|
382 |
+ |
if ( pageCount != oldPageCount ) { |
424 |
383 |
|
fireEvent( new PageCountChangeEvent( oldPageCount, pageCount ) ); |
425 |
384 |
|
oldPageCount = pageCount; |
426 |
385 |
|
} |
427 |
386 |
|
} |
428 |
387 |
|
} ); |
429 |
|
- |
if ( tableModel instanceof HasRowInsertionHandlers ) |
430 |
|
- |
{ |
431 |
|
- |
((HasRowInsertionHandlers) tableModel).addRowInsertionHandler( new RowInsertionHandler() |
432 |
|
- |
{ |
433 |
|
- |
public void onRowInsertion( RowInsertionEvent event ) |
434 |
|
- |
{ |
|
388 |
+ |
if ( tableModel instanceof HasRowInsertionHandlers ) { |
|
389 |
+ |
((HasRowInsertionHandlers) tableModel).addRowInsertionHandler( new RowInsertionHandler() { |
|
390 |
+ |
public void onRowInsertion( RowInsertionEvent event ) { |
435 |
391 |
|
insertAbsoluteRow( event.getRowIndex() ); |
436 |
392 |
|
} |
437 |
393 |
|
} ); |
438 |
394 |
|
} |
439 |
|
- |
if ( tableModel instanceof HasRowRemovalHandlers ) |
440 |
|
- |
{ |
441 |
|
- |
((HasRowRemovalHandlers) tableModel).addRowRemovalHandler( new RowRemovalHandler() |
442 |
|
- |
{ |
443 |
|
- |
public void onRowRemoval( RowRemovalEvent event ) |
444 |
|
- |
{ |
|
395 |
+ |
if ( tableModel instanceof HasRowRemovalHandlers ) { |
|
396 |
+ |
((HasRowRemovalHandlers) tableModel).addRowRemovalHandler( new RowRemovalHandler() { |
|
397 |
+ |
public void onRowRemoval( RowRemovalEvent event ) { |
445 |
398 |
|
removeAbsoluteRow( event.getRowIndex() ); |
446 |
399 |
|
} |
447 |
400 |
|
} ); |
448 |
401 |
|
} |
449 |
|
- |
if ( tableModel instanceof HasRowValueChangeHandlers ) |
450 |
|
- |
{ |
451 |
|
- |
((HasRowValueChangeHandlers<RowType>) tableModel).addRowValueChangeHandler( new RowValueChangeHandler<RowType>() |
452 |
|
- |
{ |
453 |
|
- |
public void onRowValueChange( RowValueChangeEvent<RowType> event ) |
454 |
|
- |
{ |
|
402 |
+ |
if ( tableModel instanceof HasRowValueChangeHandlers ) { |
|
403 |
+ |
((HasRowValueChangeHandlers<RowType>) tableModel).addRowValueChangeHandler( new RowValueChangeHandler<RowType>() { |
|
404 |
+ |
public void onRowValueChange( RowValueChangeEvent<RowType> event ) { |
455 |
405 |
|
int rowIndex = event.getRowIndex(); |
456 |
|
- |
if ( rowIndex < getAbsoluteFirstRowIndex() || rowIndex > getAbsoluteLastRowIndex() ) |
457 |
|
- |
{ |
|
406 |
+ |
if ( rowIndex < getAbsoluteFirstRowIndex() || rowIndex > getAbsoluteLastRowIndex() ) { |
458 |
407 |
|
return; |
459 |
408 |
|
} |
460 |
409 |
|
setRowValue( rowIndex - getAbsoluteFirstRowIndex(), event.getRowValue() ); |
|
@@ -463,22 +412,17 @@ |
463 |
412 |
|
} |
464 |
413 |
|
|
465 |
414 |
|
// Listen for cell click events |
466 |
|
- |
dataTable.addTableListener( new TableListener() |
467 |
|
- |
{ |
468 |
|
- |
public void onCellClicked( SourcesTableEvents sender, int row, int cell ) |
469 |
|
- |
{ |
|
415 |
+ |
dataTable.addTableListener( new TableListener() { |
|
416 |
+ |
public void onCellClicked( SourcesTableEvents sender, int row, int cell ) { |
470 |
417 |
|
editCell( row, cell ); |
471 |
418 |
|
} |
472 |
419 |
|
} ); |
473 |
420 |
|
|
474 |
421 |
|
// Override the column sorter |
475 |
|
- |
if ( dataTable.getColumnSorter() == null ) |
476 |
|
- |
{ |
477 |
|
- |
ColumnSorter sorter = new ColumnSorter() |
478 |
|
- |
{ |
|
422 |
+ |
if ( dataTable.getColumnSorter() == null ) { |
|
423 |
+ |
ColumnSorter sorter = new ColumnSorter() { |
479 |
424 |
|
@Override |
480 |
|
- |
public void onSortColumn( SortableGrid grid, ColumnSortList sortList, ColumnSorterCallback callback ) |
481 |
|
- |
{ |
|
425 |
+ |
public void onSortColumn( SortableGrid grid, ColumnSortList sortList, ColumnSorterCallback callback ) { |
482 |
426 |
|
reloadPage(); |
483 |
427 |
|
callback.onSortingComplete(); |
484 |
428 |
|
} |
|
@@ -487,68 +431,54 @@ |
487 |
431 |
|
} |
488 |
432 |
|
|
489 |
433 |
|
// Listen for selection events |
490 |
|
- |
dataTable.addRowSelectionHandler( new RowSelectionHandler() |
491 |
|
- |
{ |
492 |
|
- |
public void onRowSelection( RowSelectionEvent event ) |
493 |
|
- |
{ |
494 |
|
- |
if ( isPageLoading ) |
495 |
|
- |
{ |
|
434 |
+ |
dataTable.addRowSelectionHandler( new RowSelectionHandler() { |
|
435 |
+ |
public void onRowSelection( RowSelectionEvent event ) { |
|
436 |
+ |
if ( isPageLoading ) { |
496 |
437 |
|
return; |
497 |
438 |
|
} |
498 |
439 |
|
Set<Row> deselected = event.getDeselectedRows(); |
499 |
|
- |
for ( Row row : deselected ) |
500 |
|
- |
{ |
|
440 |
+ |
for ( Row row : deselected ) { |
501 |
441 |
|
selectedRowValues.remove( getRowValue( row.getRowIndex() ) ); |
502 |
442 |
|
} |
503 |
443 |
|
Set<Row> selected = event.getSelectedRows(); |
504 |
|
- |
for ( Row row : selected ) |
505 |
|
- |
{ |
|
444 |
+ |
for ( Row row : selected ) { |
506 |
445 |
|
selectedRowValues.add( getRowValue( row.getRowIndex() ) ); |
507 |
446 |
|
} |
508 |
447 |
|
} |
509 |
448 |
|
} ); |
510 |
449 |
|
} |
511 |
450 |
|
|
512 |
|
- |
public HandlerRegistration addPageChangeHandler( PageChangeHandler handler ) |
513 |
|
- |
{ |
|
451 |
+ |
public HandlerRegistration addPageChangeHandler( PageChangeHandler handler ) { |
514 |
452 |
|
return addHandler( PageChangeEvent.TYPE, handler ); |
515 |
453 |
|
} |
516 |
454 |
|
|
517 |
|
- |
public HandlerRegistration addPageCountChangeHandler( PageCountChangeHandler handler ) |
518 |
|
- |
{ |
|
455 |
+ |
public HandlerRegistration addPageCountChangeHandler( PageCountChangeHandler handler ) { |
519 |
456 |
|
return addHandler( PageCountChangeEvent.TYPE, handler ); |
520 |
457 |
|
} |
521 |
458 |
|
|
522 |
|
- |
public HandlerRegistration addPageLoadHandler( PageLoadHandler handler ) |
523 |
|
- |
{ |
|
459 |
+ |
public HandlerRegistration addPageLoadHandler( PageLoadHandler handler ) { |
524 |
460 |
|
return addHandler( PageLoadEvent.TYPE, handler ); |
525 |
461 |
|
} |
526 |
462 |
|
|
527 |
|
- |
public HandlerRegistration addPagingFailureHandler( PagingFailureHandler handler ) |
528 |
|
- |
{ |
|
463 |
+ |
public HandlerRegistration addPagingFailureHandler( PagingFailureHandler handler ) { |
529 |
464 |
|
return addHandler( PagingFailureEvent.TYPE, handler ); |
530 |
465 |
|
} |
531 |
466 |
|
|
532 |
467 |
|
/** |
533 |
468 |
|
* @return the absolute index of the first visible row |
534 |
469 |
|
*/ |
535 |
|
- |
public int getAbsoluteFirstRowIndex() |
536 |
|
- |
{ |
|
470 |
+ |
public int getAbsoluteFirstRowIndex() { |
537 |
471 |
|
return currentPage * pageSize; |
538 |
472 |
|
} |
539 |
473 |
|
|
540 |
474 |
|
/** |
541 |
475 |
|
* @return the absolute index of the last visible row |
542 |
476 |
|
*/ |
543 |
|
- |
public int getAbsoluteLastRowIndex() |
544 |
|
- |
{ |
545 |
|
- |
if ( tableModel.getRowCount() < 0 ) |
546 |
|
- |
{ |
|
477 |
+ |
public int getAbsoluteLastRowIndex() { |
|
478 |
+ |
if ( tableModel.getRowCount() < 0 ) { |
547 |
479 |
|
// Unknown row count, so just return based on current page |
548 |
480 |
|
return (currentPage + 1) * pageSize - 1; |
549 |
|
- |
} |
550 |
|
- |
else if ( pageSize == 0 ) |
551 |
|
- |
{ |
|
481 |
+ |
} else if ( pageSize == 0 ) { |
552 |
482 |
|
// Only one page, so return row count |
553 |
483 |
|
return tableModel.getRowCount() - 1; |
554 |
484 |
|
} |
|
@@ -558,36 +488,30 @@ |
558 |
488 |
|
/** |
559 |
489 |
|
* @return the current page |
560 |
490 |
|
*/ |
561 |
|
- |
public int getCurrentPage() |
562 |
|
- |
{ |
|
491 |
+ |
public int getCurrentPage() { |
563 |
492 |
|
return currentPage; |
564 |
493 |
|
} |
565 |
494 |
|
|
566 |
495 |
|
/** |
567 |
496 |
|
* @return the widget displayed when the data table is empty |
568 |
497 |
|
*/ |
569 |
|
- |
public Widget getEmptyTableWidget() |
570 |
|
- |
{ |
|
498 |
+ |
public Widget getEmptyTableWidget() { |
571 |
499 |
|
return emptyTableWidgetWrapper.getWidget(); |
572 |
500 |
|
} |
573 |
501 |
|
|
574 |
502 |
|
@Override |
575 |
|
- |
public int getMaximumColumnWidth( int column ) |
576 |
|
- |
{ |
|
503 |
+ |
public int getMaximumColumnWidth( int column ) { |
577 |
504 |
|
ColumnDefinition<RowType, ?> colDef = getColumnDefinition( column ); |
578 |
|
- |
if ( colDef == null ) |
579 |
|
- |
{ |
|
505 |
+ |
if ( colDef == null ) { |
580 |
506 |
|
return -1; |
581 |
507 |
|
} |
582 |
508 |
|
return colDef.getColumnProperty( MaximumWidthProperty.TYPE ).getMaximumColumnWidth(); |
583 |
509 |
|
} |
584 |
510 |
|
|
585 |
511 |
|
@Override |
586 |
|
- |
public int getMinimumColumnWidth( int column ) |
587 |
|
- |
{ |
|
512 |
+ |
public int getMinimumColumnWidth( int column ) { |
588 |
513 |
|
ColumnDefinition<RowType, ?> colDef = getColumnDefinition( column ); |
589 |
|
- |
if ( colDef == null ) |
590 |
|
- |
{ |
|
514 |
+ |
if ( colDef == null ) { |
591 |
515 |
|
return FixedWidthGrid.MIN_COLUMN_WIDTH; |
592 |
516 |
|
} |
593 |
517 |
|
int minWidth = colDef.getColumnProperty( MinimumWidthProperty.TYPE ).getMinimumColumnWidth(); |
|
@@ -597,17 +521,12 @@ |
597 |
521 |
|
/** |
598 |
522 |
|
* @return the number of pages, or -1 if not known |
599 |
523 |
|
*/ |
600 |
|
- |
public int getPageCount() |
601 |
|
- |
{ |
602 |
|
- |
if ( pageSize < 1 ) |
603 |
|
- |
{ |
|
524 |
+ |
public int getPageCount() { |
|
525 |
+ |
if ( pageSize < 1 ) { |
604 |
526 |
|
return 1; |
605 |
|
- |
} |
606 |
|
- |
else |
607 |
|
- |
{ |
|
527 |
+ |
} else { |
608 |
528 |
|
int numDataRows = tableModel.getRowCount(); |
609 |
|
- |
if ( numDataRows < 0 ) |
610 |
|
- |
{ |
|
529 |
+ |
if ( numDataRows < 0 ) { |
611 |
530 |
|
return -1; |
612 |
531 |
|
} |
613 |
532 |
|
return (int) Math.ceil( numDataRows / (pageSize + 0.0) ); |
|
@@ -617,17 +536,14 @@ |
617 |
536 |
|
/** |
618 |
537 |
|
* @return the number of rows per page |
619 |
538 |
|
*/ |
620 |
|
- |
public int getPageSize() |
621 |
|
- |
{ |
|
539 |
+ |
public int getPageSize() { |
622 |
540 |
|
return pageSize; |
623 |
541 |
|
} |
624 |
542 |
|
|
625 |
543 |
|
@Override |
626 |
|
- |
public int getPreferredColumnWidth( int column ) |
627 |
|
- |
{ |
|
544 |
+ |
public int getPreferredColumnWidth( int column ) { |
628 |
545 |
|
ColumnDefinition<RowType, ?> colDef = getColumnDefinition( column ); |
629 |
|
- |
if ( colDef == null ) |
630 |
|
- |
{ |
|
546 |
+ |
if ( colDef == null ) { |
631 |
547 |
|
return FixedWidthGrid.DEFAULT_COLUMN_WIDTH; |
632 |
548 |
|
} |
633 |
549 |
|
return colDef.getColumnProperty( PreferredWidthProperty.TYPE ).getPreferredColumnWidth(); |
|
@@ -640,10 +556,8 @@ |
640 |
556 |
|
* |
641 |
557 |
|
* @return the value associated with the row |
642 |
558 |
|
*/ |
643 |
|
- |
public RowType getRowValue( int row ) |
644 |
|
- |
{ |
645 |
|
- |
if ( rowValues.size() <= row ) |
646 |
|
- |
{ |
|
559 |
+ |
public RowType getRowValue( int row ) { |
|
560 |
+ |
if ( rowValues.size() <= row ) { |
647 |
561 |
|
return null; |
648 |
562 |
|
} |
649 |
563 |
|
return rowValues.get( row ); |
|
@@ -657,29 +571,25 @@ |
657 |
571 |
|
* |
658 |
572 |
|
* @see #setCrossPageSelectionEnabled(boolean) |
659 |
573 |
|
*/ |
660 |
|
- |
public Set<RowType> getSelectedRowValues() |
661 |
|
- |
{ |
|
574 |
+ |
public Set<RowType> getSelectedRowValues() { |
662 |
575 |
|
return selectedRowValues; |
663 |
576 |
|
} |
664 |
577 |
|
|
665 |
|
- |
public TableDefinition<RowType> getTableDefinition() |
666 |
|
- |
{ |
|
578 |
+ |
public TableDefinition<RowType> getTableDefinition() { |
667 |
579 |
|
return tableDefinition; |
668 |
580 |
|
} |
669 |
581 |
|
|
670 |
582 |
|
/** |
671 |
583 |
|
* @return the table model |
672 |
584 |
|
*/ |
673 |
|
- |
public TableModel<RowType> getTableModel() |
674 |
|
- |
{ |
|
585 |
+ |
public TableModel<RowType> getTableModel() { |
675 |
586 |
|
return tableModel; |
676 |
587 |
|
} |
677 |
588 |
|
|
678 |
589 |
|
/** |
679 |
590 |
|
* Go to the first page. |
680 |
591 |
|
*/ |
681 |
|
- |
public void gotoFirstPage() |
682 |
|
- |
{ |
|
592 |
+ |
public void gotoFirstPage() { |
683 |
593 |
|
gotoPage( 0, false ); |
684 |
594 |
|
} |
685 |
595 |
|
|
|
@@ -687,10 +597,8 @@ |
687 |
597 |
|
* Go to the last page. If the number of pages is not known, this method is |
688 |
598 |
|
* ignored. |
689 |
599 |
|
*/ |
690 |
|
- |
public void gotoLastPage() |
691 |
|
- |
{ |
692 |
|
- |
if ( getPageCount() >= 0 ) |
693 |
|
- |
{ |
|
600 |
+ |
public void gotoLastPage() { |
|
601 |
+ |
if ( getPageCount() >= 0 ) { |
694 |
602 |
|
gotoPage( getPageCount(), false ); |
695 |
603 |
|
} |
696 |
604 |
|
} |
|
@@ -698,8 +606,7 @@ |
698 |
606 |
|
/** |
699 |
607 |
|
* Go to the next page. |
700 |
608 |
|
*/ |
701 |
|
- |
public void gotoNextPage() |
702 |
|
- |
{ |
|
609 |
+ |
public void gotoNextPage() { |
703 |
610 |
|
gotoPage( currentPage + 1, false ); |
704 |
611 |
|
} |
705 |
612 |
|
|
|
@@ -710,28 +617,22 @@ |
710 |
617 |
|
* @param page the page |
711 |
618 |
|
* @param forced reload the page even if it is already loaded |
712 |
619 |
|
*/ |
713 |
|
- |
public void gotoPage( int page, boolean forced ) |
714 |
|
- |
{ |
|
620 |
+ |
public void gotoPage( int page, boolean forced ) { |
715 |
621 |
|
int oldPage = currentPage; |
716 |
622 |
|
int numPages = getPageCount(); |
717 |
|
- |
if ( numPages >= 0 ) |
718 |
|
- |
{ |
|
623 |
+ |
if ( numPages >= 0 ) { |
719 |
624 |
|
currentPage = Math.max( 0, Math.min( page, numPages - 1 ) ); |
720 |
|
- |
} |
721 |
|
- |
else |
722 |
|
- |
{ |
|
625 |
+ |
} else { |
723 |
626 |
|
currentPage = page; |
724 |
627 |
|
} |
725 |
628 |
|
|
726 |
|
- |
if ( currentPage != oldPage || forced ) |
727 |
|
- |
{ |
|
629 |
+ |
if ( currentPage != oldPage || forced ) { |
728 |
630 |
|
isPageLoading = true; |
729 |
631 |
|
|
730 |
632 |
|
// Deselect rows when switching pages |
731 |
633 |
|
FixedWidthGrid dataTable = getDataTable(); |
732 |
634 |
|
dataTable.deselectAllRows(); |
733 |
|
- |
if ( !isCrossPageSelectionEnabled ) |
734 |
|
- |
{ |
|
635 |
+ |
if ( !isCrossPageSelectionEnabled ) { |
735 |
636 |
|
selectedRowValues = new HashSet<RowType>(); |
736 |
637 |
|
} |
737 |
638 |
|
|
|
@@ -739,11 +640,9 @@ |
739 |
640 |
|
fireEvent( new PageChangeEvent( oldPage, currentPage ) ); |
740 |
641 |
|
|
741 |
642 |
|
// Clear out existing data if we aren't bulk rendering |
742 |
|
- |
if ( bulkRenderer == null ) |
743 |
|
- |
{ |
|
643 |
+ |
if ( bulkRenderer == null ) { |
744 |
644 |
|
int rowCount = getAbsoluteLastRowIndex() - getAbsoluteFirstRowIndex() + 1; |
745 |
|
- |
if ( rowCount != dataTable.getRowCount() ) |
746 |
|
- |
{ |
|
645 |
+ |
if ( rowCount != dataTable.getRowCount() ) { |
747 |
646 |
|
dataTable.resizeRows( rowCount ); |
748 |
647 |
|
} |
749 |
648 |
|
dataTable.clearAll(); |
|
@@ -760,32 +659,26 @@ |
760 |
659 |
|
/** |
761 |
660 |
|
* Go to the previous page. |
762 |
661 |
|
*/ |
763 |
|
- |
public void gotoPreviousPage() |
764 |
|
- |
{ |
|
662 |
+ |
public void gotoPreviousPage() { |
765 |
663 |
|
gotoPage( currentPage - 1, false ); |
766 |
664 |
|
} |
767 |
665 |
|
|
768 |
666 |
|
@Override |
769 |
|
- |
public boolean isColumnSortable( int column ) |
770 |
|
- |
{ |
|
667 |
+ |
public boolean isColumnSortable( int column ) { |
771 |
668 |
|
ColumnDefinition<RowType, ?> colDef = getColumnDefinition( column ); |
772 |
|
- |
if ( colDef == null ) |
773 |
|
- |
{ |
|
669 |
+ |
if ( colDef == null ) { |
774 |
670 |
|
return true; |
775 |
671 |
|
} |
776 |
|
- |
if ( getSortPolicy() == SortPolicy.DISABLED ) |
777 |
|
- |
{ |
|
672 |
+ |
if ( getSortPolicy() == SortPolicy.DISABLED ) { |
778 |
673 |
|
return false; |
779 |
674 |
|
} |
780 |
675 |
|
return colDef.getColumnProperty( SortableProperty.TYPE ).isColumnSortable(); |
781 |
676 |
|
} |
782 |
677 |
|
|
783 |
678 |
|
@Override |
784 |
|
- |
public boolean isColumnTruncatable( int column ) |
785 |
|
- |
{ |
|
679 |
+ |
public boolean isColumnTruncatable( int column ) { |
786 |
680 |
|
ColumnDefinition<RowType, ?> colDef = getColumnDefinition( column ); |
787 |
|
- |
if ( colDef == null ) |
788 |
|
- |
{ |
|
681 |
+ |
if ( colDef == null ) { |
789 |
682 |
|
return true; |
790 |
683 |
|
} |
791 |
684 |
|
return colDef.getColumnProperty( TruncationProperty.TYPE ).isColumnTruncatable(); |
|
@@ -794,17 +687,14 @@ |
794 |
687 |
|
/** |
795 |
688 |
|
* @return true if cross page selection is enabled |
796 |
689 |
|
*/ |
797 |
|
- |
public boolean isCrossPageSelectionEnabled() |
798 |
|
- |
{ |
|
690 |
+ |
public boolean isCrossPageSelectionEnabled() { |
799 |
691 |
|
return isCrossPageSelectionEnabled; |
800 |
692 |
|
} |
801 |
693 |
|
|
802 |
694 |
|
@Override |
803 |
|
- |
public boolean isFooterColumnTruncatable( int column ) |
804 |
|
- |
{ |
|
695 |
+ |
public boolean isFooterColumnTruncatable( int column ) { |
805 |
696 |
|
ColumnDefinition<RowType, ?> colDef = getColumnDefinition( column ); |
806 |
|
- |
if ( colDef == null ) |
807 |
|
- |
{ |
|
697 |
+ |
if ( colDef == null ) { |
808 |
698 |
|
return true; |
809 |
699 |
|
} |
810 |
700 |
|
return colDef.getColumnProperty( TruncationProperty.TYPE ).isFooterTruncatable(); |
|
@@ -813,17 +703,14 @@ |
813 |
703 |
|
/** |
814 |
704 |
|
* @return true if the footer table is automatically generated |
815 |
705 |
|
*/ |
816 |
|
- |
public boolean isFooterGenerated() |
817 |
|
- |
{ |
|
706 |
+ |
public boolean isFooterGenerated() { |
818 |
707 |
|
return isFooterGenerated; |
819 |
708 |
|
} |
820 |
709 |
|
|
821 |
710 |
|
@Override |
822 |
|
- |
public boolean isHeaderColumnTruncatable( int column ) |
823 |
|
- |
{ |
|
711 |
+ |
public boolean isHeaderColumnTruncatable( int column ) { |
824 |
712 |
|
ColumnDefinition<RowType, ?> colDef = getColumnDefinition( column ); |
825 |
|
- |
if ( colDef == null ) |
826 |
|
- |
{ |
|
713 |
+ |
if ( colDef == null ) { |
827 |
714 |
|
return true; |
828 |
715 |
|
} |
829 |
716 |
|
return colDef.getColumnProperty( TruncationProperty.TYPE ).isHeaderTruncatable(); |
|
@@ -832,30 +719,24 @@ |
832 |
719 |
|
/** |
833 |
720 |
|
* @return true if the header table is automatically generated |
834 |
721 |
|
*/ |
835 |
|
- |
public boolean isHeaderGenerated() |
836 |
|
- |
{ |
|
722 |
+ |
public boolean isHeaderGenerated() { |
837 |
723 |
|
return isHeaderGenerated; |
838 |
724 |
|
} |
839 |
725 |
|
|
840 |
726 |
|
/** |
841 |
727 |
|
* @return true if a page load is pending |
842 |
728 |
|
*/ |
843 |
|
- |
public boolean isPageLoading() |
844 |
|
- |
{ |
|
729 |
+ |
public boolean isPageLoading() { |
845 |
730 |
|
return isPageLoading; |
846 |
731 |
|
} |
847 |
732 |
|
|
848 |
733 |
|
/** |
849 |
734 |
|
* Reload the current page. |
850 |
735 |
|
*/ |
851 |
|
- |
public void reloadPage() |
852 |
|
- |
{ |
853 |
|
- |
if ( currentPage >= 0 ) |
854 |
|
- |
{ |
|
736 |
+ |
public void reloadPage() { |
|
737 |
+ |
if ( currentPage >= 0 ) { |
855 |
738 |
|
gotoPage( currentPage, true ); |
856 |
|
- |
} |
857 |
|
- |
else |
858 |
|
- |
{ |
|
739 |
+ |
} else { |
859 |
740 |
|
gotoPage( 0, true ); |
860 |
741 |
|
} |
861 |
742 |
|
} |
|
@@ -865,8 +746,7 @@ |
865 |
746 |
|
* |
866 |
747 |
|
* @param bulkRenderer the table renderer |
867 |
748 |
|
*/ |
868 |
|
- |
public void setBulkRenderer( FixedWidthGridBulkRenderer<RowType> bulkRenderer ) |
869 |
|
- |
{ |
|
749 |
+ |
public void setBulkRenderer( FixedWidthGridBulkRenderer<RowType> bulkRenderer ) { |
870 |
750 |
|
this.bulkRenderer = bulkRenderer; |
871 |
751 |
|
} |
872 |
752 |
|
|
|
@@ -878,19 +758,15 @@ |
878 |
758 |
|
* |
879 |
759 |
|
* @param enabled true to enable, false to disable |
880 |
760 |
|
*/ |
881 |
|
- |
public void setCrossPageSelectionEnabled( boolean enabled ) |
882 |
|
- |
{ |
883 |
|
- |
if ( isCrossPageSelectionEnabled != enabled ) |
884 |
|
- |
{ |
|
761 |
+ |
public void setCrossPageSelectionEnabled( boolean enabled ) { |
|
762 |
+ |
if ( isCrossPageSelectionEnabled != enabled ) { |
885 |
763 |
|
this.isCrossPageSelectionEnabled = enabled; |
886 |
764 |
|
|
887 |
765 |
|
// Reselected only the rows on this page |
888 |
|
- |
if ( !enabled ) |
889 |
|
- |
{ |
|
766 |
+ |
if ( !enabled ) { |
890 |
767 |
|
selectedRowValues = new HashSet<RowType>(); |
891 |
768 |
|
Set<Integer> selectedRows = getDataTable().getSelectedRows(); |
892 |
|
- |
for ( Integer selectedRow : selectedRows ) |
893 |
|
- |
{ |
|
769 |
+ |
for ( Integer selectedRow : selectedRows ) { |
894 |
770 |
|
selectedRowValues.add( getRowValue( selectedRow ) ); |
895 |
771 |
|
} |
896 |
772 |
|
} |
|
@@ -903,8 +779,7 @@ |
903 |
779 |
|
* |
904 |
780 |
|
* @param emptyTableWidget the widget to display when the data table is empty |
905 |
781 |
|
*/ |
906 |
|
- |
public void setEmptyTableWidget( Widget emptyTableWidget ) |
907 |
|
- |
{ |
|
782 |
+ |
public void setEmptyTableWidget( Widget emptyTableWidget ) { |
908 |
783 |
|
emptyTableWidgetWrapper.setWidget( emptyTableWidget ); |
909 |
784 |
|
} |
910 |
785 |
|
|
|
@@ -913,11 +788,9 @@ |
913 |
788 |
|
* |
914 |
789 |
|
* @param isGenerated true to enable, false to disable |
915 |
790 |
|
*/ |
916 |
|
- |
public void setFooterGenerated( boolean isGenerated ) |
917 |
|
- |
{ |
|
791 |
+ |
public void setFooterGenerated( boolean isGenerated ) { |
918 |
792 |
|
this.isFooterGenerated = isGenerated; |
919 |
|
- |
if ( isGenerated ) |
920 |
|
- |
{ |
|
793 |
+ |
if ( isGenerated ) { |
921 |
794 |
|
refreshFooterTable(); |
922 |
795 |
|
} |
923 |
796 |
|
} |
|
@@ -927,11 +800,9 @@ |
927 |
800 |
|
* |
928 |
801 |
|
* @param isGenerated true to enable, false to disable |
929 |
802 |
|
*/ |
930 |
|
- |
public void setHeaderGenerated( boolean isGenerated ) |
931 |
|
- |
{ |
|
803 |
+ |
public void setHeaderGenerated( boolean isGenerated ) { |
932 |
804 |
|
this.isHeaderGenerated = isGenerated; |
933 |
|
- |
if ( isGenerated ) |
934 |
|
- |
{ |
|
805 |
+ |
if ( isGenerated ) { |
935 |
806 |
|
refreshHeaderTable(); |
936 |
807 |
|
} |
937 |
808 |
|
} |
|
@@ -944,21 +815,18 @@ |
944 |
815 |
|
* |
945 |
816 |
|
* @param pageSize the number of rows per page |
946 |
817 |
|
*/ |
947 |
|
- |
public void setPageSize( int pageSize ) |
948 |
|
- |
{ |
|
818 |
+ |
public void setPageSize( int pageSize ) { |
949 |
819 |
|
pageSize = Math.max( 0, pageSize ); |
950 |
820 |
|
this.pageSize = pageSize; |
951 |
821 |
|
|
952 |
822 |
|
int pageCount = getPageCount(); |
953 |
|
- |
if ( pageCount != oldPageCount ) |
954 |
|
- |
{ |
|
823 |
+ |
if ( pageCount != oldPageCount ) { |
955 |
824 |
|
fireEvent( new PageCountChangeEvent( oldPageCount, pageCount ) ); |
956 |
825 |
|
oldPageCount = pageCount; |
957 |
826 |
|
} |
958 |
827 |
|
|
959 |
828 |
|
// Reset the page |
960 |
|
- |
if ( currentPage >= 0 ) |
961 |
|
- |
{ |
|
829 |
+ |
if ( currentPage >= 0 ) { |
962 |
830 |
|
gotoPage( currentPage, true ); |
963 |
831 |
|
} |
964 |
832 |
|
} |
|
@@ -969,11 +837,9 @@ |
969 |
837 |
|
* @param row the row index |
970 |
838 |
|
* @param value the value to associate |
971 |
839 |
|
*/ |
972 |
|
- |
public void setRowValue( int row, RowType value ) |
973 |
|
- |
{ |
|
840 |
+ |
public void setRowValue( int row, RowType value ) { |
974 |
841 |
|
// Make sure the list can fit the row |
975 |
|
- |
for ( int i = rowValues.size(); i <= row; i++ ) |
976 |
|
- |
{ |
|
842 |
+ |
for ( int i = rowValues.size(); i <= row; i++ ) { |
977 |
843 |
|
rowValues.add( null ); |
978 |
844 |
|
} |
979 |
845 |
|
|
|
@@ -989,8 +855,7 @@ |
989 |
855 |
|
* |
990 |
856 |
|
* @param tableDefinition the new table definition. |
991 |
857 |
|
*/ |
992 |
|
- |
public void setTableDefinition( TableDefinition<RowType> tableDefinition ) |
993 |
|
- |
{ |
|
858 |
+ |
public void setTableDefinition( TableDefinition<RowType> tableDefinition ) { |
994 |
859 |
|
assert tableDefinition != null : "tableDefinition cannot be null"; |
995 |
860 |
|
this.tableDefinition = tableDefinition; |
996 |
861 |
|
} |
|
@@ -999,39 +864,30 @@ |
999 |
864 |
|
* Invoke the cell editor on a cell, if one is set. If a cell editor is not |
1000 |
865 |
|
* specified, this method has no effect. |
1001 |
866 |
|
*/ |
1002 |
|
- |
protected void editCell( int row, int column ) |
1003 |
|
- |
{ |
|
867 |
+ |
protected void editCell( int row, int column ) { |
1004 |
868 |
|
// Get the cell editor |
1005 |
869 |
|
final ColumnDefinition colDef = getColumnDefinition( column ); |
1006 |
|
- |
if ( colDef == null ) |
1007 |
|
- |
{ |
|
870 |
+ |
if ( colDef == null ) { |
1008 |
871 |
|
return; |
1009 |
872 |
|
} |
1010 |
873 |
|
CellEditor cellEditor = colDef.getCellEditor(); |
1011 |
|
- |
if ( cellEditor == null ) |
1012 |
|
- |
{ |
|
874 |
+ |
if ( cellEditor == null ) { |
1013 |
875 |
|
return; |
1014 |
876 |
|
} |
1015 |
877 |
|
|
1016 |
878 |
|
// Forward the request to the cell editor |
1017 |
879 |
|
final RowType rowValue = getRowValue( row ); |
1018 |
880 |
|
CellEditInfo editInfo = new CellEditInfo( getDataTable(), row, column ); |
1019 |
|
- |
cellEditor.editCell( editInfo, colDef.getCellValue( rowValue ), new CellEditor.Callback() |
1020 |
|
- |
{ |
1021 |
|
- |
public void onCancel( CellEditInfo cellEditInfo ) |
1022 |
|
- |
{ |
|
881 |
+ |
cellEditor.editCell( editInfo, colDef.getCellValue( rowValue ), new CellEditor.Callback() { |
|
882 |
+ |
public void onCancel( CellEditInfo cellEditInfo ) { |
1023 |
883 |
|
} |
1024 |
884 |
|
|
1025 |
|
- |
public void onComplete( CellEditInfo cellEditInfo, Object cellValue ) |
1026 |
|
- |
{ |
|
885 |
+ |
public void onComplete( CellEditInfo cellEditInfo, Object cellValue ) { |
1027 |
886 |
|
colDef.setCellValue( rowValue, cellValue ); |
1028 |
|
- |
if ( tableModel instanceof MutableTableModel ) |
1029 |
|
- |
{ |
|
887 |
+ |
if ( tableModel instanceof MutableTableModel ) { |
1030 |
888 |
|
int row = getAbsoluteFirstRowIndex() + cellEditInfo.getRowIndex(); |
1031 |
889 |
|
((MutableTableModel<RowType>) tableModel).setRowValue( row, rowValue ); |
1032 |
|
- |
} |
1033 |
|
- |
else |
1034 |
|
- |
{ |
|
890 |
+ |
} else { |
1035 |
891 |
|
refreshRow( cellEditInfo.getRowIndex() ); |
1036 |
892 |
|
} |
1037 |
893 |
|
} |
|
@@ -1045,10 +901,8 @@ |
1045 |
901 |
|
* |
1046 |
902 |
|
* @return the {@link ColumnDefinition} associated with the column, or null |
1047 |
903 |
|
*/ |
1048 |
|
- |
protected ColumnDefinition<RowType, ?> getColumnDefinition( int colIndex ) |
1049 |
|
- |
{ |
1050 |
|
- |
if ( colIndex < visibleColumns.size() ) |
1051 |
|
- |
{ |
|
904 |
+ |
protected ColumnDefinition<RowType, ?> getColumnDefinition( int colIndex ) { |
|
905 |
+ |
if ( colIndex < visibleColumns.size() ) { |
1052 |
906 |
|
return visibleColumns.get( colIndex ); |
1053 |
907 |
|
} |
1054 |
908 |
|
return null; |
|
@@ -1060,8 +914,7 @@ |
1060 |
914 |
|
* @deprecated use {@link #getAbsoluteFirstRowIndex()} instead |
1061 |
915 |
|
*/ |
1062 |
916 |
|
@Deprecated |
1063 |
|
- |
protected int getFirstRow() |
1064 |
|
- |
{ |
|
917 |
+ |
protected int getFirstRow() { |
1065 |
918 |
|
return getAbsoluteFirstRowIndex(); |
1066 |
919 |
|
} |
1067 |
920 |
|
|
|
@@ -1071,8 +924,7 @@ |
1071 |
924 |
|
* @deprecated use {@link #getAbsoluteLastRowIndex()} instead |
1072 |
925 |
|
*/ |
1073 |
926 |
|
@Deprecated |
1074 |
|
- |
protected int getLastRow() |
1075 |
|
- |
{ |
|
927 |
+ |
protected int getLastRow() { |
1076 |
928 |
|
return getAbsoluteLastRowIndex(); |
1077 |
929 |
|
} |
1078 |
930 |
|
|
|
@@ -1081,30 +933,22 @@ |
1081 |
933 |
|
* |
1082 |
934 |
|
* @return the list of row value |
1083 |
935 |
|
*/ |
1084 |
|
- |
protected List<RowType> getRowValues() |
1085 |
|
- |
{ |
|
936 |
+ |
protected List<RowType> getRowValues() { |
1086 |
937 |
|
return rowValues; |
1087 |
938 |
|
} |
1088 |
939 |
|
|
1089 |
940 |
|
/** |
1090 |
941 |
|
* @return the header widget used to select all rows |
1091 |
942 |
|
*/ |
1092 |
|
- |
protected Widget getSelectAllWidget() |
1093 |
|
- |
{ |
1094 |
|
- |
if ( selectAllWidget == null ) |
1095 |
|
- |
{ |
|
943 |
+ |
protected Widget getSelectAllWidget() { |
|
944 |
+ |
if ( selectAllWidget == null ) { |
1096 |
945 |
|
final CheckBox box = new CheckBox(); |
1097 |
946 |
|
selectAllWidget = box; |
1098 |
|
- |
box.addClickHandler( new ClickHandler() |
1099 |
|
- |
{ |
1100 |
|
- |
public void onClick( ClickEvent event ) |
1101 |
|
- |
{ |
1102 |
|
- |
if ( box.getValue() ) |
1103 |
|
- |
{ |
|
947 |
+ |
box.addClickHandler( new ClickHandler() { |
|
948 |
+ |
public void onClick( ClickEvent event ) { |
|
949 |
+ |
if ( box.getValue() ) { |
1104 |
950 |
|
getDataTable().selectAllRows(); |
1105 |
|
- |
} |
1106 |
|
- |
else |
1107 |
|
- |
{ |
|
951 |
+ |
} else { |
1108 |
952 |
|
getDataTable().deselectAllRows(); |
1109 |
953 |
|
} |
1110 |
954 |
|
} |
|
@@ -1116,8 +960,7 @@ |
1116 |
960 |
|
/** |
1117 |
961 |
|
* @return the list of current visible column definitions |
1118 |
962 |
|
*/ |
1119 |
|
- |
protected List<ColumnDefinition<RowType, ?>> getVisibleColumnDefinitions() |
1120 |
|
- |
{ |
|
963 |
+ |
protected List<ColumnDefinition<RowType, ?>> getVisibleColumnDefinitions() { |
1121 |
964 |
|
return visibleColumns; |
1122 |
965 |
|
} |
1123 |
966 |
|
|
|
@@ -1126,25 +969,19 @@ |
1126 |
969 |
|
* |
1127 |
970 |
|
* @param beforeRow the row index |
1128 |
971 |
|
*/ |
1129 |
|
- |
protected void insertAbsoluteRow( int beforeRow ) |
1130 |
|
- |
{ |
|
972 |
+ |
protected void insertAbsoluteRow( int beforeRow ) { |
1131 |
973 |
|
// Physically insert the row |
1132 |
974 |
|
int lastRow = getAbsoluteLastRowIndex() + 1; |
1133 |
|
- |
if ( beforeRow <= lastRow ) |
1134 |
|
- |
{ |
|
975 |
+ |
if ( beforeRow <= lastRow ) { |
1135 |
976 |
|
int firstRow = getAbsoluteFirstRowIndex(); |
1136 |
|
- |
if ( beforeRow >= firstRow ) |
1137 |
|
- |
{ |
|
977 |
+ |
if ( beforeRow >= firstRow ) { |
1138 |
978 |
|
// Insert row in the middle of the page |
1139 |
979 |
|
getDataTable().insertRow( beforeRow - firstRow ); |
1140 |
|
- |
} |
1141 |
|
- |
else |
1142 |
|
- |
{ |
|
980 |
+ |
} else { |
1143 |
981 |
|
// Insert zero row because row is before this page |
1144 |
982 |
|
getDataTable().insertRow( 0 ); |
1145 |
983 |
|
} |
1146 |
|
- |
if ( getDataTable().getRowCount() > pageSize ) |
1147 |
|
- |
{ |
|
984 |
+ |
if ( getDataTable().getRowCount() > pageSize ) { |
1148 |
985 |
|
getDataTable().removeRow( pageSize ); |
1149 |
986 |
|
} |
1150 |
987 |
|
} |
|
@@ -1153,11 +990,9 @@ |
1153 |
990 |
|
/** |
1154 |
991 |
|
* Called when the data table has finished rendering. |
1155 |
992 |
|
*/ |
1156 |
|
- |
protected void onDataTableRendered() |
1157 |
|
- |
{ |
|
993 |
+ |
protected void onDataTableRendered() { |
1158 |
994 |
|
// Refresh the headers if needed |
1159 |
|
- |
if ( headersObsolete ) |
1160 |
|
- |
{ |
|
995 |
+ |
if ( headersObsolete ) { |
1161 |
996 |
|
refreshHeaderTable(); |
1162 |
997 |
|
refreshFooterTable(); |
1163 |
998 |
|
headersObsolete = false; |
|
@@ -1166,10 +1001,8 @@ |
1166 |
1001 |
|
// Select rows |
1167 |
1002 |
|
FixedWidthGrid dataTable = getDataTable(); |
1168 |
1003 |
|
int rowCount = dataTable.getRowCount(); |
1169 |
|
- |
for ( int i = 0; i < rowCount; i++ ) |
1170 |
|
- |
{ |
1171 |
|
- |
if ( selectedRowValues.contains( getRowValue( i ) ) ) |
1172 |
|
- |
{ |
|
1004 |
+ |
for ( int i = 0; i < rowCount; i++ ) { |
|
1005 |
+ |
if ( selectedRowValues.contains( getRowValue( i ) ) ) { |
1173 |
1006 |
|
dataTable.selectRow( i, false ); |
1174 |
1007 |
|
} |
1175 |
1008 |
|
} |
|
@@ -1184,10 +1017,8 @@ |
1184 |
1017 |
|
/** |
1185 |
1018 |
|
* Update the footer table based on the new {@link ColumnDefinition}. |
1186 |
1019 |
|
*/ |
1187 |
|
- |
protected void refreshFooterTable() |
1188 |
|
- |
{ |
1189 |
|
- |
if ( !isFooterGenerated ) |
1190 |
|
- |
{ |
|
1020 |
+ |
protected void refreshFooterTable() { |
|
1021 |
+ |
if ( !isFooterGenerated ) { |
1191 |
1022 |
|
return; |
1192 |
1023 |
|
} |
1193 |
1024 |
|
|
|
@@ -1196,8 +1027,7 @@ |
1196 |
1027 |
|
int columnCount = visibleColumns.size(); |
1197 |
1028 |
|
int footerCounts[] = new int[columnCount]; |
1198 |
1029 |
|
int maxFooterCount = 0; |
1199 |
|
- |
for ( int col = 0; col < columnCount; col++ ) |
1200 |
|
- |
{ |
|
1030 |
+ |
for ( int col = 0; col < columnCount; col++ ) { |
1201 |
1031 |
|
// Get the header property. |
1202 |
1032 |
|
ColumnDefinition<RowType, ?> colDef = visibleColumns.get( col ); |
1203 |
1033 |
|
FooterProperty prop = colDef.getColumnProperty( FooterProperty.TYPE ); |
|
@@ -1208,15 +1038,11 @@ |
1208 |
1038 |
|
// Add each ColumnHeaderInfo |
1209 |
1039 |
|
List<ColumnHeaderInfo> infos = new ArrayList<ColumnHeaderInfo>(); |
1210 |
1040 |
|
ColumnHeaderInfo prev = null; |
1211 |
|
- |
for ( int row = 0; row < footerCount; row++ ) |
1212 |
|
- |
{ |
|
1041 |
+ |
for ( int row = 0; row < footerCount; row++ ) { |
1213 |
1042 |
|
Object footer = prop.getFooter( row, col ); |
1214 |
|
- |
if ( prev != null && prev.header.equals( footer ) ) |
1215 |
|
- |
{ |
|
1043 |
+ |
if ( prev != null && prev.header.equals( footer ) ) { |
1216 |
1044 |
|
prev.incrementRowSpan(); |
1217 |
|
- |
} |
1218 |
|
- |
else |
1219 |
|
- |
{ |
|
1045 |
+ |
} else { |
1220 |
1046 |
|
prev = new ColumnHeaderInfo( footer ); |
1221 |
1047 |
|
infos.add( prev ); |
1222 |
1048 |
|
} |
|
@@ -1225,24 +1051,20 @@ |
1225 |
1051 |
|
} |
1226 |
1052 |
|
|
1227 |
1053 |
|
// Return early if there is no footer |
1228 |
|
- |
if ( maxFooterCount == 0 ) |
1229 |
|
- |
{ |
|
1054 |
+ |
if ( maxFooterCount == 0 ) { |
1230 |
1055 |
|
return; |
1231 |
1056 |
|
} |
1232 |
1057 |
|
|
1233 |
1058 |
|
// Fill in missing rows |
1234 |
|
- |
for ( int col = 0; col < columnCount; col++ ) |
1235 |
|
- |
{ |
|
1059 |
+ |
for ( int col = 0; col < columnCount; col++ ) { |
1236 |
1060 |
|
int footerCount = footerCounts[col]; |
1237 |
|
- |
if ( footerCount < maxFooterCount ) |
1238 |
|
- |
{ |
|
1061 |
+ |
if ( footerCount < maxFooterCount ) { |
1239 |
1062 |
|
allInfos.get( col ).add( new ColumnHeaderInfo( null, maxFooterCount - footerCount ) ); |
1240 |
1063 |
|
} |
1241 |
1064 |
|
} |
1242 |
1065 |
|
|
1243 |
1066 |
|
// Ensure that we have a footer table |
1244 |
|
- |
if ( getFooterTable() == null ) |
1245 |
|
- |
{ |
|
1067 |
+ |
if ( getFooterTable() == null ) { |
1246 |
1068 |
|
setFooterTable( new FixedWidthFlexTable() ); |
1247 |
1069 |
|
} |
1248 |
1070 |
|
|
|
@@ -1253,10 +1075,8 @@ |
1253 |
1075 |
|
/** |
1254 |
1076 |
|
* Update the header table based on the new {@link ColumnDefinition}. |
1255 |
1077 |
|
*/ |
1256 |
|
- |
protected void refreshHeaderTable() |
1257 |
|
- |
{ |
1258 |
|
- |
if ( !isHeaderGenerated ) |
1259 |
|
- |
{ |
|
1078 |
+ |
protected void refreshHeaderTable() { |
|
1079 |
+ |
if ( !isHeaderGenerated ) { |
1260 |
1080 |
|
return; |
1261 |
1081 |
|
} |
1262 |
1082 |
|
|
|
@@ -1265,8 +1085,7 @@ |
1265 |
1085 |
|
int columnCount = visibleColumns.size(); |
1266 |
1086 |
|
int headerCounts[] = new int[columnCount]; |
1267 |
1087 |
|
int maxHeaderCount = 0; |
1268 |
|
- |
for ( int col = 0; col < columnCount; col++ ) |
1269 |
|
- |
{ |
|
1088 |
+ |
for ( int col = 0; col < columnCount; col++ ) { |
1270 |
1089 |
|
// Get the header property. |
1271 |
1090 |
|
ColumnDefinition<RowType, ?> colDef = visibleColumns.get( col ); |
1272 |
1091 |
|
HeaderProperty prop = colDef.getColumnProperty( HeaderProperty.TYPE ); |
|
@@ -1277,15 +1096,11 @@ |
1277 |
1096 |
|
// Add each ColumnHeaderInfo |
1278 |
1097 |
|
List<ColumnHeaderInfo> infos = new ArrayList<ColumnHeaderInfo>(); |
1279 |
1098 |
|
ColumnHeaderInfo prev = null; |
1280 |
|
- |
for ( int row = 0; row < headerCount; row++ ) |
1281 |
|
- |
{ |
|
1099 |
+ |
for ( int row = 0; row < headerCount; row++ ) { |
1282 |
1100 |
|
Object header = prop.getHeader( row, col ); |
1283 |
|
- |
if ( prev != null && prev.header.equals( header ) ) |
1284 |
|
- |
{ |
|
1101 |
+ |
if ( prev != null && prev.header.equals( header ) ) { |
1285 |
1102 |
|
prev.incrementRowSpan(); |
1286 |
|
- |
} |
1287 |
|
- |
else |
1288 |
|
- |
{ |
|
1103 |
+ |
} else { |
1289 |
1104 |
|
prev = new ColumnHeaderInfo( header ); |
1290 |
1105 |
|
infos.add( 0, prev ); |
1291 |
1106 |
|
} |
|
@@ -1294,17 +1109,14 @@ |
1294 |
1109 |
|
} |
1295 |
1110 |
|
|
1296 |
1111 |
|
// Return early if there is no header |
1297 |
|
- |
if ( maxHeaderCount == 0 ) |
1298 |
|
- |
{ |
|
1112 |
+ |
if ( maxHeaderCount == 0 ) { |
1299 |
1113 |
|
return; |
1300 |
1114 |
|
} |
1301 |
1115 |
|
|
1302 |
1116 |
|
// Fill in missing rows |
1303 |
|
- |
for ( int col = 0; col < columnCount; col++ ) |
1304 |
|
- |
{ |
|
1117 |
+ |
for ( int col = 0; col < columnCount; col++ ) { |
1305 |
1118 |
|
int headerCount = headerCounts[col]; |
1306 |
|
- |
if ( headerCount < maxHeaderCount ) |
1307 |
|
- |
{ |
|
1119 |
+ |
if ( headerCount < maxHeaderCount ) { |
1308 |
1120 |
|
allInfos.get( col ).add( 0, new ColumnHeaderInfo( null, maxHeaderCount - headerCount ) ); |
1309 |
1121 |
|
} |
1310 |
1122 |
|
} |
|
@@ -1317,21 +1129,15 @@ |
1317 |
1129 |
|
* Refresh the list of the currently visible column definitions based on the |
1318 |
1130 |
|
* {@link TableDefinition}. |
1319 |
1131 |
|
*/ |
1320 |
|
- |
protected void refreshVisibleColumnDefinitions() |
1321 |
|
- |
{ |
|
1132 |
+ |
protected void refreshVisibleColumnDefinitions() { |
1322 |
1133 |
|
List<ColumnDefinition<RowType, ?>> colDefs = new ArrayList<ColumnDefinition<RowType, ?>>( tableDefinition.getVisibleColumnDefinitions() ); |
1323 |
|
- |
if ( !colDefs.equals( visibleColumns ) ) |
1324 |
|
- |
{ |
|
1134 |
+ |
if ( !colDefs.equals( visibleColumns ) ) { |
1325 |
1135 |
|
visibleColumns = colDefs; |
1326 |
1136 |
|
headersObsolete = true; |
1327 |
|
- |
} |
1328 |
|
- |
else |
1329 |
|
- |
{ |
|
1137 |
+ |
} else { |
1330 |
1138 |
|
// Check if any of the headers are dynamic |
1331 |
|
- |
for ( ColumnDefinition<RowType, ?> colDef : colDefs ) |
1332 |
|
- |
{ |
1333 |
|
- |
if ( colDef.getColumnProperty( HeaderProperty.TYPE ).isDynamic() || colDef.getColumnProperty( FooterProperty.TYPE ).isDynamic() ) |
1334 |
|
- |
{ |
|
1139 |
+ |
for ( ColumnDefinition<RowType, ?> colDef : colDefs ) { |
|
1140 |
+ |
if ( colDef.getColumnProperty( HeaderProperty.TYPE ).isDynamic() || colDef.getColumnProperty( FooterProperty.TYPE ).isDynamic() ) { |
1335 |
1141 |
|
headersObsolete = true; |
1336 |
1142 |
|
return; |
1337 |
1143 |
|
} |
|
@@ -1344,17 +1150,14 @@ |
1344 |
1150 |
|
* |
1345 |
1151 |
|
* @param row the row index |
1346 |
1152 |
|
*/ |
1347 |
|
- |
protected void removeAbsoluteRow( int row ) |
1348 |
|
- |
{ |
|
1153 |
+ |
protected void removeAbsoluteRow( int row ) { |
1349 |
1154 |
|
// Physically remove the row if it is in the middle of the data table |
1350 |
1155 |
|
int firstRow = getAbsoluteFirstRowIndex(); |
1351 |
1156 |
|
int lastRow = getAbsoluteLastRowIndex(); |
1352 |
|
- |
if ( row <= lastRow && row >= firstRow ) |
1353 |
|
- |
{ |
|
1157 |
+ |
if ( row <= lastRow && row >= firstRow ) { |
1354 |
1158 |
|
FixedWidthGrid dataTable = getDataTable(); |
1355 |
1159 |
|
int relativeRow = row - firstRow; |
1356 |
|
- |
if ( relativeRow < dataTable.getRowCount() ) |
1357 |
|
- |
{ |
|
1160 |
+ |
if ( relativeRow < dataTable.getRowCount() ) { |
1358 |
1161 |
|
dataTable.removeRow( relativeRow ); |
1359 |
1162 |
|
} |
1360 |
1163 |
|
} |
|
@@ -1369,12 +1172,10 @@ |
1369 |
1172 |
|
* @param firstRow the row index that the rows iterator starts with |
1370 |
1173 |
|
* @param rows the values associated with each row |
1371 |
1174 |
|
*/ |
1372 |
|
- |
protected void setData( int firstRow, Iterator<RowType> rows ) |
1373 |
|
- |
{ |
|
1175 |
+ |
protected void setData( int firstRow, Iterator<RowType> rows ) { |
1374 |
1176 |
|
getDataTable().deselectAllRows(); |
1375 |
1177 |
|
rowValues = new ArrayList<RowType>(); |
1376 |
|
- |
if ( rows != null && rows.hasNext() ) |
1377 |
|
- |
{ |
|
1178 |
+ |
if ( rows != null && rows.hasNext() ) { |
1378 |
1179 |
|
setEmptyTableWidgetVisible( false ); |
1379 |
1180 |
|
|
1380 |
1181 |
|
// Get an iterator over the visible rows |
|
@@ -1383,8 +1184,7 @@ |
1383 |
1184 |
|
Iterator<RowType> visibleIter = new VisibleRowsIterator( rows, firstRow, firstVisibleRow, lastVisibleRow ); |
1384 |
1185 |
|
|
1385 |
1186 |
|
// Set the row values |
1386 |
|
- |
while ( visibleIter.hasNext() ) |
1387 |
|
- |
{ |
|
1187 |
+ |
while ( visibleIter.hasNext() ) { |
1388 |
1188 |
|
rowValues.add( visibleIter.next() ); |
1389 |
1189 |
|
} |
1390 |
1190 |
|
|
|
@@ -1392,8 +1192,7 @@ |
1392 |
1192 |
|
refreshVisibleColumnDefinitions(); |
1393 |
1193 |
|
|
1394 |
1194 |
|
// Render using the bulk renderer |
1395 |
|
- |
if ( bulkRenderer != null ) |
1396 |
|
- |
{ |
|
1195 |
+ |
if ( bulkRenderer != null ) { |
1397 |
1196 |
|
bulkRenderer.renderRows( rowValues.iterator(), tableRendererCallback ); |
1398 |
1197 |
|
return; |
1399 |
1198 |
|
} |
|
@@ -1405,9 +1204,7 @@ |
1405 |
1204 |
|
|
1406 |
1205 |
|
// Render the rows |
1407 |
1206 |
|
tableDefinition.renderRows( 0, rowValues.iterator(), rowView ); |
1408 |
|
- |
} |
1409 |
|
- |
else |
1410 |
|
- |
{ |
|
1207 |
+ |
} else { |
1411 |
1208 |
|
setEmptyTableWidgetVisible( true ); |
1412 |
1209 |
|
} |
1413 |
1210 |
|
|
|
@@ -1420,15 +1217,11 @@ |
1420 |
1217 |
|
* |
1421 |
1218 |
|
* @param visible true to show the empty table widget |
1422 |
1219 |
|
*/ |
1423 |
|
- |
protected void setEmptyTableWidgetVisible( boolean visible ) |
1424 |
|
- |
{ |
|
1220 |
+ |
protected void setEmptyTableWidgetVisible( boolean visible ) { |
1425 |
1221 |
|
emptyTableWidgetWrapper.setVisible( visible ); |
1426 |
|
- |
if ( visible ) |
1427 |
|
- |
{ |
|
1222 |
+ |
if ( visible ) { |
1428 |
1223 |
|
getDataWrapper().getStyle().setProperty( "display", "none" ); |
1429 |
|
- |
} |
1430 |
|
- |
else |
1431 |
|
- |
{ |
|
1224 |
+ |
} else { |
1432 |
1225 |
|
getDataWrapper().getStyle().setProperty( "display", "" ); |
1433 |
1226 |
|
} |
1434 |
1227 |
|
} |
|
@@ -1441,18 +1234,15 @@ |
1441 |
1234 |
|
* @param allInfos the header info |
1442 |
1235 |
|
* @param isHeader false if refreshing the footer table |
1443 |
1236 |
|
*/ |
1444 |
|
- |
private void refreshHeaderTable( FixedWidthFlexTable table, List<List<ColumnHeaderInfo>> allInfos, boolean isHeader ) |
1445 |
|
- |
{ |
|
1237 |
+ |
private void refreshHeaderTable( FixedWidthFlexTable table, List<List<ColumnHeaderInfo>> allInfos, boolean isHeader ) { |
1446 |
1238 |
|
// Return if we have no column definitions. |
1447 |
|
- |
if ( visibleColumns == null ) |
1448 |
|
- |
{ |
|
1239 |
+ |
if ( visibleColumns == null ) { |
1449 |
1240 |
|
return; |
1450 |
1241 |
|
} |
1451 |
1242 |
|
|
1452 |
1243 |
|
// Reset the header table. |
1453 |
1244 |
|
int rowCount = table.getRowCount(); |
1454 |
|
- |
for ( int i = 0; i < rowCount; i++ ) |
1455 |
|
- |
{ |
|
1245 |
+ |
for ( int i = 0; i < rowCount; i++ ) { |
1456 |
1246 |
|
table.removeRow( 0 ); |
1457 |
1247 |
|
} |
1458 |
1248 |
|
|
|
@@ -1460,30 +1250,24 @@ |
1460 |
1250 |
|
int columnCount = allInfos.size(); |
1461 |
1251 |
|
FlexCellFormatter formatter = table.getFlexCellFormatter(); |
1462 |
1252 |
|
List<ColumnHeaderInfo> prevInfos = null; |
1463 |
|
- |
for ( int col = 0; col < columnCount; col++ ) |
1464 |
|
- |
{ |
|
1253 |
+ |
for ( int col = 0; col < columnCount; col++ ) { |
1465 |
1254 |
|
List<ColumnHeaderInfo> infos = allInfos.get( col ); |
1466 |
1255 |
|
int row = 0; |
1467 |
|
- |
for ( ColumnHeaderInfo info : infos ) |
1468 |
|
- |
{ |
|
1256 |
+ |
for ( ColumnHeaderInfo info : infos ) { |
1469 |
1257 |
|
// Get the actual row and cell index |
1470 |
1258 |
|
int rowSpan = info.getRowSpan(); |
1471 |
1259 |
|
int cell = 0; |
1472 |
|
- |
if ( table.getRowCount() > row ) |
1473 |
|
- |
{ |
|
1260 |
+ |
if ( table.getRowCount() > row ) { |
1474 |
1261 |
|
cell = table.getCellCount( row ); |
1475 |
1262 |
|
} |
1476 |
1263 |
|
|
1477 |
1264 |
|
// Compare to the cell in the previous column |
1478 |
|
- |
if ( prevInfos != null ) |
1479 |
|
- |
{ |
|
1265 |
+ |
if ( prevInfos != null ) { |
1480 |
1266 |
|
boolean headerAdded = false; |
1481 |
1267 |
|
int prevRow = 0; |
1482 |
|
- |
for ( ColumnHeaderInfo prevInfo : prevInfos ) |
1483 |
|
- |
{ |
|
1268 |
+ |
for ( ColumnHeaderInfo prevInfo : prevInfos ) { |
1484 |
1269 |
|
// Increase the colSpan of the previous cell |
1485 |
|
- |
if ( prevRow == row && info.equals( prevInfo ) ) |
1486 |
|
- |
{ |
|
1270 |
+ |
if ( prevRow == row && info.equals( prevInfo ) ) { |
1487 |
1271 |
|
int colSpan = formatter.getColSpan( row, cell - 1 ); |
1488 |
1272 |
|
formatter.setColSpan( row, cell - 1, colSpan + 1 ); |
1489 |
1273 |
|
headerAdded = true; |
|
@@ -1492,8 +1276,7 @@ |
1492 |
1276 |
|
prevRow += prevInfo.getRowSpan(); |
1493 |
1277 |
|
} |
1494 |
1278 |
|
|
1495 |
|
- |
if ( headerAdded ) |
1496 |
|
- |
{ |
|
1279 |
+ |
if ( headerAdded ) { |
1497 |
1280 |
|
row += rowSpan; |
1498 |
1281 |
|
continue; |
1499 |
1282 |
|
} |
|
@@ -1501,18 +1284,14 @@ |
1501 |
1284 |
|
|
1502 |
1285 |
|
// Set the new header |
1503 |
1286 |
|
Object header = info.getHeader(); |
1504 |
|
- |
if ( header instanceof Widget ) |
1505 |
|
- |
{ |
|
1287 |
+ |
if ( header instanceof Widget ) { |
1506 |
1288 |
|
table.setWidget( row, cell, (Widget) header ); |
1507 |
|
- |
} |
1508 |
|
- |
else |
1509 |
|
- |
{ |
|
1289 |
+ |
} else { |
1510 |
1290 |
|
table.setHTML( row, cell, header.toString() ); |
1511 |
1291 |
|
} |
1512 |
1292 |
|
|
1513 |
1293 |
|
// Update the rowSpan |
1514 |
|
- |
if ( rowSpan > 1 ) |
1515 |
|
- |
{ |
|
1294 |
+ |
if ( rowSpan > 1 ) { |
1516 |
1295 |
|
formatter.setRowSpan( row, cell, rowSpan ); |
1517 |
1296 |
|
} |
1518 |
1297 |
|
|
|
@@ -1526,23 +1305,18 @@ |
1526 |
1305 |
|
|
1527 |
1306 |
|
// Insert the checkbox column |
1528 |
1307 |
|
SelectionPolicy selectionPolicy = getDataTable().getSelectionPolicy(); |
1529 |
|
- |
if ( selectionPolicy.hasInputColumn() ) |
1530 |
|
- |
{ |
|
1308 |
+ |
if ( selectionPolicy.hasInputColumn() ) { |
1531 |
1309 |
|
// Get the select all box |
1532 |
1310 |
|
Widget box = null; |
1533 |
|
- |
if ( isHeader && getDataTable().getSelectionPolicy() == SelectionPolicy.CHECKBOX ) |
1534 |
|
- |
{ |
|
1311 |
+ |
if ( isHeader && getDataTable().getSelectionPolicy() == SelectionPolicy.CHECKBOX ) { |
1535 |
1312 |
|
box = getSelectAllWidget(); |
1536 |
1313 |
|
} |
1537 |
1314 |
|
|
1538 |
1315 |
|
// Add the offset column |
1539 |
1316 |
|
table.insertCell( 0, 0 ); |
1540 |
|
- |
if ( box != null ) |
1541 |
|
- |
{ |
|
1317 |
+ |
if ( box != null ) { |
1542 |
1318 |
|
table.setWidget( 0, 0, box ); |
1543 |
|
- |
} |
1544 |
|
- |
else |
1545 |
|
- |
{ |
|
1319 |
+ |
} else { |
1546 |
1320 |
|
table.setHTML( 0, 0, HTMLConstants.NBSP ); |
1547 |
1321 |
|
} |
1548 |
1322 |
|
formatter.setRowSpan( 0, 0, table.getRowCount() ); |
|
@@ -1556,30 +1330,24 @@ |
1556 |
1330 |
|
* |
1557 |
1331 |
|
* @param rowIndex the index of the row |
1558 |
1332 |
|
*/ |
1559 |
|
- |
private void refreshRow( int rowIndex ) |
1560 |
|
- |
{ |
|
1333 |
+ |
private void refreshRow( int rowIndex ) { |
1561 |
1334 |
|
final RowType rowValue = getRowValue( rowIndex ); |
1562 |
|
- |
Iterator<RowType> singleIterator = new Iterator<RowType>() |
1563 |
|
- |
{ |
|
1335 |
+ |
Iterator<RowType> singleIterator = new Iterator<RowType>() { |
1564 |
1336 |
|
private boolean nextCalled = false; |
1565 |
1337 |
|
|
1566 |
|
- |
public boolean hasNext() |
1567 |
|
- |
{ |
|
1338 |
+ |
public boolean hasNext() { |
1568 |
1339 |
|
return !nextCalled; |
1569 |
1340 |
|
} |
1570 |
1341 |
|
|
1571 |
|
- |
public RowType next() |
1572 |
|
- |
{ |
1573 |
|
- |
if ( !hasNext() ) |
1574 |
|
- |
{ |
|
1342 |
+ |
public RowType next() { |
|
1343 |
+ |
if ( !hasNext() ) { |
1575 |
1344 |
|
throw new NoSuchElementException(); |
1576 |
1345 |
|
} |
1577 |
1346 |
|
nextCalled = true; |
1578 |
1347 |
|
return rowValue; |
1579 |
1348 |
|
} |
1580 |
1349 |
|
|
1581 |
|
- |
public void remove() |
1582 |
|
- |
{ |
|
1350 |
+ |
public void remove() { |
1583 |
1351 |
|
throw new UnsupportedOperationException(); |
1584 |
1352 |
|
} |
1585 |
1353 |
|
}; |