|
@@ -6,70 +6,57 @@ |
6 |
6 |
|
import com.google.gwt.user.client.*; |
7 |
7 |
|
import com.google.gwt.user.client.ui.*; |
8 |
8 |
|
|
9 |
|
- |
public class TwoDimensionalChildHelper |
10 |
|
- |
{ |
|
9 |
+ |
public class TwoDimensionalChildHelper { |
11 |
10 |
|
private Element mTBody; |
12 |
11 |
|
private int mColsPerRow; |
13 |
12 |
|
private Cell[] mEmptyRow; |
14 |
13 |
|
private Row[] mRows = NO_ROWS; |
15 |
14 |
|
|
16 |
|
- |
public TwoDimensionalChildHelper( Element pTBody, int pColsPerRow ) |
17 |
|
- |
{ |
|
15 |
+ |
public TwoDimensionalChildHelper( Element pTBody, int pColsPerRow ) { |
18 |
16 |
|
Objects.assertNotNull( "TBODY", mTBody = pTBody ); |
19 |
|
- |
if ( (mColsPerRow = pColsPerRow) < 1 ) |
20 |
|
- |
{ |
|
17 |
+ |
if ( (mColsPerRow = pColsPerRow) < 1 ) { |
21 |
18 |
|
throw new IllegalArgumentException( "Must have at least 1 column, but was given: " + pColsPerRow ); |
22 |
19 |
|
} |
23 |
20 |
|
} |
24 |
21 |
|
|
25 |
|
- |
public void add( Widget pWidget ) |
26 |
|
- |
{ |
27 |
|
- |
if ( pWidget != null ) |
28 |
|
- |
{ |
|
22 |
+ |
public void add( Widget pWidget ) { |
|
23 |
+ |
if ( pWidget != null ) { |
29 |
24 |
|
Cell zCell = findEmptyCell(); |
30 |
25 |
|
} |
31 |
26 |
|
} |
32 |
27 |
|
|
33 |
|
- |
private Cell findEmptyCell() |
34 |
|
- |
{ |
|
28 |
+ |
private Cell findEmptyCell() { |
35 |
29 |
|
return null; // todo... |
36 |
30 |
|
} |
37 |
31 |
|
|
38 |
|
- |
private Cell getCell( int pRow, int pCol ) |
39 |
|
- |
{ |
|
32 |
+ |
private Cell getCell( int pRow, int pCol ) { |
40 |
33 |
|
return null; // todo... |
41 |
34 |
|
} |
42 |
35 |
|
|
43 |
|
- |
private class Row |
44 |
|
- |
{ |
|
36 |
+ |
private class Row { |
45 |
37 |
|
private int mIndex; |
46 |
38 |
|
private Element mTR; |
47 |
39 |
|
private Cell[] mCells; |
48 |
40 |
|
|
49 |
|
- |
public Row( int pIndex ) |
50 |
|
- |
{ |
|
41 |
+ |
public Row( int pIndex ) { |
51 |
42 |
|
mIndex = pIndex; |
52 |
43 |
|
DOM.appendChild( mTBody, mTR = DOM.createTR() ); |
53 |
44 |
|
mCells = new Cell[mColsPerRow]; |
54 |
|
- |
for ( int i = 0; i < mCells.length; i++ ) |
55 |
|
- |
{ |
|
45 |
+ |
for ( int i = 0; i < mCells.length; i++ ) { |
56 |
46 |
|
mCells[i] = new Cell( this, i ); |
57 |
47 |
|
} |
58 |
48 |
|
} |
59 |
49 |
|
|
60 |
|
- |
public int getIndex() |
61 |
|
- |
{ |
|
50 |
+ |
public int getIndex() { |
62 |
51 |
|
return mIndex; |
63 |
52 |
|
} |
64 |
53 |
|
|
65 |
|
- |
public Element getTR() |
66 |
|
- |
{ |
|
54 |
+ |
public Element getTR() { |
67 |
55 |
|
return mTR; |
68 |
56 |
|
} |
69 |
57 |
|
} |
70 |
58 |
|
|
71 |
|
- |
private class Cell |
72 |
|
- |
{ |
|
59 |
+ |
private class Cell { |
73 |
60 |
|
private Row mRow; |
74 |
61 |
|
private int mIndex; |
75 |
62 |
|
private int mAdditionalRightCells = 0; |
|
@@ -78,32 +65,26 @@ |
78 |
65 |
|
private Element mTD = null; |
79 |
66 |
|
private Widget mContent = null; |
80 |
67 |
|
|
81 |
|
- |
public Cell( Row pRow, int pIndex ) |
82 |
|
- |
{ |
|
68 |
+ |
public Cell( Row pRow, int pIndex ) { |
83 |
69 |
|
mRow = pRow; |
84 |
70 |
|
mIndex = pIndex; |
85 |
71 |
|
int zRowIndex = mRow.getIndex(); |
86 |
|
- |
if ( zRowIndex != 0 ) |
87 |
|
- |
{ |
|
72 |
+ |
if ( zRowIndex != 0 ) { |
88 |
73 |
|
Cell zPotentialSpanFromCell = getCell( zRowIndex - 1, mIndex ); |
89 |
|
- |
while ( zPotentialSpanFromCell.mSpannedFrom != null ) |
90 |
|
- |
{ |
|
74 |
+ |
while ( zPotentialSpanFromCell.mSpannedFrom != null ) { |
91 |
75 |
|
zPotentialSpanFromCell = zPotentialSpanFromCell.mSpannedFrom; |
92 |
76 |
|
} |
93 |
|
- |
if ( zPotentialSpanFromCell.coverageIncludes( zRowIndex, pIndex ) ) |
94 |
|
- |
{ |
|
77 |
+ |
if ( zPotentialSpanFromCell.coverageIncludes( zRowIndex, pIndex ) ) { |
95 |
78 |
|
mSpannedFrom = zPotentialSpanFromCell; |
96 |
79 |
|
} |
97 |
80 |
|
} |
98 |
81 |
|
} |
99 |
82 |
|
|
100 |
|
- |
public Row getRow() |
101 |
|
- |
{ |
|
83 |
+ |
public Row getRow() { |
102 |
84 |
|
return mRow; |
103 |
85 |
|
} |
104 |
86 |
|
|
105 |
|
- |
private boolean coverageIncludes( int pRow, int pCol ) |
106 |
|
- |
{ |
|
87 |
+ |
private boolean coverageIncludes( int pRow, int pCol ) { |
107 |
88 |
|
int zRowIndex = mRow.getIndex(); |
108 |
89 |
|
return (zRowIndex <= pRow) && (pRow <= (zRowIndex + mAdditionalDownCells)) && (mIndex <= pCol) && (pCol <= (mIndex + mAdditionalRightCells)); |
109 |
90 |
|
} |