Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/datatables/TableHelper.java

Diff revisions: vs.
  @@ -1,39 +1,32 @@
1 1 // This Source Code is in the Public Domain per: http://unlicense.org
2 2 package org.litesoft.GWT.client.widgets.datatables;
3 3
4 - import java.util.*;
5 -
6 4 import com.google.gwt.event.dom.client.*;
7 5 import com.google.gwt.gen2.table.client.*;
8 6 import com.google.gwt.user.client.*;
9 7
10 - public interface TableHelper
11 - {
12 - public abstract static class GridHelper
13 - {
8 + import java.util.*;
9 +
10 + public interface TableHelper {
11 + public abstract static class GridHelper {
14 12 private final HTMLTable mGrid;
15 13
16 - public GridHelper( HTMLTable pGrid )
17 - {
14 + public GridHelper( HTMLTable pGrid ) {
18 15 mGrid = pGrid;
19 16 }
20 17
21 - public int getRowForEvent( Event pEvent )
22 - {
18 + public int getRowForEvent( Event pEvent ) {
23 19 Element targetCell = mGrid.getEventTargetCell( pEvent );
24 20 return (targetCell != null) ? getRowIndex( DOM.getParent( targetCell ) ) : -1;
25 21 }
26 22
27 - public Cell getCellForEvent( Event pEvent )
28 - {
23 + public Cell getCellForEvent( Event pEvent ) {
29 24 Element targetCell = mGrid.getEventTargetCell( pEvent );
30 - if ( targetCell != null )
31 - {
25 + if ( targetCell != null ) {
32 26 Element targetRow = DOM.getParent( targetCell );
33 27 int row = getRowIndex( targetRow );
34 28 int col = getCellIndex( targetRow, targetCell );
35 - if ( col != -1 )
36 - {
29 + if ( col != -1 ) {
37 30 return new Cell( row, col );
38 31 }
39 32 }
  @@ -45,35 +38,28 @@
45 38 protected abstract int getCellIndex( Element pRowElement, Element pCellElement );
46 39 }
47 40
48 - public static abstract class GridClickHandler<RowType> implements ClickHandler
49 - {
41 + public static abstract class GridClickHandler<RowType> implements ClickHandler {
50 42 private final List<ColumnDefinition<RowType, ?>> mColDefs;
51 43 private final GridHelper mGridHelper;
52 44 private final int mFirstRowOffset;
53 45
54 - public GridClickHandler( int pFirstRowOffset, GridHelper pGridHelper, List<ColumnDefinition<RowType, ?>> pColDefs )
55 - {
46 + public GridClickHandler( int pFirstRowOffset, GridHelper pGridHelper, List<ColumnDefinition<RowType, ?>> pColDefs ) {
56 47 mFirstRowOffset = pFirstRowOffset;
57 48 mGridHelper = pGridHelper;
58 49 mColDefs = pColDefs;
59 50 }
60 51
61 52 @SuppressWarnings("unchecked")
62 - public void onClick( ClickEvent pEvent )
63 - {
53 + public void onClick( ClickEvent pEvent ) {
64 54 Cell cell = mGridHelper.getCellForEvent( Event.as( pEvent.getNativeEvent() ) );
65 - if ( cell != null )
66 - {
55 + if ( cell != null ) {
67 56 ColumnDefinition<RowType, ?> colDef = mColDefs.get( cell.getCol() );
68 57 ClickHandlerProperty zProperty = colDef.getColumnProperty( ClickHandlerProperty.TYPE );
69 - if ( zProperty != null )
70 - {
58 + if ( zProperty != null ) {
71 59 CellClickHandler<?> clickHandler = zProperty.getValue();
72 - if ( clickHandler != null )
73 - {
60 + if ( clickHandler != null ) {
74 61 int rowIndex = cell.getRow() - mFirstRowOffset; // Mat, I updated this to remove the overhead on the Accordion table
75 - if ( rowIndex >= 0 )
76 - {
62 + if ( rowIndex >= 0 ) {
77 63 RowType rowValue = getRowValue( rowIndex );
78 64 ((CellClickHandler<RowType>) clickHandler).execute( colDef, rowIndex, rowValue );
79 65 }
  @@ -86,24 +72,20 @@
86 72 protected abstract RowType getRowValue( int pRow );
87 73 }
88 74
89 - public static class Cell
90 - {
75 + public static class Cell {
91 76 private final int mRow;
92 77 private final int mCol;
93 78
94 - public Cell( int pRow, int pCol )
95 - {
79 + public Cell( int pRow, int pCol ) {
96 80 mRow = pRow;
97 81 mCol = pCol;
98 82 }
99 83
100 - public int getRow()
101 - {
84 + public int getRow() {
102 85 return mRow;
103 86 }
104 87
105 - public int getCol()
106 - {
88 + public int getCol() {
107 89 return mCol;
108 90 }
109 91 }