|
@@ -15,259 +15,298 @@ |
15 |
15 |
|
*/ |
16 |
16 |
|
package com.google.gwt.gen2.table.client; |
17 |
17 |
|
|
18 |
|
- |
import com.google.gwt.user.client.DOM; |
19 |
|
- |
import com.google.gwt.user.client.Element; |
|
18 |
+ |
import com.google.gwt.user.client.*; |
20 |
19 |
|
|
21 |
20 |
|
/** |
22 |
21 |
|
* This class should replace the actual class of the same name. |
23 |
|
- |
* |
|
22 |
+ |
* <p/> |
24 |
23 |
|
* TODO: Incorporate changes into actual class. |
25 |
24 |
|
*/ |
26 |
|
- |
public class Grid extends HTMLTable { |
27 |
|
- |
/** |
28 |
|
- |
* Number of columns in the current grid. |
29 |
|
- |
*/ |
30 |
|
- |
protected int numColumns; |
31 |
|
- |
|
32 |
|
- |
/** |
33 |
|
- |
* Number of rows in the current grid. |
34 |
|
- |
*/ |
35 |
|
- |
protected int numRows; |
36 |
|
- |
|
37 |
|
- |
/** |
38 |
|
- |
* Constructor for <code>Grid</code>. |
39 |
|
- |
*/ |
40 |
|
- |
public Grid() { |
41 |
|
- |
super(); |
42 |
|
- |
setClearText(" "); |
43 |
|
- |
setCellFormatter(new CellFormatter()); |
44 |
|
- |
setRowFormatter(new RowFormatter()); |
45 |
|
- |
setColumnFormatter(new ColumnFormatter()); |
46 |
|
- |
} |
47 |
|
- |
|
48 |
|
- |
/** |
49 |
|
- |
* Constructs a grid with the requested size. |
50 |
|
- |
* |
51 |
|
- |
* @param rows the number of rows |
52 |
|
- |
* @param columns the number of columns |
53 |
|
- |
* @throws IndexOutOfBoundsException |
54 |
|
- |
*/ |
55 |
|
- |
public Grid(int rows, int columns) { |
56 |
|
- |
this(); |
57 |
|
- |
resize(rows, columns); |
58 |
|
- |
} |
59 |
|
- |
|
60 |
|
- |
/** |
61 |
|
- |
* Return number of columns. For grid, row argument is ignored as all grids |
62 |
|
- |
* are rectangular. |
63 |
|
- |
*/ |
64 |
|
- |
@Override |
65 |
|
- |
public int getCellCount(int row) { |
66 |
|
- |
return numColumns; |
67 |
|
- |
} |
68 |
|
- |
|
69 |
|
- |
/** |
70 |
|
- |
* Gets the number of columns in this grid. |
71 |
|
- |
* |
72 |
|
- |
* @return the number of columns |
73 |
|
- |
*/ |
74 |
|
- |
public int getColumnCount() { |
75 |
|
- |
return numColumns; |
76 |
|
- |
} |
77 |
|
- |
|
78 |
|
- |
/** |
79 |
|
- |
* Return number of rows. |
80 |
|
- |
*/ |
81 |
|
- |
@Override |
82 |
|
- |
public int getRowCount() { |
83 |
|
- |
return numRows; |
84 |
|
- |
} |
85 |
|
- |
|
86 |
|
- |
/** |
87 |
|
- |
* Inserts a new row into the table. If you want to add multiple rows at once, |
88 |
|
- |
* use {@link #resize(int, int)} or {@link #resizeRows(int)} as they are more |
89 |
|
- |
* efficient. |
90 |
|
- |
* |
91 |
|
- |
* @param beforeRow the index before which the new row will be inserted |
92 |
|
- |
* @return the index of the newly-created row |
93 |
|
- |
* @throws IndexOutOfBoundsException |
94 |
|
- |
*/ |
95 |
|
- |
@Override |
96 |
|
- |
public int insertRow(int beforeRow) { |
97 |
|
- |
int index = super.insertRow(beforeRow); |
98 |
|
- |
numRows++; |
99 |
|
- |
return index; |
100 |
|
- |
} |
101 |
|
- |
|
102 |
|
- |
@Override |
103 |
|
- |
public void removeRow(int row) { |
104 |
|
- |
super.removeRow(row); |
105 |
|
- |
numRows--; |
106 |
|
- |
} |
107 |
|
- |
|
108 |
|
- |
/** |
109 |
|
- |
* Resizes the grid. |
110 |
|
- |
* |
111 |
|
- |
* @param rows the number of rows |
112 |
|
- |
* @param columns the number of columns |
113 |
|
- |
* @throws IndexOutOfBoundsException |
114 |
|
- |
*/ |
115 |
|
- |
public void resize(int rows, int columns) { |
116 |
|
- |
resizeColumns(columns); |
117 |
|
- |
resizeRows(rows); |
118 |
|
- |
} |
119 |
|
- |
|
120 |
|
- |
/** |
121 |
|
- |
* Resizes the grid to the specified number of columns. |
122 |
|
- |
* |
123 |
|
- |
* @param columns the number of columns |
124 |
|
- |
* @throws IndexOutOfBoundsException |
125 |
|
- |
*/ |
126 |
|
- |
public void resizeColumns(int columns) { |
127 |
|
- |
if (numColumns == columns) { |
128 |
|
- |
return; |
129 |
|
- |
} |
130 |
|
- |
if (columns < 0) { |
131 |
|
- |
throw new IndexOutOfBoundsException("Cannot set number of columns to " |
132 |
|
- |
+ columns); |
133 |
|
- |
} |
134 |
|
- |
|
135 |
|
- |
if (numColumns > columns) { |
136 |
|
- |
// Fewer columns. Remove extraneous cells. |
137 |
|
- |
for (int i = 0; i < numRows; i++) { |
138 |
|
- |
for (int j = numColumns - 1; j >= columns; j--) { |
139 |
|
- |
removeCell(i, j); |
140 |
|
- |
} |
141 |
|
- |
} |
142 |
|
- |
} else { |
143 |
|
- |
// More columns. add cells where necessary. |
144 |
|
- |
for (int i = 0; i < numRows; i++) { |
145 |
|
- |
for (int j = numColumns; j < columns; j++) { |
146 |
|
- |
insertCell(i, j); |
147 |
|
- |
} |
148 |
|
- |
} |
149 |
|
- |
} |
150 |
|
- |
numColumns = columns; |
151 |
|
- |
} |
152 |
|
- |
|
153 |
|
- |
/** |
154 |
|
- |
* Resizes the grid to the specified number of rows. |
155 |
|
- |
* |
156 |
|
- |
* @param rows the number of rows |
157 |
|
- |
* @throws IndexOutOfBoundsException |
158 |
|
- |
*/ |
159 |
|
- |
public void resizeRows(int rows) { |
160 |
|
- |
if (numRows == rows) { |
161 |
|
- |
return; |
162 |
|
- |
} |
163 |
|
- |
if (rows < 0) { |
164 |
|
- |
throw new IndexOutOfBoundsException("Cannot set number of rows to " |
165 |
|
- |
+ rows); |
166 |
|
- |
} |
167 |
|
- |
if (numRows < rows) { |
168 |
|
- |
Element tr = createRow(); |
169 |
|
- |
getBodyElement().appendChild(tr); |
170 |
|
- |
for (int i = numRows + 1; i < rows; i++) { |
171 |
|
- |
getBodyElement().appendChild(tr.cloneNode(true)); |
172 |
|
- |
} |
173 |
|
- |
numRows = rows; |
174 |
|
- |
} else { |
175 |
|
- |
while (numRows > rows) { |
176 |
|
- |
// Fewer rows. Remove extraneous ones. |
177 |
|
- |
removeRow(numRows - 1); |
178 |
|
- |
} |
179 |
|
- |
} |
180 |
|
- |
} |
181 |
|
- |
|
182 |
|
- |
/** |
183 |
|
- |
* Creates a new, empty cell. |
184 |
|
- |
*/ |
185 |
|
- |
@Override |
186 |
|
- |
protected Element createCell() { |
187 |
|
- |
Element td = super.createCell(); |
188 |
|
- |
|
189 |
|
- |
// Add a non-breaking space to the TD. This ensures that the cell is |
190 |
|
- |
// displayed. |
191 |
|
- |
DOM.setInnerHTML(td, " "); |
192 |
|
- |
return td; |
193 |
|
- |
} |
194 |
|
- |
|
195 |
|
- |
@Override |
196 |
|
- |
protected Element createRow() { |
197 |
|
- |
Element tr = super.createRow(); |
198 |
|
- |
for (int i = 0; i < numColumns; i++) { |
199 |
|
- |
tr.appendChild(createCell()); |
200 |
|
- |
} |
201 |
|
- |
return tr; |
202 |
|
- |
} |
203 |
|
- |
|
204 |
|
- |
/** |
205 |
|
- |
* Checks that a cell is a valid cell in the table. |
206 |
|
- |
* |
207 |
|
- |
* @param row the cell's row |
208 |
|
- |
* @param column the cell's column |
209 |
|
- |
* @throws IndexOutOfBoundsException |
210 |
|
- |
*/ |
211 |
|
- |
@Override |
212 |
|
- |
protected void prepareCell(int row, int column) { |
213 |
|
- |
// Ensure that the indices are not negative. |
214 |
|
- |
prepareRow(row); |
215 |
|
- |
if (column < 0) { |
216 |
|
- |
throw new IndexOutOfBoundsException( |
217 |
|
- |
"Cannot access a column with a negative index: " + column); |
218 |
|
- |
} |
219 |
|
- |
|
220 |
|
- |
if (column >= numColumns) { |
221 |
|
- |
throw new IndexOutOfBoundsException("Column index: " + column |
222 |
|
- |
+ ", Column size: " + numColumns); |
223 |
|
- |
} |
224 |
|
- |
} |
225 |
|
- |
|
226 |
|
- |
/** |
227 |
|
- |
* Checks that the column index is valid. |
228 |
|
- |
* |
229 |
|
- |
* @param column The column index to be checked |
230 |
|
- |
* @throws IndexOutOfBoundsException if the column is negative |
231 |
|
- |
*/ |
232 |
|
- |
@Override |
233 |
|
- |
protected void prepareColumn(int column) { |
234 |
|
- |
// Ensure that the indices are not negative. |
235 |
|
- |
if (column < 0) { |
236 |
|
- |
throw new IndexOutOfBoundsException( |
237 |
|
- |
"Cannot access a column with a negative index: " + column); |
238 |
|
- |
} |
239 |
|
- |
|
240 |
|
- |
/** |
241 |
|
- |
* Grid does not lazily create cells, so simply ensure that the requested |
242 |
|
- |
* column and column are valid |
243 |
|
- |
*/ |
244 |
|
- |
if (column >= numColumns) { |
245 |
|
- |
throw new IndexOutOfBoundsException("Column index: " + column |
246 |
|
- |
+ ", Column size: " + numColumns); |
247 |
|
- |
} |
248 |
|
- |
} |
249 |
|
- |
|
250 |
|
- |
/** |
251 |
|
- |
* Checks that the row index is valid. |
252 |
|
- |
* |
253 |
|
- |
* @param row The row index to be checked |
254 |
|
- |
* @throws IndexOutOfBoundsException if the row is negative |
255 |
|
- |
*/ |
256 |
|
- |
@Override |
257 |
|
- |
protected void prepareRow(int row) { |
258 |
|
- |
// Ensure that the indices are not negative. |
259 |
|
- |
if (row < 0) { |
260 |
|
- |
throw new IndexOutOfBoundsException( |
261 |
|
- |
"Cannot access a row with a negative index: " + row); |
262 |
|
- |
} |
263 |
|
- |
|
264 |
|
- |
/** |
265 |
|
- |
* Grid does not lazily create cells, so simply ensure that the requested |
266 |
|
- |
* row and column are valid |
267 |
|
- |
*/ |
268 |
|
- |
if (row >= numRows) { |
269 |
|
- |
throw new IndexOutOfBoundsException("Row index: " + row + ", Row size: " |
270 |
|
- |
+ numRows); |
|
25 |
+ |
public class Grid extends HTMLTable |
|
26 |
+ |
{ |
|
27 |
+ |
/** |
|
28 |
+ |
* Number of columns in the current grid. |
|
29 |
+ |
*/ |
|
30 |
+ |
protected int numColumns; |
|
31 |
+ |
|
|
32 |
+ |
/** |
|
33 |
+ |
* Number of rows in the current grid. |
|
34 |
+ |
*/ |
|
35 |
+ |
protected int numRows; |
|
36 |
+ |
|
|
37 |
+ |
/** |
|
38 |
+ |
* Constructor for <code>Grid</code>. |
|
39 |
+ |
*/ |
|
40 |
+ |
public Grid() |
|
41 |
+ |
{ |
|
42 |
+ |
super(); |
|
43 |
+ |
setClearText( " " ); |
|
44 |
+ |
setCellFormatter( new CellFormatter() ); |
|
45 |
+ |
setRowFormatter( new RowFormatter() ); |
|
46 |
+ |
setColumnFormatter( new ColumnFormatter() ); |
|
47 |
+ |
} |
|
48 |
+ |
|
|
49 |
+ |
/** |
|
50 |
+ |
* Constructs a grid with the requested size. |
|
51 |
+ |
* |
|
52 |
+ |
* @param rows the number of rows |
|
53 |
+ |
* @param columns the number of columns |
|
54 |
+ |
* |
|
55 |
+ |
* @throws IndexOutOfBoundsException |
|
56 |
+ |
*/ |
|
57 |
+ |
public Grid( int rows, int columns ) |
|
58 |
+ |
{ |
|
59 |
+ |
this(); |
|
60 |
+ |
resize( rows, columns ); |
|
61 |
+ |
} |
|
62 |
+ |
|
|
63 |
+ |
/** |
|
64 |
+ |
* Return number of columns. For grid, row argument is ignored as all grids |
|
65 |
+ |
* are rectangular. |
|
66 |
+ |
*/ |
|
67 |
+ |
@Override |
|
68 |
+ |
public int getCellCount( int row ) |
|
69 |
+ |
{ |
|
70 |
+ |
return numColumns; |
|
71 |
+ |
} |
|
72 |
+ |
|
|
73 |
+ |
/** |
|
74 |
+ |
* Gets the number of columns in this grid. |
|
75 |
+ |
* |
|
76 |
+ |
* @return the number of columns |
|
77 |
+ |
*/ |
|
78 |
+ |
public int getColumnCount() |
|
79 |
+ |
{ |
|
80 |
+ |
return numColumns; |
|
81 |
+ |
} |
|
82 |
+ |
|
|
83 |
+ |
/** |
|
84 |
+ |
* Return number of rows. |
|
85 |
+ |
*/ |
|
86 |
+ |
@Override |
|
87 |
+ |
public int getRowCount() |
|
88 |
+ |
{ |
|
89 |
+ |
return numRows; |
|
90 |
+ |
} |
|
91 |
+ |
|
|
92 |
+ |
/** |
|
93 |
+ |
* Inserts a new row into the table. If you want to add multiple rows at once, |
|
94 |
+ |
* use {@link #resize(int, int)} or {@link #resizeRows(int)} as they are more |
|
95 |
+ |
* efficient. |
|
96 |
+ |
* |
|
97 |
+ |
* @param beforeRow the index before which the new row will be inserted |
|
98 |
+ |
* |
|
99 |
+ |
* @return the index of the newly-created row |
|
100 |
+ |
* |
|
101 |
+ |
* @throws IndexOutOfBoundsException |
|
102 |
+ |
*/ |
|
103 |
+ |
@Override |
|
104 |
+ |
public int insertRow( int beforeRow ) |
|
105 |
+ |
{ |
|
106 |
+ |
int index = super.insertRow( beforeRow ); |
|
107 |
+ |
numRows++; |
|
108 |
+ |
return index; |
|
109 |
+ |
} |
|
110 |
+ |
|
|
111 |
+ |
@Override |
|
112 |
+ |
public void removeRow( int row ) |
|
113 |
+ |
{ |
|
114 |
+ |
super.removeRow( row ); |
|
115 |
+ |
numRows--; |
|
116 |
+ |
} |
|
117 |
+ |
|
|
118 |
+ |
/** |
|
119 |
+ |
* Resizes the grid. |
|
120 |
+ |
* |
|
121 |
+ |
* @param rows the number of rows |
|
122 |
+ |
* @param columns the number of columns |
|
123 |
+ |
* |
|
124 |
+ |
* @throws IndexOutOfBoundsException |
|
125 |
+ |
*/ |
|
126 |
+ |
public void resize( int rows, int columns ) |
|
127 |
+ |
{ |
|
128 |
+ |
resizeColumns( columns ); |
|
129 |
+ |
resizeRows( rows ); |
|
130 |
+ |
} |
|
131 |
+ |
|
|
132 |
+ |
/** |
|
133 |
+ |
* Resizes the grid to the specified number of columns. |
|
134 |
+ |
* |
|
135 |
+ |
* @param columns the number of columns |
|
136 |
+ |
* |
|
137 |
+ |
* @throws IndexOutOfBoundsException |
|
138 |
+ |
*/ |
|
139 |
+ |
public void resizeColumns( int columns ) |
|
140 |
+ |
{ |
|
141 |
+ |
if ( numColumns == columns ) |
|
142 |
+ |
{ |
|
143 |
+ |
return; |
|
144 |
+ |
} |
|
145 |
+ |
if ( columns < 0 ) |
|
146 |
+ |
{ |
|
147 |
+ |
throw new IndexOutOfBoundsException( "Cannot set number of columns to " + columns ); |
|
148 |
+ |
} |
|
149 |
+ |
|
|
150 |
+ |
if ( numColumns > columns ) |
|
151 |
+ |
{ |
|
152 |
+ |
// Fewer columns. Remove extraneous cells. |
|
153 |
+ |
for ( int i = 0; i < numRows; i++ ) |
|
154 |
+ |
{ |
|
155 |
+ |
for ( int j = numColumns - 1; j >= columns; j-- ) |
|
156 |
+ |
{ |
|
157 |
+ |
removeCell( i, j ); |
|
158 |
+ |
} |
|
159 |
+ |
} |
|
160 |
+ |
} |
|
161 |
+ |
else |
|
162 |
+ |
{ |
|
163 |
+ |
// More columns. add cells where necessary. |
|
164 |
+ |
for ( int i = 0; i < numRows; i++ ) |
|
165 |
+ |
{ |
|
166 |
+ |
for ( int j = numColumns; j < columns; j++ ) |
|
167 |
+ |
{ |
|
168 |
+ |
insertCell( i, j ); |
|
169 |
+ |
} |
|
170 |
+ |
} |
|
171 |
+ |
} |
|
172 |
+ |
numColumns = columns; |
|
173 |
+ |
} |
|
174 |
+ |
|
|
175 |
+ |
/** |
|
176 |
+ |
* Resizes the grid to the specified number of rows. |
|
177 |
+ |
* |
|
178 |
+ |
* @param rows the number of rows |
|
179 |
+ |
* |
|
180 |
+ |
* @throws IndexOutOfBoundsException |
|
181 |
+ |
*/ |
|
182 |
+ |
public void resizeRows( int rows ) |
|
183 |
+ |
{ |
|
184 |
+ |
if ( numRows == rows ) |
|
185 |
+ |
{ |
|
186 |
+ |
return; |
|
187 |
+ |
} |
|
188 |
+ |
if ( rows < 0 ) |
|
189 |
+ |
{ |
|
190 |
+ |
throw new IndexOutOfBoundsException( "Cannot set number of rows to " + rows ); |
|
191 |
+ |
} |
|
192 |
+ |
if ( numRows < rows ) |
|
193 |
+ |
{ |
|
194 |
+ |
Element tr = createRow(); |
|
195 |
+ |
getBodyElement().appendChild( tr ); |
|
196 |
+ |
for ( int i = numRows + 1; i < rows; i++ ) |
|
197 |
+ |
{ |
|
198 |
+ |
getBodyElement().appendChild( tr.cloneNode( true ) ); |
|
199 |
+ |
} |
|
200 |
+ |
numRows = rows; |
|
201 |
+ |
} |
|
202 |
+ |
else |
|
203 |
+ |
{ |
|
204 |
+ |
while ( numRows > rows ) |
|
205 |
+ |
{ |
|
206 |
+ |
// Fewer rows. Remove extraneous ones. |
|
207 |
+ |
removeRow( numRows - 1 ); |
|
208 |
+ |
} |
|
209 |
+ |
} |
|
210 |
+ |
} |
|
211 |
+ |
|
|
212 |
+ |
/** |
|
213 |
+ |
* Creates a new, empty cell. |
|
214 |
+ |
*/ |
|
215 |
+ |
@Override |
|
216 |
+ |
protected Element createCell() |
|
217 |
+ |
{ |
|
218 |
+ |
Element td = super.createCell(); |
|
219 |
+ |
|
|
220 |
+ |
// Add a non-breaking space to the TD. This ensures that the cell is |
|
221 |
+ |
// displayed. |
|
222 |
+ |
DOM.setInnerHTML( td, " " ); |
|
223 |
+ |
return td; |
|
224 |
+ |
} |
|
225 |
+ |
|
|
226 |
+ |
@Override |
|
227 |
+ |
protected Element createRow() |
|
228 |
+ |
{ |
|
229 |
+ |
Element tr = super.createRow(); |
|
230 |
+ |
for ( int i = 0; i < numColumns; i++ ) |
|
231 |
+ |
{ |
|
232 |
+ |
tr.appendChild( createCell() ); |
|
233 |
+ |
} |
|
234 |
+ |
return tr; |
|
235 |
+ |
} |
|
236 |
+ |
|
|
237 |
+ |
/** |
|
238 |
+ |
* Checks that a cell is a valid cell in the table. |
|
239 |
+ |
* |
|
240 |
+ |
* @param row the cell's row |
|
241 |
+ |
* @param column the cell's column |
|
242 |
+ |
* |
|
243 |
+ |
* @throws IndexOutOfBoundsException |
|
244 |
+ |
*/ |
|
245 |
+ |
@Override |
|
246 |
+ |
protected void prepareCell( int row, int column ) |
|
247 |
+ |
{ |
|
248 |
+ |
// Ensure that the indices are not negative. |
|
249 |
+ |
prepareRow( row ); |
|
250 |
+ |
if ( column < 0 ) |
|
251 |
+ |
{ |
|
252 |
+ |
throw new IndexOutOfBoundsException( "Cannot access a column with a negative index: " + column ); |
|
253 |
+ |
} |
|
254 |
+ |
|
|
255 |
+ |
if ( column >= numColumns ) |
|
256 |
+ |
{ |
|
257 |
+ |
throw new IndexOutOfBoundsException( "Column index: " + column + ", Column size: " + numColumns ); |
|
258 |
+ |
} |
|
259 |
+ |
} |
|
260 |
+ |
|
|
261 |
+ |
/** |
|
262 |
+ |
* Checks that the column index is valid. |
|
263 |
+ |
* |
|
264 |
+ |
* @param column The column index to be checked |
|
265 |
+ |
* |
|
266 |
+ |
* @throws IndexOutOfBoundsException if the column is negative |
|
267 |
+ |
*/ |
|
268 |
+ |
@Override |
|
269 |
+ |
protected void prepareColumn( int column ) |
|
270 |
+ |
{ |
|
271 |
+ |
// Ensure that the indices are not negative. |
|
272 |
+ |
if ( column < 0 ) |
|
273 |
+ |
{ |
|
274 |
+ |
throw new IndexOutOfBoundsException( "Cannot access a column with a negative index: " + column ); |
|
275 |
+ |
} |
|
276 |
+ |
|
|
277 |
+ |
/** |
|
278 |
+ |
* Grid does not lazily create cells, so simply ensure that the requested |
|
279 |
+ |
* column and column are valid |
|
280 |
+ |
*/ |
|
281 |
+ |
if ( column >= numColumns ) |
|
282 |
+ |
{ |
|
283 |
+ |
throw new IndexOutOfBoundsException( "Column index: " + column + ", Column size: " + numColumns ); |
|
284 |
+ |
} |
|
285 |
+ |
} |
|
286 |
+ |
|
|
287 |
+ |
/** |
|
288 |
+ |
* Checks that the row index is valid. |
|
289 |
+ |
* |
|
290 |
+ |
* @param row The row index to be checked |
|
291 |
+ |
* |
|
292 |
+ |
* @throws IndexOutOfBoundsException if the row is negative |
|
293 |
+ |
*/ |
|
294 |
+ |
@Override |
|
295 |
+ |
protected void prepareRow( int row ) |
|
296 |
+ |
{ |
|
297 |
+ |
// Ensure that the indices are not negative. |
|
298 |
+ |
if ( row < 0 ) |
|
299 |
+ |
{ |
|
300 |
+ |
throw new IndexOutOfBoundsException( "Cannot access a row with a negative index: " + row ); |
|
301 |
+ |
} |
|
302 |
+ |
|
|
303 |
+ |
/** |
|
304 |
+ |
* Grid does not lazily create cells, so simply ensure that the requested |
|
305 |
+ |
* row and column are valid |
|
306 |
+ |
*/ |
|
307 |
+ |
if ( row >= numRows ) |
|
308 |
+ |
{ |
|
309 |
+ |
throw new IndexOutOfBoundsException( "Row index: " + row + ", Row size: " + numRows ); |
|
310 |
+ |
} |
271 |
311 |
|
} |
272 |
|
- |
} |
273 |
312 |
|
} |