Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/com/google/gwt/gen2/table/client/ListTableModel.java

Diff revisions: vs.
  @@ -15,39 +15,33 @@
15 15 */
16 16 package com.google.gwt.gen2.table.client;
17 17
18 - import java.util.*;
19 -
20 18 import com.google.gwt.gen2.table.client.TableModelHelper.*;
21 19
20 + import java.util.*;
21 +
22 22 /**
23 23 * A {@link ClientTableModel} that uses a 2D {@link List} of Objects as its
24 24 * source of data.
25 25 */
26 - public class ListTableModel extends MutableTableModel<List<Object>>
27 - {
26 + public class ListTableModel extends MutableTableModel<List<Object>> {
28 27 /**
29 28 * An {@link Iterator} over the requested rows.
30 29 */
31 - private class RowIterator implements Iterator<List<Object>>
32 - {
30 + private class RowIterator implements Iterator<List<Object>> {
33 31 private int curRow;
34 32 private int lastRow;
35 33
36 - public RowIterator( Request request )
37 - {
34 + public RowIterator( Request request ) {
38 35 curRow = request.getStartRow() - 1;
39 36 lastRow = Math.min( rowValues.size() - 1, curRow + request.getNumRows() );
40 37 }
41 38
42 - public boolean hasNext()
43 - {
39 + public boolean hasNext() {
44 40 return curRow < lastRow;
45 41 }
46 42
47 - public List<Object> next()
48 - {
49 - if ( !hasNext() )
50 - {
43 + public List<Object> next() {
44 + if ( !hasNext() ) {
51 45 throw new NoSuchElementException();
52 46 }
53 47
  @@ -55,8 +49,7 @@
55 49 return rowValues.get( new Integer( curRow ) );
56 50 }
57 51
58 - public void remove()
59 - {
52 + public void remove() {
60 53 throw new UnsupportedOperationException();
61 54 }
62 55 }
  @@ -71,21 +64,17 @@
71 64 *
72 65 * @param rows the data that this model feeds from
73 66 */
74 - public ListTableModel( List<List<Object>> rows )
75 - {
67 + public ListTableModel( List<List<Object>> rows ) {
76 68 this.rowValues = rows;
77 69 setRowCount( rows.size() );
78 70 }
79 71
80 72 @Override
81 - public void requestRows( Request request, Callback<List<Object>> callback )
82 - {
73 + public void requestRows( Request request, Callback<List<Object>> callback ) {
83 74 final RowIterator it = new RowIterator( request );
84 - Response<List<Object>> response = new Response<List<Object>>()
85 - {
75 + Response<List<Object>> response = new Response<List<Object>>() {
86 76 @Override
87 - public Iterator<List<Object>> getRowValues()
88 - {
77 + public Iterator<List<Object>> getRowValues() {
89 78 return it;
90 79 }
91 80 };
  @@ -93,31 +82,25 @@
93 82 }
94 83
95 84 @Override
96 - protected boolean onRowInserted( int beforeRow )
97 - {
98 - if ( beforeRow < rowValues.size() )
99 - {
85 + protected boolean onRowInserted( int beforeRow ) {
86 + if ( beforeRow < rowValues.size() ) {
100 87 rowValues.add( beforeRow, null );
101 88 }
102 89 return true;
103 90 }
104 91
105 92 @Override
106 - protected boolean onRowRemoved( int row )
107 - {
108 - if ( row < rowValues.size() )
109 - {
93 + protected boolean onRowRemoved( int row ) {
94 + if ( row < rowValues.size() ) {
110 95 rowValues.remove( row );
111 96 }
112 97 return true;
113 98 }
114 99
115 100 @Override
116 - protected boolean onSetRowValue( int row, List<Object> rowValue )
117 - {
101 + protected boolean onSetRowValue( int row, List<Object> rowValue ) {
118 102 // Expand to fit row
119 - for ( int i = rowValues.size(); i <= row; i++ )
120 - {
103 + for ( int i = rowValues.size(); i <= row; i++ ) {
121 104 rowValues.add( null );
122 105 }
123 106
  @@ -134,18 +117,15 @@
134 117 *
135 118 * @return the cell value, or null if it does not exist
136 119 */
137 - Object getCellValue( int rowIndex, int cellIndex )
138 - {
120 + Object getCellValue( int rowIndex, int cellIndex ) {
139 121 // Row does not exist
140 - if ( rowIndex >= rowValues.size() )
141 - {
122 + if ( rowIndex >= rowValues.size() ) {
142 123 return null;
143 124 }
144 125
145 126 // Get the cell value from the row
146 127 List<Object> rowList = rowValues.get( rowIndex );
147 - if ( rowList != null && rowList.size() > cellIndex )
148 - {
128 + if ( rowList != null && rowList.size() > cellIndex ) {
149 129 return rowList.get( cellIndex );
150 130 }
151 131 return null;