|
@@ -15,13 +15,13 @@ |
15 |
15 |
|
*/ |
16 |
16 |
|
package com.google.gwt.gen2.table.client; |
17 |
17 |
|
|
18 |
|
- |
import java.util.*; |
19 |
|
- |
|
20 |
18 |
|
import com.google.gwt.user.client.*; |
21 |
19 |
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment.*; |
22 |
20 |
|
import com.google.gwt.user.client.ui.HasVerticalAlignment.*; |
23 |
21 |
|
import com.google.gwt.user.client.ui.*; |
24 |
22 |
|
|
|
23 |
+ |
import java.util.*; |
|
24 |
+ |
|
25 |
25 |
|
/** |
26 |
26 |
|
* This class should replace the actual class of the same name. |
27 |
27 |
|
* <p/> |
|
@@ -30,13 +30,11 @@ |
30 |
30 |
|
* Steps to incorporate: 1. Replace "OverrideDOM." with "DOM." 2. Copy contents |
31 |
31 |
|
* to actual HTMLTable class |
32 |
32 |
|
*/ |
33 |
|
- |
public abstract class HTMLTable extends Gen2TablePanel implements SourcesTableEvents |
34 |
|
- |
{ |
|
33 |
+ |
public abstract class HTMLTable extends Gen2TablePanel implements SourcesTableEvents { |
35 |
34 |
|
/** |
36 |
35 |
|
* This class contains methods used to format a table's cells. |
37 |
36 |
|
*/ |
38 |
|
- |
public class CellFormatter |
39 |
|
- |
{ |
|
37 |
+ |
public class CellFormatter { |
40 |
38 |
|
/** |
41 |
39 |
|
* Adds a style to the specified cell. |
42 |
40 |
|
* |
|
@@ -46,8 +44,7 @@ |
46 |
44 |
|
* |
47 |
45 |
|
* @see UIObject#addStyleName(String) |
48 |
46 |
|
*/ |
49 |
|
- |
public void addStyleName( int row, int column, String styleName ) |
50 |
|
- |
{ |
|
47 |
+ |
public void addStyleName( int row, int column, String styleName ) { |
51 |
48 |
|
prepareCell( row, column ); |
52 |
49 |
|
Element td = getRawElement( row, column ); |
53 |
50 |
|
UIObject.setStyleName( td, styleName, true ); |
|
@@ -63,8 +60,7 @@ |
63 |
60 |
|
* |
64 |
61 |
|
* @throws IndexOutOfBoundsException |
65 |
62 |
|
*/ |
66 |
|
- |
public Element getElement( int row, int column ) |
67 |
|
- |
{ |
|
63 |
+ |
public Element getElement( int row, int column ) { |
68 |
64 |
|
checkCellBounds( row, column ); |
69 |
65 |
|
return getRawElement( row, column ); |
70 |
66 |
|
} |
|
@@ -80,8 +76,7 @@ |
80 |
76 |
|
* @throws IndexOutOfBoundsException |
81 |
77 |
|
* @see UIObject#getStyleName() |
82 |
78 |
|
*/ |
83 |
|
- |
public String getStyleName( int row, int column ) |
84 |
|
- |
{ |
|
79 |
+ |
public String getStyleName( int row, int column ) { |
85 |
80 |
|
return UIObject.getStyleName( getElement( row, column ) ); |
86 |
81 |
|
} |
87 |
82 |
|
|
|
@@ -96,8 +91,7 @@ |
96 |
91 |
|
* @throws IndexOutOfBoundsException |
97 |
92 |
|
* @see UIObject#getStylePrimaryName() |
98 |
93 |
|
*/ |
99 |
|
- |
public String getStylePrimaryName( int row, int column ) |
100 |
|
- |
{ |
|
94 |
+ |
public String getStylePrimaryName( int row, int column ) { |
101 |
95 |
|
return UIObject.getStylePrimaryName( getElement( row, column ) ); |
102 |
96 |
|
} |
103 |
97 |
|
|
|
@@ -109,8 +103,7 @@ |
109 |
103 |
|
* |
110 |
104 |
|
* @return <code>true</code> if the object is visible |
111 |
105 |
|
*/ |
112 |
|
- |
public boolean isVisible( int row, int column ) |
113 |
|
- |
{ |
|
106 |
+ |
public boolean isVisible( int row, int column ) { |
114 |
107 |
|
Element e = getElement( row, column ); |
115 |
108 |
|
return UIObject.isVisible( e ); |
116 |
109 |
|
} |
|
@@ -125,8 +118,7 @@ |
125 |
118 |
|
* @throws IndexOutOfBoundsException |
126 |
119 |
|
* @see UIObject#removeStyleName(String) |
127 |
120 |
|
*/ |
128 |
|
- |
public void removeStyleName( int row, int column, String styleName ) |
129 |
|
- |
{ |
|
121 |
+ |
public void removeStyleName( int row, int column, String styleName ) { |
130 |
122 |
|
checkCellBounds( row, column ); |
131 |
123 |
|
Element td = getRawElement( row, column ); |
132 |
124 |
|
UIObject.setStyleName( td, styleName, false ); |
|
@@ -145,8 +137,7 @@ |
145 |
137 |
|
* |
146 |
138 |
|
* @throws IndexOutOfBoundsException |
147 |
139 |
|
*/ |
148 |
|
- |
public void setAlignment( int row, int column, HorizontalAlignmentConstant hAlign, VerticalAlignmentConstant vAlign ) |
149 |
|
- |
{ |
|
140 |
+ |
public void setAlignment( int row, int column, HorizontalAlignmentConstant hAlign, VerticalAlignmentConstant vAlign ) { |
150 |
141 |
|
setHorizontalAlignment( row, column, hAlign ); |
151 |
142 |
|
setVerticalAlignment( row, column, vAlign ); |
152 |
143 |
|
} |
|
@@ -160,8 +151,7 @@ |
160 |
151 |
|
* |
161 |
152 |
|
* @throws IndexOutOfBoundsException |
162 |
153 |
|
*/ |
163 |
|
- |
public void setHeight( int row, int column, String height ) |
164 |
|
- |
{ |
|
154 |
+ |
public void setHeight( int row, int column, String height ) { |
165 |
155 |
|
prepareCell( row, column ); |
166 |
156 |
|
Element elem = getRawElement( row, column ); |
167 |
157 |
|
DOM.setElementProperty( elem, "height", height ); |
|
@@ -177,8 +167,7 @@ |
177 |
167 |
|
* |
178 |
168 |
|
* @throws IndexOutOfBoundsException |
179 |
169 |
|
*/ |
180 |
|
- |
public void setHorizontalAlignment( int row, int column, HorizontalAlignmentConstant align ) |
181 |
|
- |
{ |
|
170 |
+ |
public void setHorizontalAlignment( int row, int column, HorizontalAlignmentConstant align ) { |
182 |
171 |
|
prepareCell( row, column ); |
183 |
172 |
|
Element elem = getRawElement( row, column ); |
184 |
173 |
|
DOM.setElementProperty( elem, "align", align.getTextAlignString() ); |
|
@@ -194,8 +183,7 @@ |
194 |
183 |
|
* @throws IndexOutOfBoundsException |
195 |
184 |
|
* @see UIObject#setStyleName(String) |
196 |
185 |
|
*/ |
197 |
|
- |
public void setStyleName( int row, int column, String styleName ) |
198 |
|
- |
{ |
|
186 |
+ |
public void setStyleName( int row, int column, String styleName ) { |
199 |
187 |
|
prepareCell( row, column ); |
200 |
188 |
|
UIObject.setStyleName( getRawElement( row, column ), styleName ); |
201 |
189 |
|
} |
|
@@ -210,8 +198,7 @@ |
210 |
198 |
|
* @throws IndexOutOfBoundsException |
211 |
199 |
|
* @see UIObject#setStylePrimaryName(String) |
212 |
200 |
|
*/ |
213 |
|
- |
public void setStylePrimaryName( int row, int column, String styleName ) |
214 |
|
- |
{ |
|
201 |
+ |
public void setStylePrimaryName( int row, int column, String styleName ) { |
215 |
202 |
|
UIObject.setStylePrimaryName( getRawElement( row, column ), styleName ); |
216 |
203 |
|
} |
217 |
204 |
|
|
|
@@ -225,8 +212,7 @@ |
225 |
212 |
|
* |
226 |
213 |
|
* @throws IndexOutOfBoundsException |
227 |
214 |
|
*/ |
228 |
|
- |
public void setVerticalAlignment( int row, int column, VerticalAlignmentConstant align ) |
229 |
|
- |
{ |
|
215 |
+ |
public void setVerticalAlignment( int row, int column, VerticalAlignmentConstant align ) { |
230 |
216 |
|
prepareCell( row, column ); |
231 |
217 |
|
DOM.setStyleAttribute( getRawElement( row, column ), "verticalAlign", align.getVerticalAlignString() ); |
232 |
218 |
|
} |
|
@@ -241,8 +227,7 @@ |
241 |
227 |
|
* @param visible <code>true</code> to show the cell, <code>false</code> |
242 |
228 |
|
* to hide it |
243 |
229 |
|
*/ |
244 |
|
- |
public void setVisible( int row, int column, boolean visible ) |
245 |
|
- |
{ |
|
230 |
+ |
public void setVisible( int row, int column, boolean visible ) { |
246 |
231 |
|
Element e = ensureElement( row, column ); |
247 |
232 |
|
UIObject.setVisible( e, visible ); |
248 |
233 |
|
} |
|
@@ -256,8 +241,7 @@ |
256 |
241 |
|
* |
257 |
242 |
|
* @throws IndexOutOfBoundsException |
258 |
243 |
|
*/ |
259 |
|
- |
public void setWidth( int row, int column, String width ) |
260 |
|
- |
{ |
|
244 |
+ |
public void setWidth( int row, int column, String width ) { |
261 |
245 |
|
// Give the subclass a chance to prepare the cell. |
262 |
246 |
|
prepareCell( row, column ); |
263 |
247 |
|
DOM.setElementProperty( getRawElement( row, column ), "width", width ); |
|
@@ -272,8 +256,7 @@ |
272 |
256 |
|
* |
273 |
257 |
|
* @throws IndexOutOfBoundsException |
274 |
258 |
|
*/ |
275 |
|
- |
public void setWordWrap( int row, int column, boolean wrap ) |
276 |
|
- |
{ |
|
259 |
+ |
public void setWordWrap( int row, int column, boolean wrap ) { |
277 |
260 |
|
prepareCell( row, column ); |
278 |
261 |
|
String wrapValue = wrap ? "" : "nowrap"; |
279 |
262 |
|
DOM.setStyleAttribute( getElement( row, column ), "whiteSpace", wrapValue ); |
|
@@ -290,8 +273,7 @@ |
290 |
273 |
|
* |
291 |
274 |
|
* @throws IndexOutOfBoundsException |
292 |
275 |
|
*/ |
293 |
|
- |
protected Element ensureElement( int row, int column ) |
294 |
|
- |
{ |
|
276 |
+ |
protected Element ensureElement( int row, int column ) { |
295 |
277 |
|
prepareCell( row, column ); |
296 |
278 |
|
return getRawElement( row, column ); |
297 |
279 |
|
} |
|
@@ -307,8 +289,7 @@ |
307 |
289 |
|
* |
308 |
290 |
|
* @throws IndexOutOfBoundsException |
309 |
291 |
|
*/ |
310 |
|
- |
protected String getAttr( int row, int column, String attr ) |
311 |
|
- |
{ |
|
292 |
+ |
protected String getAttr( int row, int column, String attr ) { |
312 |
293 |
|
Element elem = getElement( row, column ); |
313 |
294 |
|
return DOM.getElementAttribute( elem, attr ); |
314 |
295 |
|
} |
|
@@ -322,8 +303,7 @@ |
322 |
303 |
|
* |
323 |
304 |
|
* @return the column's TD element |
324 |
305 |
|
*/ |
325 |
|
- |
protected Element getRawElement( int row, int column ) |
326 |
|
- |
{ |
|
306 |
+ |
protected Element getRawElement( int row, int column ) { |
327 |
307 |
|
return getCellElement( bodyElem, row, column ); |
328 |
308 |
|
} |
329 |
309 |
|
|
|
@@ -337,8 +317,7 @@ |
337 |
317 |
|
* |
338 |
318 |
|
* @throws IndexOutOfBoundsException |
339 |
319 |
|
*/ |
340 |
|
- |
protected void setAttr( int row, int column, String attrName, String value ) |
341 |
|
- |
{ |
|
320 |
+ |
protected void setAttr( int row, int column, String attrName, String value ) { |
342 |
321 |
|
Element elem = ensureElement( row, column ); |
343 |
322 |
|
DOM.setElementAttribute( elem, attrName, value ); |
344 |
323 |
|
} |
|
@@ -362,8 +341,7 @@ |
362 |
341 |
|
* This class contains methods used to format a table's columns. It is limited |
363 |
342 |
|
* by the support cross-browser HTML support for column formatting. |
364 |
343 |
|
*/ |
365 |
|
- |
public class ColumnFormatter |
366 |
|
- |
{ |
|
344 |
+ |
public class ColumnFormatter { |
367 |
345 |
|
protected Element columnGroup; |
368 |
346 |
|
|
369 |
347 |
|
/** |
|
@@ -375,8 +353,7 @@ |
375 |
353 |
|
* @throws IndexOutOfBoundsException |
376 |
354 |
|
* @see UIObject#addStyleName(String) |
377 |
355 |
|
*/ |
378 |
|
- |
public void addStyleName( int col, String styleName ) |
379 |
|
- |
{ |
|
356 |
+ |
public void addStyleName( int col, String styleName ) { |
380 |
357 |
|
UIObject.setStyleName( ensureColumn( col ), styleName, true ); |
381 |
358 |
|
} |
382 |
359 |
|
|
|
@@ -390,8 +367,7 @@ |
390 |
367 |
|
* @throws IndexOutOfBoundsException |
391 |
368 |
|
* @see UIObject#getStyleName() |
392 |
369 |
|
*/ |
393 |
|
- |
public String getStyleName( int column ) |
394 |
|
- |
{ |
|
370 |
+ |
public String getStyleName( int column ) { |
395 |
371 |
|
return UIObject.getStyleName( ensureColumn( column ) ); |
396 |
372 |
|
} |
397 |
373 |
|
|
|
@@ -405,8 +381,7 @@ |
405 |
381 |
|
* @throws IndexOutOfBoundsException |
406 |
382 |
|
* @see UIObject#getStylePrimaryName() |
407 |
383 |
|
*/ |
408 |
|
- |
public String getStylePrimaryName( int column ) |
409 |
|
- |
{ |
|
384 |
+ |
public String getStylePrimaryName( int column ) { |
410 |
385 |
|
return UIObject.getStylePrimaryName( ensureColumn( column ) ); |
411 |
386 |
|
} |
412 |
387 |
|
|
|
@@ -419,8 +394,7 @@ |
419 |
394 |
|
* @throws IndexOutOfBoundsException |
420 |
395 |
|
* @see UIObject#removeStyleName(String) |
421 |
396 |
|
*/ |
422 |
|
- |
public void removeStyleName( int column, String styleName ) |
423 |
|
- |
{ |
|
397 |
+ |
public void removeStyleName( int column, String styleName ) { |
424 |
398 |
|
UIObject.setStyleName( ensureColumn( column ), styleName, false ); |
425 |
399 |
|
} |
426 |
400 |
|
|
|
@@ -433,8 +407,7 @@ |
433 |
407 |
|
* @throws IndexOutOfBoundsException |
434 |
408 |
|
* @see UIObject#setStyleName(String) |
435 |
409 |
|
*/ |
436 |
|
- |
public void setStyleName( int column, String styleName ) |
437 |
|
- |
{ |
|
410 |
+ |
public void setStyleName( int column, String styleName ) { |
438 |
411 |
|
UIObject.setStyleName( ensureColumn( column ), styleName ); |
439 |
412 |
|
} |
440 |
413 |
|
|
|
@@ -447,8 +420,7 @@ |
447 |
420 |
|
* @throws IndexOutOfBoundsException |
448 |
421 |
|
* @see UIObject#setStylePrimaryName(String) |
449 |
422 |
|
*/ |
450 |
|
- |
public void setStylePrimaryName( int column, String styleName ) |
451 |
|
- |
{ |
|
423 |
+ |
public void setStylePrimaryName( int column, String styleName ) { |
452 |
424 |
|
UIObject.setStylePrimaryName( ensureColumn( column ), styleName ); |
453 |
425 |
|
} |
454 |
426 |
|
|
|
@@ -460,22 +432,18 @@ |
460 |
432 |
|
* |
461 |
433 |
|
* @throws IndexOutOfBoundsException |
462 |
434 |
|
*/ |
463 |
|
- |
public void setWidth( int column, String width ) |
464 |
|
- |
{ |
|
435 |
+ |
public void setWidth( int column, String width ) { |
465 |
436 |
|
DOM.setElementProperty( ensureColumn( column ), "width", width ); |
466 |
437 |
|
} |
467 |
438 |
|
|
468 |
|
- |
private Element ensureColumn( int col ) |
469 |
|
- |
{ |
|
439 |
+ |
private Element ensureColumn( int col ) { |
470 |
440 |
|
prepareColumn( col ); |
471 |
441 |
|
prepareColumnGroup(); |
472 |
442 |
|
|
473 |
443 |
|
int num = DOM.getChildCount( columnGroup ); |
474 |
|
- |
if ( num <= col ) |
475 |
|
- |
{ |
|
444 |
+ |
if ( num <= col ) { |
476 |
445 |
|
Element colElement = null; |
477 |
|
- |
for ( int i = num; i <= col; i++ ) |
478 |
|
- |
{ |
|
446 |
+ |
for ( int i = num; i <= col; i++ ) { |
479 |
447 |
|
colElement = DOM.createElement( "col" ); |
480 |
448 |
|
DOM.appendChild( columnGroup, colElement ); |
481 |
449 |
|
} |
|
@@ -490,10 +458,8 @@ |
490 |
458 |
|
* where the col tag will affect the wrong column if a col tag doesn't exist |
491 |
459 |
|
* when the element is attached to the page. |
492 |
460 |
|
*/ |
493 |
|
- |
private void prepareColumnGroup() |
494 |
|
- |
{ |
495 |
|
- |
if ( columnGroup == null ) |
496 |
|
- |
{ |
|
461 |
+ |
private void prepareColumnGroup() { |
|
462 |
+ |
if ( columnGroup == null ) { |
497 |
463 |
|
columnGroup = DOM.createElement( "colgroup" ); |
498 |
464 |
|
DOM.insertChild( tableElem, columnGroup, 0 ); |
499 |
465 |
|
DOM.appendChild( columnGroup, DOM.createElement( "col" ) ); |
|
@@ -504,8 +470,7 @@ |
504 |
470 |
|
/** |
505 |
471 |
|
* This class contains methods used to format a table's rows. |
506 |
472 |
|
*/ |
507 |
|
- |
public class RowFormatter |
508 |
|
- |
{ |
|
473 |
+ |
public class RowFormatter { |
509 |
474 |
|
|
510 |
475 |
|
/** |
511 |
476 |
|
* Adds a style to the specified row. |
|
@@ -516,8 +481,7 @@ |
516 |
481 |
|
* @throws IndexOutOfBoundsException |
517 |
482 |
|
* @see UIObject#addStyleName(String) |
518 |
483 |
|
*/ |
519 |
|
- |
public void addStyleName( int row, String styleName ) |
520 |
|
- |
{ |
|
484 |
+ |
public void addStyleName( int row, String styleName ) { |
521 |
485 |
|
UIObject.setStyleName( ensureElement( row ), styleName, true ); |
522 |
486 |
|
} |
523 |
487 |
|
|
|
@@ -530,8 +494,7 @@ |
530 |
494 |
|
* |
531 |
495 |
|
* @throws IndexOutOfBoundsException |
532 |
496 |
|
*/ |
533 |
|
- |
public Element getElement( int row ) |
534 |
|
- |
{ |
|
497 |
+ |
public Element getElement( int row ) { |
535 |
498 |
|
checkRowBounds( row ); |
536 |
499 |
|
return getRawElement( row ); |
537 |
500 |
|
} |
|
@@ -546,8 +509,7 @@ |
546 |
509 |
|
* @throws IndexOutOfBoundsException |
547 |
510 |
|
* @see UIObject#getStyleName() |
548 |
511 |
|
*/ |
549 |
|
- |
public String getStyleName( int row ) |
550 |
|
- |
{ |
|
512 |
+ |
public String getStyleName( int row ) { |
551 |
513 |
|
return UIObject.getStyleName( getElement( row ) ); |
552 |
514 |
|
} |
553 |
515 |
|
|
|
@@ -561,8 +523,7 @@ |
561 |
523 |
|
* @throws IndexOutOfBoundsException |
562 |
524 |
|
* @see UIObject#getStylePrimaryName() |
563 |
525 |
|
*/ |
564 |
|
- |
public String getStylePrimaryName( int row ) |
565 |
|
- |
{ |
|
526 |
+ |
public String getStylePrimaryName( int row ) { |
566 |
527 |
|
return UIObject.getStylePrimaryName( getElement( row ) ); |
567 |
528 |
|
} |
568 |
529 |
|
|
|
@@ -574,8 +535,7 @@ |
574 |
535 |
|
* |
575 |
536 |
|
* @return <code>true</code> if the row is visible |
576 |
537 |
|
*/ |
577 |
|
- |
public boolean isVisible( int row ) |
578 |
|
- |
{ |
|
538 |
+ |
public boolean isVisible( int row ) { |
579 |
539 |
|
Element e = getElement( row ); |
580 |
540 |
|
return UIObject.isVisible( e ); |
581 |
541 |
|
} |
|
@@ -589,8 +549,7 @@ |
589 |
549 |
|
* @throws IndexOutOfBoundsException |
590 |
550 |
|
* @see UIObject#removeStyleName(String) |
591 |
551 |
|
*/ |
592 |
|
- |
public void removeStyleName( int row, String styleName ) |
593 |
|
- |
{ |
|
552 |
+ |
public void removeStyleName( int row, String styleName ) { |
594 |
553 |
|
UIObject.setStyleName( ensureElement( row ), styleName, false ); |
595 |
554 |
|
} |
596 |
555 |
|
|
|
@@ -603,8 +562,7 @@ |
603 |
562 |
|
* @throws IndexOutOfBoundsException |
604 |
563 |
|
* @see UIObject#setStyleName(String) |
605 |
564 |
|
*/ |
606 |
|
- |
public void setStyleName( int row, String styleName ) |
607 |
|
- |
{ |
|
565 |
+ |
public void setStyleName( int row, String styleName ) { |
608 |
566 |
|
UIObject.setStyleName( ensureElement( row ), styleName ); |
609 |
567 |
|
} |
610 |
568 |
|
|
|
@@ -617,8 +575,7 @@ |
617 |
575 |
|
* @throws IndexOutOfBoundsException |
618 |
576 |
|
* @see UIObject#setStylePrimaryName(String) |
619 |
577 |
|
*/ |
620 |
|
- |
public void setStylePrimaryName( int row, String styleName ) |
621 |
|
- |
{ |
|
578 |
+ |
public void setStylePrimaryName( int row, String styleName ) { |
622 |
579 |
|
UIObject.setStylePrimaryName( ensureElement( row ), styleName ); |
623 |
580 |
|
} |
624 |
581 |
|
|
|
@@ -631,8 +588,7 @@ |
631 |
588 |
|
* |
632 |
589 |
|
* @throws IndexOutOfBoundsException |
633 |
590 |
|
*/ |
634 |
|
- |
public void setVerticalAlign( int row, VerticalAlignmentConstant align ) |
635 |
|
- |
{ |
|
591 |
+ |
public void setVerticalAlign( int row, VerticalAlignmentConstant align ) { |
636 |
592 |
|
DOM.setStyleAttribute( ensureElement( row ), "verticalAlign", align.getVerticalAlignString() ); |
637 |
593 |
|
} |
638 |
594 |
|
|
|
@@ -643,8 +599,7 @@ |
643 |
599 |
|
* @param visible <code>true</code> to show the row, <code>false</code> |
644 |
600 |
|
* to hide it |
645 |
601 |
|
*/ |
646 |
|
- |
public void setVisible( int row, boolean visible ) |
647 |
|
- |
{ |
|
602 |
+ |
public void setVisible( int row, boolean visible ) { |
648 |
603 |
|
Element e = ensureElement( row ); |
649 |
604 |
|
UIObject.setVisible( e, visible ); |
650 |
605 |
|
} |
|
@@ -659,8 +614,7 @@ |
659 |
614 |
|
* |
660 |
615 |
|
* @throws IndexOutOfBoundsException |
661 |
616 |
|
*/ |
662 |
|
- |
protected Element ensureElement( int row ) |
663 |
|
- |
{ |
|
617 |
+ |
protected Element ensureElement( int row ) { |
664 |
618 |
|
prepareRow( row ); |
665 |
619 |
|
return getRawElement( row ); |
666 |
620 |
|
} |
|
@@ -672,8 +626,7 @@ |
672 |
626 |
|
* |
673 |
627 |
|
* @return the row element |
674 |
628 |
|
*/ |
675 |
|
- |
protected Element getRawElement( int row ) |
676 |
|
- |
{ |
|
629 |
+ |
protected Element getRawElement( int row ) { |
677 |
630 |
|
return getRow( bodyElem, row ); |
678 |
631 |
|
} |
679 |
632 |
|
|
|
@@ -690,8 +643,7 @@ |
690 |
643 |
|
* |
691 |
644 |
|
* @throws IndexOutOfBoundsException |
692 |
645 |
|
*/ |
693 |
|
- |
protected void setAttr( int row, String attrName, String value ) |
694 |
|
- |
{ |
|
646 |
+ |
protected void setAttr( int row, String attrName, String value ) { |
695 |
647 |
|
Element elem = ensureElement( row ); |
696 |
648 |
|
DOM.setElementAttribute( elem, attrName, value ); |
697 |
649 |
|
} |
|
@@ -700,16 +652,13 @@ |
700 |
652 |
|
/** |
701 |
653 |
|
* Creates a mapping from elements to their associated widgets. |
702 |
654 |
|
*/ |
703 |
|
- |
protected static class WidgetMapper |
704 |
|
- |
{ |
|
655 |
+ |
protected static class WidgetMapper { |
705 |
656 |
|
|
706 |
|
- |
private static class FreeNode |
707 |
|
- |
{ |
|
657 |
+ |
private static class FreeNode { |
708 |
658 |
|
int index; |
709 |
659 |
|
FreeNode next; |
710 |
660 |
|
|
711 |
|
- |
public FreeNode( int index, FreeNode next ) |
712 |
|
- |
{ |
|
661 |
+ |
public FreeNode( int index, FreeNode next ) { |
713 |
662 |
|
this.index = index; |
714 |
663 |
|
this.next = next; |
715 |
664 |
|
} |
|
@@ -739,11 +688,9 @@ |
739 |
688 |
|
* |
740 |
689 |
|
* @return the widget |
741 |
690 |
|
*/ |
742 |
|
- |
public Widget getWidget( Element elem ) |
743 |
|
- |
{ |
|
691 |
+ |
public Widget getWidget( Element elem ) { |
744 |
692 |
|
int index = getWidgetIndex( elem ); |
745 |
|
- |
if ( index < 0 ) |
746 |
|
- |
{ |
|
693 |
+ |
if ( index < 0 ) { |
747 |
694 |
|
return null; |
748 |
695 |
|
} |
749 |
696 |
|
return (Widget) widgetList.get( index ); |
|
@@ -754,16 +701,12 @@ |
754 |
701 |
|
* |
755 |
702 |
|
* @param widget widget to add |
756 |
703 |
|
*/ |
757 |
|
- |
public void putWidget( Widget widget ) |
758 |
|
- |
{ |
|
704 |
+ |
public void putWidget( Widget widget ) { |
759 |
705 |
|
int index; |
760 |
|
- |
if ( freeList == null ) |
761 |
|
- |
{ |
|
706 |
+ |
if ( freeList == null ) { |
762 |
707 |
|
index = widgetList.size(); |
763 |
708 |
|
widgetList.add( widget ); |
764 |
|
- |
} |
765 |
|
- |
else |
766 |
|
- |
{ |
|
709 |
+ |
} else { |
767 |
710 |
|
index = freeList.index; |
768 |
711 |
|
widgetList.set( index, widget ); |
769 |
712 |
|
freeList = freeList.next; |
|
@@ -776,8 +719,7 @@ |
776 |
719 |
|
* |
777 |
720 |
|
* @param elem the widget's element |
778 |
721 |
|
*/ |
779 |
|
- |
public void removeWidgetByElement( Element elem ) |
780 |
|
- |
{ |
|
722 |
+ |
public void removeWidgetByElement( Element elem ) { |
781 |
723 |
|
int index = getWidgetIndex( elem ); |
782 |
724 |
|
removeImpl( elem, index ); |
783 |
725 |
|
} |
|
@@ -787,11 +729,9 @@ |
787 |
729 |
|
* |
788 |
730 |
|
* @return the iterator |
789 |
731 |
|
*/ |
790 |
|
- |
public Iterator widgetIterator() |
791 |
|
- |
{ |
|
732 |
+ |
public Iterator widgetIterator() { |
792 |
733 |
|
// TODO: look at using the WidgetIterators class! |
793 |
|
- |
return new Iterator() |
794 |
|
- |
{ |
|
734 |
+ |
return new Iterator() { |
795 |
735 |
|
int lastIndex = -1; |
796 |
736 |
|
int nextIndex = -1; |
797 |
737 |
|
|
|
@@ -799,15 +739,12 @@ |
799 |
739 |
|
findNext(); |
800 |
740 |
|
} |
801 |
741 |
|
|
802 |
|
- |
public boolean hasNext() |
803 |
|
- |
{ |
|
742 |
+ |
public boolean hasNext() { |
804 |
743 |
|
return nextIndex < widgetList.size(); |
805 |
744 |
|
} |
806 |
745 |
|
|
807 |
|
- |
public Object next() |
808 |
|
- |
{ |
809 |
|
- |
if ( !hasNext() ) |
810 |
|
- |
{ |
|
746 |
+ |
public Object next() { |
|
747 |
+ |
if ( !hasNext() ) { |
811 |
748 |
|
throw new NoSuchElementException(); |
812 |
749 |
|
} |
813 |
750 |
|
Object result = widgetList.get( nextIndex ); |
|
@@ -816,10 +753,8 @@ |
816 |
753 |
|
return result; |
817 |
754 |
|
} |
818 |
755 |
|
|
819 |
|
- |
public void remove() |
820 |
|
- |
{ |
821 |
|
- |
if ( lastIndex < 0 ) |
822 |
|
- |
{ |
|
756 |
+ |
public void remove() { |
|
757 |
+ |
if ( lastIndex < 0 ) { |
823 |
758 |
|
throw new IllegalStateException(); |
824 |
759 |
|
} |
825 |
760 |
|
Widget w = (Widget) widgetList.get( lastIndex ); |
|
@@ -828,12 +763,9 @@ |
828 |
763 |
|
lastIndex = -1; |
829 |
764 |
|
} |
830 |
765 |
|
|
831 |
|
- |
private void findNext() |
832 |
|
- |
{ |
833 |
|
- |
while ( ++nextIndex < widgetList.size() ) |
834 |
|
- |
{ |
835 |
|
- |
if ( widgetList.get( nextIndex ) != null ) |
836 |
|
- |
{ |
|
766 |
+ |
private void findNext() { |
|
767 |
+ |
while ( ++nextIndex < widgetList.size() ) { |
|
768 |
+ |
if ( widgetList.get( nextIndex ) != null ) { |
837 |
769 |
|
return; |
838 |
770 |
|
} |
839 |
771 |
|
} |
|
@@ -841,8 +773,7 @@ |
841 |
773 |
|
}; |
842 |
774 |
|
} |
843 |
775 |
|
|
844 |
|
- |
private void removeImpl( Element elem, int index ) |
845 |
|
- |
{ |
|
776 |
+ |
private void removeImpl( Element elem, int index ) { |
846 |
777 |
|
clearWidgetIndex( elem ); |
847 |
778 |
|
widgetList.set( index, null ); |
848 |
779 |
|
freeList = new FreeNode( index, freeList ); |
|
@@ -889,8 +820,7 @@ |
889 |
820 |
|
/** |
890 |
821 |
|
* Create a new empty HTML Table. |
891 |
822 |
|
*/ |
892 |
|
- |
public HTMLTable() |
893 |
|
- |
{ |
|
823 |
+ |
public HTMLTable() { |
894 |
824 |
|
super(); |
895 |
825 |
|
tableElem = DOM.createTable(); |
896 |
826 |
|
bodyElem = DOM.createTBody(); |
|
@@ -904,10 +834,8 @@ |
904 |
834 |
|
* |
905 |
835 |
|
* @param listener listener to add |
906 |
836 |
|
*/ |
907 |
|
- |
public void addTableListener( TableListener listener ) |
908 |
|
- |
{ |
909 |
|
- |
if ( tableListeners == null ) |
910 |
|
- |
{ |
|
837 |
+ |
public void addTableListener( TableListener listener ) { |
|
838 |
+ |
if ( tableListeners == null ) { |
911 |
839 |
|
tableListeners = new TableListenerCollection(); |
912 |
840 |
|
} |
913 |
841 |
|
tableListeners.add( listener ); |
|
@@ -917,15 +845,11 @@ |
917 |
845 |
|
* Removes all widgets from this table, but does not remove other HTML or text |
918 |
846 |
|
* contents of cells. |
919 |
847 |
|
*/ |
920 |
|
- |
public void clear() |
921 |
|
- |
{ |
922 |
|
- |
for ( int row = 0; row < getRowCount(); ++row ) |
923 |
|
- |
{ |
924 |
|
- |
for ( int col = 0; col < getCellCount( row ); ++col ) |
925 |
|
- |
{ |
|
848 |
+ |
public void clear() { |
|
849 |
+ |
for ( int row = 0; row < getRowCount(); ++row ) { |
|
850 |
+ |
for ( int col = 0; col < getCellCount( row ); ++col ) { |
926 |
851 |
|
Widget child = getWidgetImpl( row, col ); |
927 |
|
- |
if ( child != null ) |
928 |
|
- |
{ |
|
852 |
+ |
if ( child != null ) { |
929 |
853 |
|
remove( child ); |
930 |
854 |
|
} |
931 |
855 |
|
} |
|
@@ -936,12 +860,9 @@ |
936 |
860 |
|
* Removes all widgets from this table, including other HTML or text contents |
937 |
861 |
|
* of cells. |
938 |
862 |
|
*/ |
939 |
|
- |
public void clearAll() |
940 |
|
- |
{ |
941 |
|
- |
for ( int row = 0; row < getRowCount(); row++ ) |
942 |
|
- |
{ |
943 |
|
- |
for ( int col = 0; col < getCellCount( row ); col++ ) |
944 |
|
- |
{ |
|
863 |
+ |
public void clearAll() { |
|
864 |
+ |
for ( int row = 0; row < getRowCount(); row++ ) { |
|
865 |
+ |
for ( int col = 0; col < getCellCount( row ); col++ ) { |
945 |
866 |
|
Element td = cellFormatter.getRawElement( row, col ); |
946 |
867 |
|
internalClearCell( td, true ); |
947 |
868 |
|
} |
|
@@ -959,8 +880,7 @@ |
959 |
880 |
|
* |
960 |
881 |
|
* @throws IndexOutOfBoundsException |
961 |
882 |
|
*/ |
962 |
|
- |
public boolean clearCell( int row, int column ) |
963 |
|
- |
{ |
|
883 |
+ |
public boolean clearCell( int row, int column ) { |
964 |
884 |
|
Element td = getCellFormatter().getElement( row, column ); |
965 |
885 |
|
return internalClearCell( td, true ); |
966 |
886 |
|
} |
|
@@ -980,8 +900,7 @@ |
980 |
900 |
|
* |
981 |
901 |
|
* @return this table's cell formatter |
982 |
902 |
|
*/ |
983 |
|
- |
public CellFormatter getCellFormatter() |
984 |
|
- |
{ |
|
903 |
+ |
public CellFormatter getCellFormatter() { |
985 |
904 |
|
return cellFormatter; |
986 |
905 |
|
} |
987 |
906 |
|
|
|
@@ -990,8 +909,7 @@ |
990 |
909 |
|
* |
991 |
910 |
|
* @return the cell padding, in pixels |
992 |
911 |
|
*/ |
993 |
|
- |
public int getCellPadding() |
994 |
|
- |
{ |
|
912 |
+ |
public int getCellPadding() { |
995 |
913 |
|
return DOM.getElementPropertyInt( tableElem, "cellPadding" ); |
996 |
914 |
|
} |
997 |
915 |
|
|
|
@@ -1000,8 +918,7 @@ |
1000 |
918 |
|
* |
1001 |
919 |
|
* @return the cell spacing, in pixels |
1002 |
920 |
|
*/ |
1003 |
|
- |
public int getCellSpacing() |
1004 |
|
- |
{ |
|
921 |
+ |
public int getCellSpacing() { |
1005 |
922 |
|
return DOM.getElementPropertyInt( tableElem, "cellSpacing" ); |
1006 |
923 |
|
} |
1007 |
924 |
|
|
|
@@ -1010,8 +927,7 @@ |
1010 |
927 |
|
* |
1011 |
928 |
|
* @return the column formatter |
1012 |
929 |
|
*/ |
1013 |
|
- |
public ColumnFormatter getColumnFormatter() |
1014 |
|
- |
{ |
|
930 |
+ |
public ColumnFormatter getColumnFormatter() { |
1015 |
931 |
|
return columnFormatter; |
1016 |
932 |
|
} |
1017 |
933 |
|
|
|
@@ -1021,28 +937,23 @@ |
1021 |
937 |
|
* @param event the event to be queried |
1022 |
938 |
|
* |
1023 |
939 |
|
* @return the TD associated with the event, or <code>null</code> if none is |
1024 |
|
- |
* found. |
|
940 |
+ |
* found. |
1025 |
941 |
|
*/ |
1026 |
|
- |
public Element getEventTargetCell( Event event ) |
1027 |
|
- |
{ |
|
942 |
+ |
public Element getEventTargetCell( Event event ) { |
1028 |
943 |
|
Element td = DOM.eventGetTarget( event ); |
1029 |
|
- |
for (; td != null; td = DOM.getParent( td ) ) |
1030 |
|
- |
{ |
|
944 |
+ |
for (; td != null; td = DOM.getParent( td ) ) { |
1031 |
945 |
|
// If it's a TD, it might be the one we're looking for. |
1032 |
|
- |
if ( "td".equalsIgnoreCase( td.getPropertyString( "tagName" ) ) ) |
1033 |
|
- |
{ |
|
946 |
+ |
if ( "td".equalsIgnoreCase( td.getPropertyString( "tagName" ) ) ) { |
1034 |
947 |
|
// Make sure it's directly a part of this table before returning |
1035 |
948 |
|
// it. |
1036 |
949 |
|
Element tr = DOM.getParent( td ); |
1037 |
950 |
|
Element body = DOM.getParent( tr ); |
1038 |
|
- |
if ( DOM.compare( body, bodyElem ) ) |
1039 |
|
- |
{ |
|
951 |
+ |
if ( DOM.compare( body, bodyElem ) ) { |
1040 |
952 |
|
return td; |
1041 |
953 |
|
} |
1042 |
954 |
|
} |
1043 |
955 |
|
// If we run into this table's body, we're out of options. |
1044 |
|
- |
if ( DOM.compare( td, bodyElem ) ) |
1045 |
|
- |
{ |
|
956 |
+ |
if ( DOM.compare( td, bodyElem ) ) { |
1046 |
957 |
|
return null; |
1047 |
958 |
|
} |
1048 |
959 |
|
} |
|
@@ -1055,27 +966,22 @@ |
1055 |
966 |
|
* @param event the event to be queried |
1056 |
967 |
|
* |
1057 |
968 |
|
* @return the TR associated with the event, or <code>null</code> if none is |
1058 |
|
- |
* found. |
|
969 |
+ |
* found. |
1059 |
970 |
|
*/ |
1060 |
|
- |
public Element getEventTargetRow( Event event ) |
1061 |
|
- |
{ |
|
971 |
+ |
public Element getEventTargetRow( Event event ) { |
1062 |
972 |
|
Element tr = DOM.eventGetTarget( event ); |
1063 |
|
- |
for (; tr != null; tr = DOM.getParent( tr ) ) |
1064 |
|
- |
{ |
|
973 |
+ |
for (; tr != null; tr = DOM.getParent( tr ) ) { |
1065 |
974 |
|
// If it's a TD, it might be the one we're looking for. |
1066 |
|
- |
if ( "tr".equalsIgnoreCase( tr.getPropertyString( "tagName" ) ) ) |
1067 |
|
- |
{ |
|
975 |
+ |
if ( "tr".equalsIgnoreCase( tr.getPropertyString( "tagName" ) ) ) { |
1068 |
976 |
|
// Make sure it's directly a part of this table before returning |
1069 |
977 |
|
// it. |
1070 |
978 |
|
Element body = DOM.getParent( tr ); |
1071 |
|
- |
if ( DOM.compare( body, bodyElem ) ) |
1072 |
|
- |
{ |
|
979 |
+ |
if ( DOM.compare( body, bodyElem ) ) { |
1073 |
980 |
|
return tr; |
1074 |
981 |
|
} |
1075 |
982 |
|
} |
1076 |
983 |
|
// If we run into this table's body, we're out of options. |
1077 |
|
- |
if ( DOM.compare( tr, bodyElem ) ) |
1078 |
|
- |
{ |
|
984 |
+ |
if ( DOM.compare( tr, bodyElem ) ) { |
1079 |
985 |
|
return null; |
1080 |
986 |
|
} |
1081 |
987 |
|
} |
|
@@ -1092,8 +998,7 @@ |
1092 |
998 |
|
* |
1093 |
999 |
|
* @throws IndexOutOfBoundsException |
1094 |
1000 |
|
*/ |
1095 |
|
- |
public String getHTML( int row, int column ) |
1096 |
|
- |
{ |
|
1001 |
+ |
public String getHTML( int row, int column ) { |
1097 |
1002 |
|
return DOM.getInnerHTML( cellFormatter.getElement( row, column ) ); |
1098 |
1003 |
|
} |
1099 |
1004 |
|
|
|
@@ -1109,8 +1014,7 @@ |
1109 |
1014 |
|
* |
1110 |
1015 |
|
* @return the table's row formatter |
1111 |
1016 |
|
*/ |
1112 |
|
- |
public RowFormatter getRowFormatter() |
1113 |
|
- |
{ |
|
1017 |
+ |
public RowFormatter getRowFormatter() { |
1114 |
1018 |
|
return rowFormatter; |
1115 |
1019 |
|
} |
1116 |
1020 |
|
|
|
@@ -1124,8 +1028,7 @@ |
1124 |
1028 |
|
* |
1125 |
1029 |
|
* @throws IndexOutOfBoundsException |
1126 |
1030 |
|
*/ |
1127 |
|
- |
public String getText( int row, int column ) |
1128 |
|
- |
{ |
|
1031 |
+ |
public String getText( int row, int column ) { |
1129 |
1032 |
|
return DOM.getInnerText( cellFormatter.getElement( row, column ) ); |
1130 |
1033 |
|
} |
1131 |
1034 |
|
|
|
@@ -1136,12 +1039,11 @@ |
1136 |
1039 |
|
* @param column the cell's column |
1137 |
1040 |
|
* |
1138 |
1041 |
|
* @return the widget in the specified cell, or <code>null</code> if none is |
1139 |
|
- |
* present |
|
1042 |
+ |
* present |
1140 |
1043 |
|
* |
1141 |
1044 |
|
* @throws IndexOutOfBoundsException |
1142 |
1045 |
|
*/ |
1143 |
|
- |
public Widget getWidget( int row, int column ) |
1144 |
|
- |
{ |
|
1046 |
+ |
public Widget getWidget( int row, int column ) { |
1145 |
1047 |
|
checkCellBounds( row, column ); |
1146 |
1048 |
|
return getWidgetImpl( row, column ); |
1147 |
1049 |
|
} |
|
@@ -1154,18 +1056,13 @@ |
1154 |
1056 |
|
* |
1155 |
1057 |
|
* @return <code>true</code> if the specified cell exists |
1156 |
1058 |
|
*/ |
1157 |
|
- |
public boolean isCellPresent( int row, int column ) |
1158 |
|
- |
{ |
1159 |
|
- |
if ( (row >= getRowCount()) || (row < 0) ) |
1160 |
|
- |
{ |
|
1059 |
+ |
public boolean isCellPresent( int row, int column ) { |
|
1060 |
+ |
if ( (row >= getRowCount()) || (row < 0) ) { |
1161 |
1061 |
|
return false; |
1162 |
1062 |
|
} |
1163 |
|
- |
if ( (column < 0) || (column >= getCellCount( row )) ) |
1164 |
|
- |
{ |
|
1063 |
+ |
if ( (column < 0) || (column >= getCellCount( row )) ) { |
1165 |
1064 |
|
return false; |
1166 |
|
- |
} |
1167 |
|
- |
else |
1168 |
|
- |
{ |
|
1065 |
+ |
} else { |
1169 |
1066 |
|
return true; |
1170 |
1067 |
|
} |
1171 |
1068 |
|
} |
|
@@ -1175,8 +1072,7 @@ |
1175 |
1072 |
|
* |
1176 |
1073 |
|
* @return the iterator |
1177 |
1074 |
|
*/ |
1178 |
|
- |
public Iterator<Widget> iterator() |
1179 |
|
- |
{ |
|
1075 |
+ |
public Iterator<Widget> iterator() { |
1180 |
1076 |
|
return widgetMap.widgetIterator(); |
1181 |
1077 |
|
} |
1182 |
1078 |
|
|
|
@@ -1185,33 +1081,26 @@ |
1185 |
1081 |
|
* |
1186 |
1082 |
|
* @param event the generated event |
1187 |
1083 |
|
*/ |
1188 |
|
- |
public void onBrowserEvent( Event event ) |
1189 |
|
- |
{ |
1190 |
|
- |
switch ( DOM.eventGetType( event ) ) |
1191 |
|
- |
{ |
1192 |
|
- |
case Event.ONCLICK: |
1193 |
|
- |
{ |
1194 |
|
- |
if ( tableListeners != null ) |
1195 |
|
- |
{ |
|
1084 |
+ |
public void onBrowserEvent( Event event ) { |
|
1085 |
+ |
switch ( DOM.eventGetType( event ) ) { |
|
1086 |
+ |
case Event.ONCLICK: { |
|
1087 |
+ |
if ( tableListeners != null ) { |
1196 |
1088 |
|
// Find out which cell was actually clicked. |
1197 |
1089 |
|
Element td = getEventTargetCell( event ); |
1198 |
|
- |
if ( td == null ) |
1199 |
|
- |
{ |
|
1090 |
+ |
if ( td == null ) { |
1200 |
1091 |
|
return; |
1201 |
1092 |
|
} |
1202 |
1093 |
|
Element tr = DOM.getParent( td ); |
1203 |
1094 |
|
int row = getRowIndex( tr ); |
1204 |
1095 |
|
int column = getCellIndex( tr, td ); |
1205 |
|
- |
if ( column >= 0 ) |
1206 |
|
- |
{ |
|
1096 |
+ |
if ( column >= 0 ) { |
1207 |
1097 |
|
// Fire the event. |
1208 |
1098 |
|
tableListeners.fireCellClicked( this, row, column ); |
1209 |
1099 |
|
} |
1210 |
1100 |
|
} |
1211 |
1101 |
|
break; |
1212 |
1102 |
|
} |
1213 |
|
- |
default: |
1214 |
|
- |
{ |
|
1103 |
+ |
default: { |
1215 |
1104 |
|
// Do nothing |
1216 |
1105 |
|
} |
1217 |
1106 |
|
} |
|
@@ -1224,11 +1113,9 @@ |
1224 |
1113 |
|
* |
1225 |
1114 |
|
* @return was the widget removed from the table. |
1226 |
1115 |
|
*/ |
1227 |
|
- |
public boolean remove( Widget widget ) |
1228 |
|
- |
{ |
|
1116 |
+ |
public boolean remove( Widget widget ) { |
1229 |
1117 |
|
// Validate. |
1230 |
|
- |
if ( widget.getParent() != this ) |
1231 |
|
- |
{ |
|
1118 |
+ |
if ( widget.getParent() != this ) { |
1232 |
1119 |
|
return false; |
1233 |
1120 |
|
} |
1234 |
1121 |
|
|
|
@@ -1249,10 +1136,8 @@ |
1249 |
1136 |
|
* |
1250 |
1137 |
|
* @param listener listener to remove |
1251 |
1138 |
|
*/ |
1252 |
|
- |
public void removeTableListener( TableListener listener ) |
1253 |
|
- |
{ |
1254 |
|
- |
if ( tableListeners != null ) |
1255 |
|
- |
{ |
|
1139 |
+ |
public void removeTableListener( TableListener listener ) { |
|
1140 |
+ |
if ( tableListeners != null ) { |
1256 |
1141 |
|
tableListeners.remove( listener ); |
1257 |
1142 |
|
} |
1258 |
1143 |
|
} |
|
@@ -1263,8 +1148,7 @@ |
1263 |
1148 |
|
* |
1264 |
1149 |
|
* @param width the width of the border, in pixels |
1265 |
1150 |
|
*/ |
1266 |
|
- |
public void setBorderWidth( int width ) |
1267 |
|
- |
{ |
|
1151 |
+ |
public void setBorderWidth( int width ) { |
1268 |
1152 |
|
DOM.setElementProperty( tableElem, "border", "" + width ); |
1269 |
1153 |
|
} |
1270 |
1154 |
|
|
|
@@ -1273,8 +1157,7 @@ |
1273 |
1157 |
|
* |
1274 |
1158 |
|
* @param padding the cell padding, in pixels |
1275 |
1159 |
|
*/ |
1276 |
|
- |
public void setCellPadding( int padding ) |
1277 |
|
- |
{ |
|
1160 |
+ |
public void setCellPadding( int padding ) { |
1278 |
1161 |
|
DOM.setElementPropertyInt( tableElem, "cellPadding", padding ); |
1279 |
1162 |
|
} |
1280 |
1163 |
|
|
|
@@ -1283,8 +1166,7 @@ |
1283 |
1166 |
|
* |
1284 |
1167 |
|
* @param spacing the cell spacing, in pixels |
1285 |
1168 |
|
*/ |
1286 |
|
- |
public void setCellSpacing( int spacing ) |
1287 |
|
- |
{ |
|
1169 |
+ |
public void setCellSpacing( int spacing ) { |
1288 |
1170 |
|
DOM.setElementPropertyInt( tableElem, "cellSpacing", spacing ); |
1289 |
1171 |
|
} |
1290 |
1172 |
|
|
|
@@ -1305,11 +1187,9 @@ |
1305 |
1187 |
|
* |
1306 |
1188 |
|
* @throws IndexOutOfBoundsException |
1307 |
1189 |
|
*/ |
1308 |
|
- |
public void setElement( int row, int column, Element element ) |
1309 |
|
- |
{ |
|
1190 |
+ |
public void setElement( int row, int column, Element element ) { |
1310 |
1191 |
|
prepareCell( row, column ); |
1311 |
|
- |
if ( element != null ) |
1312 |
|
- |
{ |
|
1192 |
+ |
if ( element != null ) { |
1313 |
1193 |
|
|
1314 |
1194 |
|
// Removes any existing widget. |
1315 |
1195 |
|
Element td = cleanCell( row, column, true ); |
|
@@ -1328,12 +1208,10 @@ |
1328 |
1208 |
|
* |
1329 |
1209 |
|
* @throws IndexOutOfBoundsException |
1330 |
1210 |
|
*/ |
1331 |
|
- |
public void setHTML( int row, int column, String html ) |
1332 |
|
- |
{ |
|
1211 |
+ |
public void setHTML( int row, int column, String html ) { |
1333 |
1212 |
|
prepareCell( row, column ); |
1334 |
1213 |
|
Element td = cleanCell( row, column, html == null ); |
1335 |
|
- |
if ( html != null ) |
1336 |
|
- |
{ |
|
1214 |
+ |
if ( html != null ) { |
1337 |
1215 |
|
DOM.setInnerHTML( td, html ); |
1338 |
1216 |
|
} |
1339 |
1217 |
|
} |
|
@@ -1347,12 +1225,10 @@ |
1347 |
1225 |
|
* |
1348 |
1226 |
|
* @throws IndexOutOfBoundsException |
1349 |
1227 |
|
*/ |
1350 |
|
- |
public void setText( int row, int column, String text ) |
1351 |
|
- |
{ |
|
1228 |
+ |
public void setText( int row, int column, String text ) { |
1352 |
1229 |
|
prepareCell( row, column ); |
1353 |
1230 |
|
Element td = cleanCell( row, column, text == null ); |
1354 |
|
- |
if ( text != null ) |
1355 |
|
- |
{ |
|
1231 |
+ |
if ( text != null ) { |
1356 |
1232 |
|
DOM.setInnerText( td, text ); |
1357 |
1233 |
|
} |
1358 |
1234 |
|
} |
|
@@ -1375,11 +1251,9 @@ |
1375 |
1251 |
|
* |
1376 |
1252 |
|
* @throws IndexOutOfBoundsException |
1377 |
1253 |
|
*/ |
1378 |
|
- |
public void setWidget( int row, int column, Widget widget ) |
1379 |
|
- |
{ |
|
1254 |
+ |
public void setWidget( int row, int column, Widget widget ) { |
1380 |
1255 |
|
prepareCell( row, column ); |
1381 |
|
- |
if ( widget != null ) |
1382 |
|
- |
{ |
|
1256 |
+ |
if ( widget != null ) { |
1383 |
1257 |
|
widget.removeFromParent(); |
1384 |
1258 |
|
|
1385 |
1259 |
|
// Removes any existing widget. |
|
@@ -1404,16 +1278,13 @@ |
1404 |
1278 |
|
* |
1405 |
1279 |
|
* @throws IndexOutOfBoundsException |
1406 |
1280 |
|
*/ |
1407 |
|
- |
protected void checkCellBounds( int row, int column ) |
1408 |
|
- |
{ |
|
1281 |
+ |
protected void checkCellBounds( int row, int column ) { |
1409 |
1282 |
|
checkRowBounds( row ); |
1410 |
|
- |
if ( column < 0 ) |
1411 |
|
- |
{ |
|
1283 |
+ |
if ( column < 0 ) { |
1412 |
1284 |
|
throw new IndexOutOfBoundsException( "Column " + column + " must be non-negative: " + column ); |
1413 |
1285 |
|
} |
1414 |
1286 |
|
int cellSize = getCellCount( row ); |
1415 |
|
- |
if ( cellSize <= column ) |
1416 |
|
- |
{ |
|
1287 |
+ |
if ( cellSize <= column ) { |
1417 |
1288 |
|
throw new IndexOutOfBoundsException( "Column index: " + column + ", Column size: " + getCellCount( row ) ); |
1418 |
1289 |
|
} |
1419 |
1290 |
|
} |
|
@@ -1425,11 +1296,9 @@ |
1425 |
1296 |
|
* |
1426 |
1297 |
|
* @throws IndexOutOfBoundsException |
1427 |
1298 |
|
*/ |
1428 |
|
- |
protected void checkRowBounds( int row ) |
1429 |
|
- |
{ |
|
1299 |
+ |
protected void checkRowBounds( int row ) { |
1430 |
1300 |
|
int rowSize = getRowCount(); |
1431 |
|
- |
if ( (row >= rowSize) || (row < 0) ) |
1432 |
|
- |
{ |
|
1301 |
+ |
if ( (row >= rowSize) || (row < 0) ) { |
1433 |
1302 |
|
throw new IndexOutOfBoundsException( "Row index: " + row + ", Row size: " + rowSize ); |
1434 |
1303 |
|
} |
1435 |
1304 |
|
} |
|
@@ -1444,8 +1313,7 @@ |
1444 |
1313 |
|
* |
1445 |
1314 |
|
* @return element that has been cleaned |
1446 |
1315 |
|
*/ |
1447 |
|
- |
protected Element cleanCell( int row, int column, boolean clearInnerHTML ) |
1448 |
|
- |
{ |
|
1316 |
+ |
protected Element cleanCell( int row, int column, boolean clearInnerHTML ) { |
1449 |
1317 |
|
// Clear whatever is in the cell. |
1450 |
1318 |
|
Element td = getCellFormatter().getRawElement( row, column ); |
1451 |
1319 |
|
internalClearCell( td, clearInnerHTML ); |
|
@@ -1458,8 +1326,7 @@ |
1458 |
1326 |
|
* |
1459 |
1327 |
|
* @return the newly created TD |
1460 |
1328 |
|
*/ |
1461 |
|
- |
protected Element createCell() |
1462 |
|
- |
{ |
|
1329 |
+ |
protected Element createCell() { |
1463 |
1330 |
|
return OverrideDOM.createTD(); |
1464 |
1331 |
|
} |
1465 |
1332 |
|
|
|
@@ -1469,8 +1336,7 @@ |
1469 |
1336 |
|
* |
1470 |
1337 |
|
* @return the newly created TD |
1471 |
1338 |
|
*/ |
1472 |
|
- |
protected Element createRow() |
1473 |
|
- |
{ |
|
1339 |
+ |
protected Element createRow() { |
1474 |
1340 |
|
return DOM.createTR(); |
1475 |
1341 |
|
} |
1476 |
1342 |
|
|
|
@@ -1479,8 +1345,7 @@ |
1479 |
1345 |
|
* |
1480 |
1346 |
|
* @return the TBODY element |
1481 |
1347 |
|
*/ |
1482 |
|
- |
protected Element getBodyElement() |
1483 |
|
- |
{ |
|
1348 |
+ |
protected Element getBodyElement() { |
1484 |
1349 |
|
return bodyElem; |
1485 |
1350 |
|
} |
1486 |
1351 |
|
|
|
@@ -1490,8 +1355,7 @@ |
1490 |
1355 |
|
* |
1491 |
1356 |
|
* @return the index of a cell in the row |
1492 |
1357 |
|
*/ |
1493 |
|
- |
protected int getCellIndex( Element rowElem, Element cellElem ) |
1494 |
|
- |
{ |
|
1358 |
+ |
protected int getCellIndex( Element rowElem, Element cellElem ) { |
1495 |
1359 |
|
return DOM.getChildIndex( rowElem, cellElem ); |
1496 |
1360 |
|
} |
1497 |
1361 |
|
|
|
@@ -1514,8 +1378,7 @@ |
1514 |
1378 |
|
* |
1515 |
1379 |
|
* @return number of columns in the row |
1516 |
1380 |
|
*/ |
1517 |
|
- |
protected int getDOMCellCount( int row ) |
1518 |
|
- |
{ |
|
1381 |
+ |
protected int getDOMCellCount( int row ) { |
1519 |
1382 |
|
return getDOMCellCount( bodyElem, row ); |
1520 |
1383 |
|
} |
1521 |
1384 |
|
|
|
@@ -1524,8 +1387,7 @@ |
1524 |
1387 |
|
* |
1525 |
1388 |
|
* @return Returns the number of rows in the table |
1526 |
1389 |
|
*/ |
1527 |
|
- |
protected int getDOMRowCount() |
1528 |
|
- |
{ |
|
1390 |
+ |
protected int getDOMRowCount() { |
1529 |
1391 |
|
return getDOMRowCount( bodyElem ); |
1530 |
1392 |
|
} |
1531 |
1393 |
|
|
|
@@ -1538,8 +1400,7 @@ |
1538 |
1400 |
|
* |
1539 |
1401 |
|
* @return the index of a row |
1540 |
1402 |
|
*/ |
1541 |
|
- |
protected int getRowIndex( Element rowElem ) |
1542 |
|
- |
{ |
|
1403 |
+ |
protected int getRowIndex( Element rowElem ) { |
1543 |
1404 |
|
return OverrideDOM.getRowIndex( rowElem ); |
1544 |
1405 |
|
} |
1545 |
1406 |
|
|
|
@@ -1548,8 +1409,7 @@ |
1548 |
1409 |
|
* |
1549 |
1410 |
|
* @return the widget map |
1550 |
1411 |
|
*/ |
1551 |
|
- |
protected WidgetMapper getWidgetMap() |
1552 |
|
- |
{ |
|
1412 |
+ |
protected WidgetMapper getWidgetMap() { |
1553 |
1413 |
|
return widgetMap; |
1554 |
1414 |
|
} |
1555 |
1415 |
|
|
|
@@ -1563,8 +1423,7 @@ |
1563 |
1423 |
|
* |
1564 |
1424 |
|
* @throws IndexOutOfBoundsException |
1565 |
1425 |
|
*/ |
1566 |
|
- |
protected Element insertCell( int row, int column ) |
1567 |
|
- |
{ |
|
1426 |
+ |
protected Element insertCell( int row, int column ) { |
1568 |
1427 |
|
Element tr = rowFormatter.getElement( row ); |
1569 |
1428 |
|
Element td = createCell(); |
1570 |
1429 |
|
Element beforeTd = cellFormatter.getRawElement( row, column ); |
|
@@ -1581,12 +1440,10 @@ |
1581 |
1440 |
|
* |
1582 |
1441 |
|
* @throws IndexOutOfBoundsException |
1583 |
1442 |
|
*/ |
1584 |
|
- |
protected void insertCells( int row, int column, int count ) |
1585 |
|
- |
{ |
|
1443 |
+ |
protected void insertCells( int row, int column, int count ) { |
1586 |
1444 |
|
Element tr = rowFormatter.getRawElement( row ); |
1587 |
1445 |
|
Element beforeTd = cellFormatter.getRawElement( row, column ); |
1588 |
|
- |
for ( int i = column; i < column + count; i++ ) |
1589 |
|
- |
{ |
|
1446 |
+ |
for ( int i = column; i < column + count; i++ ) { |
1590 |
1447 |
|
Element td = createCell(); |
1591 |
1448 |
|
tr.insertBefore( td, beforeTd ); |
1592 |
1449 |
|
} |
|
@@ -1601,11 +1458,9 @@ |
1601 |
1458 |
|
* |
1602 |
1459 |
|
* @throws IndexOutOfBoundsException |
1603 |
1460 |
|
*/ |
1604 |
|
- |
protected int insertRow( int beforeRow ) |
1605 |
|
- |
{ |
|
1461 |
+ |
protected int insertRow( int beforeRow ) { |
1606 |
1462 |
|
// Specifically allow the row count as an insert position. |
1607 |
|
- |
if ( beforeRow != getRowCount() ) |
1608 |
|
- |
{ |
|
1463 |
+ |
if ( beforeRow != getRowCount() ) { |
1609 |
1464 |
|
checkRowBounds( beforeRow ); |
1610 |
1465 |
|
} |
1611 |
1466 |
|
Element tr = createRow(); |
|
@@ -1624,25 +1479,19 @@ |
1624 |
1479 |
|
* |
1625 |
1480 |
|
* @return returns whether a widget was cleared |
1626 |
1481 |
|
*/ |
1627 |
|
- |
protected boolean internalClearCell( Element td, boolean clearInnerHTML ) |
1628 |
|
- |
{ |
|
1482 |
+ |
protected boolean internalClearCell( Element td, boolean clearInnerHTML ) { |
1629 |
1483 |
|
Element maybeChild = DOM.getFirstChild( td ); |
1630 |
1484 |
|
Widget widget = null; |
1631 |
|
- |
if ( maybeChild != null ) |
1632 |
|
- |
{ |
|
1485 |
+ |
if ( maybeChild != null ) { |
1633 |
1486 |
|
widget = widgetMap.getWidget( maybeChild ); |
1634 |
1487 |
|
} |
1635 |
|
- |
if ( widget != null ) |
1636 |
|
- |
{ |
|
1488 |
+ |
if ( widget != null ) { |
1637 |
1489 |
|
// If there is a widget, remove it. |
1638 |
1490 |
|
remove( widget ); |
1639 |
1491 |
|
return true; |
1640 |
|
- |
} |
1641 |
|
- |
else |
1642 |
|
- |
{ |
|
1492 |
+ |
} else { |
1643 |
1493 |
|
// Otherwise, simply clear whatever text and/or HTML may be there. |
1644 |
|
- |
if ( clearInnerHTML ) |
1645 |
|
- |
{ |
|
1494 |
+ |
if ( clearInnerHTML ) { |
1646 |
1495 |
|
DOM.setInnerHTML( td, clearText ); |
1647 |
1496 |
|
} |
1648 |
1497 |
|
return false; |
|
@@ -1670,8 +1519,7 @@ |
1670 |
1519 |
|
* |
1671 |
1520 |
|
* @throws IndexOutOfBoundsException |
1672 |
1521 |
|
*/ |
1673 |
|
- |
protected void prepareColumn( int column ) |
1674 |
|
- |
{ |
|
1522 |
+ |
protected void prepareColumn( int column ) { |
1675 |
1523 |
|
// By default, do nothing. |
1676 |
1524 |
|
} |
1677 |
1525 |
|
|
|
@@ -1692,8 +1540,7 @@ |
1692 |
1540 |
|
* |
1693 |
1541 |
|
* @throws IndexOutOfBoundsException |
1694 |
1542 |
|
*/ |
1695 |
|
- |
protected void removeCell( int row, int column ) |
1696 |
|
- |
{ |
|
1543 |
+ |
protected void removeCell( int row, int column ) { |
1697 |
1544 |
|
checkCellBounds( row, column ); |
1698 |
1545 |
|
Element td = cleanCell( row, column, false ); |
1699 |
1546 |
|
Element tr = rowFormatter.getRawElement( row ); |
|
@@ -1707,22 +1554,18 @@ |
1707 |
1554 |
|
* |
1708 |
1555 |
|
* @throws IndexOutOfBoundsException |
1709 |
1556 |
|
*/ |
1710 |
|
- |
protected void removeRow( int row ) |
1711 |
|
- |
{ |
|
1557 |
+ |
protected void removeRow( int row ) { |
1712 |
1558 |
|
checkRowBounds( row ); |
1713 |
1559 |
|
int columnCount = getCellCount( row ); |
1714 |
|
- |
for ( int column = 0; column < columnCount; ++column ) |
1715 |
|
- |
{ |
|
1560 |
+ |
for ( int column = 0; column < columnCount; ++column ) { |
1716 |
1561 |
|
cleanCell( row, column, false ); |
1717 |
1562 |
|
} |
1718 |
1563 |
|
DOM.removeChild( bodyElem, rowFormatter.getRawElement( row ) ); |
1719 |
1564 |
|
} |
1720 |
1565 |
|
|
1721 |
|
- |
protected void setBodyElement( Element element ) |
1722 |
|
- |
{ |
|
1566 |
+ |
protected void setBodyElement( Element element ) { |
1723 |
1567 |
|
// Must free any existing widgets from the current DOM first. |
1724 |
|
- |
if ( this.bodyElem != null ) |
1725 |
|
- |
{ |
|
1568 |
+ |
if ( this.bodyElem != null ) { |
1726 |
1569 |
|
clearOnlyWidgets(); |
1727 |
1570 |
|
} |
1728 |
1571 |
|
this.bodyElem = element; |
|
@@ -1733,8 +1576,7 @@ |
1733 |
1576 |
|
* |
1734 |
1577 |
|
* @param cellFormatter the table's cell formatter |
1735 |
1578 |
|
*/ |
1736 |
|
- |
protected void setCellFormatter( CellFormatter cellFormatter ) |
1737 |
|
- |
{ |
|
1579 |
+ |
protected void setCellFormatter( CellFormatter cellFormatter ) { |
1738 |
1580 |
|
this.cellFormatter = cellFormatter; |
1739 |
1581 |
|
} |
1740 |
1582 |
|
|
|
@@ -1744,13 +1586,11 @@ |
1744 |
1586 |
|
* |
1745 |
1587 |
|
* @param clearText the default clear text |
1746 |
1588 |
|
*/ |
1747 |
|
- |
protected void setClearText( String clearText ) |
1748 |
|
- |
{ |
|
1589 |
+ |
protected void setClearText( String clearText ) { |
1749 |
1590 |
|
this.clearText = clearText; |
1750 |
1591 |
|
} |
1751 |
1592 |
|
|
1752 |
|
- |
protected void setColumnFormatter( ColumnFormatter formatter ) |
1753 |
|
- |
{ |
|
1593 |
+ |
protected void setColumnFormatter( ColumnFormatter formatter ) { |
1754 |
1594 |
|
columnFormatter = formatter; |
1755 |
1595 |
|
columnFormatter.prepareColumnGroup(); |
1756 |
1596 |
|
} |
|
@@ -1760,8 +1600,7 @@ |
1760 |
1600 |
|
* |
1761 |
1601 |
|
* @param rowFormatter the table's row formatter |
1762 |
1602 |
|
*/ |
1763 |
|
- |
protected void setRowFormatter( RowFormatter rowFormatter ) |
1764 |
|
- |
{ |
|
1603 |
+ |
protected void setRowFormatter( RowFormatter rowFormatter ) { |
1765 |
1604 |
|
this.rowFormatter = rowFormatter; |
1766 |
1605 |
|
} |
1767 |
1606 |
|
|
|
@@ -1769,11 +1608,9 @@ |
1769 |
1608 |
|
* Clears the widgets from the table without actually modifying the underlying |
1770 |
1609 |
|
* HTMLTable. |
1771 |
1610 |
|
*/ |
1772 |
|
- |
private void clearOnlyWidgets() |
1773 |
|
- |
{ |
|
1611 |
+ |
private void clearOnlyWidgets() { |
1774 |
1612 |
|
Iterator widgets = iterator(); |
1775 |
|
- |
while ( widgets.hasNext() ) |
1776 |
|
- |
{ |
|
1613 |
+ |
while ( widgets.hasNext() ) { |
1777 |
1614 |
|
orphan( (Widget) widgets.next() ); |
1778 |
1615 |
|
} |
1779 |
1616 |
|
widgetMap = new WidgetMapper(); |
|
@@ -1787,16 +1624,12 @@ |
1787 |
1624 |
|
* |
1788 |
1625 |
|
* @return the widget |
1789 |
1626 |
|
*/ |
1790 |
|
- |
private Widget getWidgetImpl( int row, int column ) |
1791 |
|
- |
{ |
|
1627 |
+ |
private Widget getWidgetImpl( int row, int column ) { |
1792 |
1628 |
|
Element e = cellFormatter.getRawElement( row, column ); |
1793 |
1629 |
|
Element child = DOM.getFirstChild( e ); |
1794 |
|
- |
if ( child == null ) |
1795 |
|
- |
{ |
|
1630 |
+ |
if ( child == null ) { |
1796 |
1631 |
|
return null; |
1797 |
|
- |
} |
1798 |
|
- |
else |
1799 |
|
- |
{ |
|
1632 |
+ |
} else { |
1800 |
1633 |
|
return widgetMap.getWidget( child ); |
1801 |
1634 |
|
} |
1802 |
1635 |
|
} |
|
@@ -1811,10 +1644,8 @@ |
1811 |
1644 |
|
* @throws IndexOutOfBoundsException |
1812 |
1645 |
|
*/ |
1813 |
1646 |
|
@SuppressWarnings("unused") |
1814 |
|
- |
private void setWidgetRaw( int row, int column, Widget widget ) |
1815 |
|
- |
{ |
1816 |
|
- |
if ( widget != null ) |
1817 |
|
- |
{ |
|
1647 |
+ |
private void setWidgetRaw( int row, int column, Widget widget ) { |
|
1648 |
+ |
if ( widget != null ) { |
1818 |
1649 |
|
widget.removeFromParent(); |
1819 |
1650 |
|
|
1820 |
1651 |
|
// Logical attach. |