|
@@ -14,36 +14,36 @@ |
14 |
14 |
|
{ |
15 |
15 |
|
private final HTMLTable mGrid; |
16 |
16 |
|
|
17 |
|
- |
public GridHelper(HTMLTable pGrid) |
|
17 |
+ |
public GridHelper( HTMLTable pGrid ) |
18 |
18 |
|
{ |
19 |
19 |
|
mGrid = pGrid; |
20 |
20 |
|
} |
21 |
21 |
|
|
22 |
|
- |
public int getRowForEvent(Event pEvent) |
|
22 |
+ |
public int getRowForEvent( Event pEvent ) |
23 |
23 |
|
{ |
24 |
|
- |
Element targetCell = mGrid.getEventTargetCell(pEvent); |
25 |
|
- |
return (targetCell != null) ? getRowIndex(DOM.getParent(targetCell)) : -1; |
|
24 |
+ |
Element targetCell = mGrid.getEventTargetCell( pEvent ); |
|
25 |
+ |
return (targetCell != null) ? getRowIndex( DOM.getParent( targetCell ) ) : -1; |
26 |
26 |
|
} |
27 |
27 |
|
|
28 |
|
- |
public Cell getCellForEvent(Event pEvent) |
|
28 |
+ |
public Cell getCellForEvent( Event pEvent ) |
29 |
29 |
|
{ |
30 |
|
- |
Element targetCell = mGrid.getEventTargetCell(pEvent); |
31 |
|
- |
if (targetCell != null) |
|
30 |
+ |
Element targetCell = mGrid.getEventTargetCell( pEvent ); |
|
31 |
+ |
if ( targetCell != null ) |
32 |
32 |
|
{ |
33 |
|
- |
Element targetRow = DOM.getParent(targetCell); |
34 |
|
- |
int row = getRowIndex(targetRow); |
35 |
|
- |
int col = getCellIndex(targetRow, targetCell); |
36 |
|
- |
if (col != -1) |
|
33 |
+ |
Element targetRow = DOM.getParent( targetCell ); |
|
34 |
+ |
int row = getRowIndex( targetRow ); |
|
35 |
+ |
int col = getCellIndex( targetRow, targetCell ); |
|
36 |
+ |
if ( col != -1 ) |
37 |
37 |
|
{ |
38 |
|
- |
return new Cell(row, col); |
|
38 |
+ |
return new Cell( row, col ); |
39 |
39 |
|
} |
40 |
40 |
|
} |
41 |
41 |
|
return null; |
42 |
42 |
|
} |
43 |
43 |
|
|
44 |
|
- |
protected abstract int getRowIndex(Element pRowElement); |
|
44 |
+ |
protected abstract int getRowIndex( Element pRowElement ); |
45 |
45 |
|
|
46 |
|
- |
protected abstract int getCellIndex(Element pRowElement, Element pCellElement); |
|
46 |
+ |
protected abstract int getCellIndex( Element pRowElement, Element pCellElement ); |
47 |
47 |
|
} |
48 |
48 |
|
|
49 |
49 |
|
public static abstract class GridClickHandler<RowType> implements ClickHandler |
|
@@ -52,7 +52,7 @@ |
52 |
52 |
|
private final GridHelper mGridHelper; |
53 |
53 |
|
private final int mFirstRowOffset; |
54 |
54 |
|
|
55 |
|
- |
public GridClickHandler(int pFirstRowOffset, GridHelper pGridHelper, List<ColumnDefinition<RowType, ?>> pColDefs) |
|
55 |
+ |
public GridClickHandler( int pFirstRowOffset, GridHelper pGridHelper, List<ColumnDefinition<RowType, ?>> pColDefs ) |
56 |
56 |
|
{ |
57 |
57 |
|
mFirstRowOffset = pFirstRowOffset; |
58 |
58 |
|
mGridHelper = pGridHelper; |
|
@@ -60,23 +60,23 @@ |
60 |
60 |
|
} |
61 |
61 |
|
|
62 |
62 |
|
@SuppressWarnings("unchecked") |
63 |
|
- |
public void onClick(ClickEvent pEvent) |
|
63 |
+ |
public void onClick( ClickEvent pEvent ) |
64 |
64 |
|
{ |
65 |
|
- |
Cell cell = mGridHelper.getCellForEvent(Event.as(pEvent.getNativeEvent())); |
66 |
|
- |
if (cell != null) |
|
65 |
+ |
Cell cell = mGridHelper.getCellForEvent( Event.as( pEvent.getNativeEvent() ) ); |
|
66 |
+ |
if ( cell != null ) |
67 |
67 |
|
{ |
68 |
|
- |
ColumnDefinition<RowType, ?> colDef = mColDefs.get(cell.getCol()); |
69 |
|
- |
ClickHandlerProperty zProperty = colDef.getColumnProperty(ClickHandlerProperty.TYPE); |
70 |
|
- |
if (zProperty != null) |
|
68 |
+ |
ColumnDefinition<RowType, ?> colDef = mColDefs.get( cell.getCol() ); |
|
69 |
+ |
ClickHandlerProperty zProperty = colDef.getColumnProperty( ClickHandlerProperty.TYPE ); |
|
70 |
+ |
if ( zProperty != null ) |
71 |
71 |
|
{ |
72 |
72 |
|
CellClickHandler<?> clickHandler = zProperty.getValue(); |
73 |
|
- |
if (clickHandler != null) |
|
73 |
+ |
if ( clickHandler != null ) |
74 |
74 |
|
{ |
75 |
75 |
|
int rowIndex = cell.getRow() - mFirstRowOffset; // Mat, I updated this to remove the overhead on the Accordion table |
76 |
|
- |
if (rowIndex >= 0) |
|
76 |
+ |
if ( rowIndex >= 0 ) |
77 |
77 |
|
{ |
78 |
|
- |
RowType rowValue = getRowValue(rowIndex); |
79 |
|
- |
((CellClickHandler<RowType>) clickHandler).execute(colDef, rowIndex, rowValue); |
|
78 |
+ |
RowType rowValue = getRowValue( rowIndex ); |
|
79 |
+ |
((CellClickHandler<RowType>) clickHandler).execute( colDef, rowIndex, rowValue ); |
80 |
80 |
|
} |
81 |
81 |
|
} |
82 |
82 |
|
} |
|
@@ -84,7 +84,7 @@ |
84 |
84 |
|
} |
85 |
85 |
|
} |
86 |
86 |
|
|
87 |
|
- |
protected abstract RowType getRowValue(int pRow); |
|
87 |
+ |
protected abstract RowType getRowValue( int pRow ); |
88 |
88 |
|
} |
89 |
89 |
|
|
90 |
90 |
|
public static class Cell |