Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -24,8 +24,7 @@
24 24 * <p/>
25 25 * TODO: Incorporate changes into actual class.
26 26 */
27 - public class Grid extends HTMLTable
28 - {
27 + public class Grid extends HTMLTable {
29 28 /**
30 29 * Number of columns in the current grid.
31 30 */
  @@ -39,8 +38,7 @@
39 38 /**
40 39 * Constructor for <code>Grid</code>.
41 40 */
42 - public Grid()
43 - {
41 + public Grid() {
44 42 super();
45 43 setClearText( HTMLConstants.NBSP );
46 44 setCellFormatter( new CellFormatter() );
  @@ -56,8 +54,7 @@
56 54 *
57 55 * @throws IndexOutOfBoundsException
58 56 */
59 - public Grid( int rows, int columns )
60 - {
57 + public Grid( int rows, int columns ) {
61 58 this();
62 59 resize( rows, columns );
63 60 }
  @@ -67,8 +64,7 @@
67 64 * are rectangular.
68 65 */
69 66 @Override
70 - public int getCellCount( int row )
71 - {
67 + public int getCellCount( int row ) {
72 68 return numColumns;
73 69 }
74 70
  @@ -77,8 +73,7 @@
77 73 *
78 74 * @return the number of columns
79 75 */
80 - public int getColumnCount()
81 - {
76 + public int getColumnCount() {
82 77 return numColumns;
83 78 }
84 79
  @@ -86,8 +81,7 @@
86 81 * Return number of rows.
87 82 */
88 83 @Override
89 - public int getRowCount()
90 - {
84 + public int getRowCount() {
91 85 return numRows;
92 86 }
93 87
  @@ -103,16 +97,14 @@
103 97 * @throws IndexOutOfBoundsException
104 98 */
105 99 @Override
106 - public int insertRow( int beforeRow )
107 - {
100 + public int insertRow( int beforeRow ) {
108 101 int index = super.insertRow( beforeRow );
109 102 numRows++;
110 103 return index;
111 104 }
112 105
113 106 @Override
114 - public void removeRow( int row )
115 - {
107 + public void removeRow( int row ) {
116 108 super.removeRow( row );
117 109 numRows--;
118 110 }
  @@ -125,8 +117,7 @@
125 117 *
126 118 * @throws IndexOutOfBoundsException
127 119 */
128 - public void resize( int rows, int columns )
129 - {
120 + public void resize( int rows, int columns ) {
130 121 resizeColumns( columns );
131 122 resizeRows( rows );
132 123 }
  @@ -138,35 +129,25 @@
138 129 *
139 130 * @throws IndexOutOfBoundsException
140 131 */
141 - public void resizeColumns( int columns )
142 - {
143 - if ( numColumns == columns )
144 - {
132 + public void resizeColumns( int columns ) {
133 + if ( numColumns == columns ) {
145 134 return;
146 135 }
147 - if ( columns < 0 )
148 - {
136 + if ( columns < 0 ) {
149 137 throw new IndexOutOfBoundsException( "Cannot set number of columns to " + columns );
150 138 }
151 139
152 - if ( numColumns > columns )
153 - {
140 + if ( numColumns > columns ) {
154 141 // Fewer columns. Remove extraneous cells.
155 - for ( int i = 0; i < numRows; i++ )
156 - {
157 - for ( int j = numColumns - 1; j >= columns; j-- )
158 - {
142 + for ( int i = 0; i < numRows; i++ ) {
143 + for ( int j = numColumns - 1; j >= columns; j-- ) {
159 144 removeCell( i, j );
160 145 }
161 146 }
162 - }
163 - else
164 - {
147 + } else {
165 148 // More columns. add cells where necessary.
166 - for ( int i = 0; i < numRows; i++ )
167 - {
168 - for ( int j = numColumns; j < columns; j++ )
169 - {
149 + for ( int i = 0; i < numRows; i++ ) {
150 + for ( int j = numColumns; j < columns; j++ ) {
170 151 insertCell( i, j );
171 152 }
172 153 }
  @@ -181,30 +162,22 @@
181 162 *
182 163 * @throws IndexOutOfBoundsException
183 164 */
184 - public void resizeRows( int rows )
185 - {
186 - if ( numRows == rows )
187 - {
165 + public void resizeRows( int rows ) {
166 + if ( numRows == rows ) {
188 167 return;
189 168 }
190 - if ( rows < 0 )
191 - {
169 + if ( rows < 0 ) {
192 170 throw new IndexOutOfBoundsException( "Cannot set number of rows to " + rows );
193 171 }
194 - if ( numRows < rows )
195 - {
172 + if ( numRows < rows ) {
196 173 Element tr = createRow();
197 174 getBodyElement().appendChild( tr );
198 - for ( int i = numRows + 1; i < rows; i++ )
199 - {
175 + for ( int i = numRows + 1; i < rows; i++ ) {
200 176 getBodyElement().appendChild( tr.cloneNode( true ) );
201 177 }
202 178 numRows = rows;
203 - }
204 - else
205 - {
206 - while ( numRows > rows )
207 - {
179 + } else {
180 + while ( numRows > rows ) {
208 181 // Fewer rows. Remove extraneous ones.
209 182 removeRow( numRows - 1 );
210 183 }
  @@ -215,8 +188,7 @@
215 188 * Creates a new, empty cell.
216 189 */
217 190 @Override
218 - protected Element createCell()
219 - {
191 + protected Element createCell() {
220 192 Element td = super.createCell();
221 193
222 194 // Add a non-breaking space to the TD. This ensures that the cell is
  @@ -226,11 +198,9 @@
226 198 }
227 199
228 200 @Override
229 - protected Element createRow()
230 - {
201 + protected Element createRow() {
231 202 Element tr = super.createRow();
232 - for ( int i = 0; i < numColumns; i++ )
233 - {
203 + for ( int i = 0; i < numColumns; i++ ) {
234 204 tr.appendChild( createCell() );
235 205 }
236 206 return tr;
  @@ -245,17 +215,14 @@
245 215 * @throws IndexOutOfBoundsException
246 216 */
247 217 @Override
248 - protected void prepareCell( int row, int column )
249 - {
218 + protected void prepareCell( int row, int column ) {
250 219 // Ensure that the indices are not negative.
251 220 prepareRow( row );
252 - if ( column < 0 )
253 - {
221 + if ( column < 0 ) {
254 222 throw new IndexOutOfBoundsException( "Cannot access a column with a negative index: " + column );
255 223 }
256 224
257 - if ( column >= numColumns )
258 - {
225 + if ( column >= numColumns ) {
259 226 throw new IndexOutOfBoundsException( "Column index: " + column + ", Column size: " + numColumns );
260 227 }
261 228 }
  @@ -268,11 +235,9 @@
268 235 * @throws IndexOutOfBoundsException if the column is negative
269 236 */
270 237 @Override
271 - protected void prepareColumn( int column )
272 - {
238 + protected void prepareColumn( int column ) {
273 239 // Ensure that the indices are not negative.
274 - if ( column < 0 )
275 - {
240 + if ( column < 0 ) {
276 241 throw new IndexOutOfBoundsException( "Cannot access a column with a negative index: " + column );
277 242 }
278 243
  @@ -280,8 +245,7 @@
280 245 * Grid does not lazily create cells, so simply ensure that the requested
281 246 * column and column are valid
282 247 */
283 - if ( column >= numColumns )
284 - {
248 + if ( column >= numColumns ) {
285 249 throw new IndexOutOfBoundsException( "Column index: " + column + ", Column size: " + numColumns );
286 250 }
287 251 }
  @@ -294,11 +258,9 @@
294 258 * @throws IndexOutOfBoundsException if the row is negative
295 259 */
296 260 @Override
297 - protected void prepareRow( int row )
298 - {
261 + protected void prepareRow( int row ) {
299 262 // Ensure that the indices are not negative.
300 - if ( row < 0 )
301 - {
263 + if ( row < 0 ) {
302 264 throw new IndexOutOfBoundsException( "Cannot access a row with a negative index: " + row );
303 265 }
304 266
  @@ -306,8 +268,7 @@
306 268 * Grid does not lazily create cells, so simply ensure that the requested
307 269 * row and column are valid
308 270 */
309 - if ( row >= numRows )
310 - {
271 + if ( row >= numRows ) {
311 272 throw new IndexOutOfBoundsException( "Row index: " + row + ", Row size: " + numRows );
312 273 }
313 274 }