|
@@ -17,94 +17,100 @@ |
17 |
17 |
|
|
18 |
18 |
|
/** |
19 |
19 |
|
* Cell editors provide a mechanism to edit cells. |
20 |
|
- |
* |
|
20 |
+ |
* |
21 |
21 |
|
* @param <ColType> the data type of the column |
22 |
22 |
|
*/ |
23 |
|
- |
public interface CellEditor<ColType> { |
24 |
|
- |
/** |
25 |
|
- |
* Callback for {@link CellEditor}. The callback will be used when the user |
26 |
|
- |
* finishes editing the cell. |
27 |
|
- |
* |
28 |
|
- |
* @param <ColType> the data type of the column |
29 |
|
- |
*/ |
30 |
|
- |
public static interface Callback<ColType> { |
|
23 |
+ |
public interface CellEditor<ColType> |
|
24 |
+ |
{ |
31 |
25 |
|
/** |
32 |
|
- |
* Use this callback to return a new row value to the table. |
33 |
|
- |
* |
34 |
|
- |
* @param cellEditInfo information about the source of the edit request |
35 |
|
- |
* @param cellValue the new value to associated with the cell |
36 |
|
- |
*/ |
37 |
|
- |
void onComplete(CellEditInfo cellEditInfo, ColType cellValue); |
38 |
|
- |
|
39 |
|
- |
/** |
40 |
|
- |
* Use this callback to cancel the edit request. |
41 |
|
- |
* |
42 |
|
- |
* @param cellEditInfo information about the source of the edit request |
43 |
|
- |
*/ |
44 |
|
- |
void onCancel(CellEditInfo cellEditInfo); |
45 |
|
- |
} |
46 |
|
- |
|
47 |
|
- |
/** |
48 |
|
- |
* The information about the cell to edit. |
49 |
|
- |
*/ |
50 |
|
- |
public static class CellEditInfo { |
51 |
|
- |
/** |
52 |
|
- |
* The cell index. |
53 |
|
- |
*/ |
54 |
|
- |
private int cellIndex; |
55 |
|
- |
|
56 |
|
- |
/** |
57 |
|
- |
* The row index. |
58 |
|
- |
*/ |
59 |
|
- |
private int rowIndex; |
60 |
|
- |
|
61 |
|
- |
/** |
62 |
|
- |
* The table that triggered the editor. |
63 |
|
- |
*/ |
64 |
|
- |
private HTMLTable table; |
65 |
|
- |
|
66 |
|
- |
/** |
67 |
|
- |
* Construct a new {@link CellEditInfo}. |
68 |
|
- |
* |
69 |
|
- |
* @param table the table that opened the editor |
70 |
|
- |
* @param rowIndex the row index |
71 |
|
- |
* @param cellIndex the cell index |
72 |
|
- |
*/ |
73 |
|
- |
public CellEditInfo(HTMLTable table, int rowIndex, int cellIndex) { |
74 |
|
- |
this.table = table; |
75 |
|
- |
this.rowIndex = rowIndex; |
76 |
|
- |
this.cellIndex = cellIndex; |
77 |
|
- |
} |
78 |
|
- |
|
79 |
|
- |
/** |
80 |
|
- |
* @return the cell index |
81 |
|
- |
*/ |
82 |
|
- |
public int getCellIndex() { |
83 |
|
- |
return cellIndex; |
|
26 |
+ |
* Callback for {@link CellEditor}. The callback will be used when the user |
|
27 |
+ |
* finishes editing the cell. |
|
28 |
+ |
* |
|
29 |
+ |
* @param <ColType> the data type of the column |
|
30 |
+ |
*/ |
|
31 |
+ |
public static interface Callback<ColType> |
|
32 |
+ |
{ |
|
33 |
+ |
/** |
|
34 |
+ |
* Use this callback to return a new row value to the table. |
|
35 |
+ |
* |
|
36 |
+ |
* @param cellEditInfo information about the source of the edit request |
|
37 |
+ |
* @param cellValue the new value to associated with the cell |
|
38 |
+ |
*/ |
|
39 |
+ |
void onComplete( CellEditInfo cellEditInfo, ColType cellValue ); |
|
40 |
+ |
|
|
41 |
+ |
/** |
|
42 |
+ |
* Use this callback to cancel the edit request. |
|
43 |
+ |
* |
|
44 |
+ |
* @param cellEditInfo information about the source of the edit request |
|
45 |
+ |
*/ |
|
46 |
+ |
void onCancel( CellEditInfo cellEditInfo ); |
84 |
47 |
|
} |
85 |
48 |
|
|
86 |
49 |
|
/** |
87 |
|
- |
* @return the row index |
|
50 |
+ |
* The information about the cell to edit. |
88 |
51 |
|
*/ |
89 |
|
- |
public int getRowIndex() { |
90 |
|
- |
return rowIndex; |
|
52 |
+ |
public static class CellEditInfo |
|
53 |
+ |
{ |
|
54 |
+ |
/** |
|
55 |
+ |
* The cell index. |
|
56 |
+ |
*/ |
|
57 |
+ |
private int cellIndex; |
|
58 |
+ |
|
|
59 |
+ |
/** |
|
60 |
+ |
* The row index. |
|
61 |
+ |
*/ |
|
62 |
+ |
private int rowIndex; |
|
63 |
+ |
|
|
64 |
+ |
/** |
|
65 |
+ |
* The table that triggered the editor. |
|
66 |
+ |
*/ |
|
67 |
+ |
private HTMLTable table; |
|
68 |
+ |
|
|
69 |
+ |
/** |
|
70 |
+ |
* Construct a new {@link CellEditInfo}. |
|
71 |
+ |
* |
|
72 |
+ |
* @param table the table that opened the editor |
|
73 |
+ |
* @param rowIndex the row index |
|
74 |
+ |
* @param cellIndex the cell index |
|
75 |
+ |
*/ |
|
76 |
+ |
public CellEditInfo( HTMLTable table, int rowIndex, int cellIndex ) |
|
77 |
+ |
{ |
|
78 |
+ |
this.table = table; |
|
79 |
+ |
this.rowIndex = rowIndex; |
|
80 |
+ |
this.cellIndex = cellIndex; |
|
81 |
+ |
} |
|
82 |
+ |
|
|
83 |
+ |
/** |
|
84 |
+ |
* @return the cell index |
|
85 |
+ |
*/ |
|
86 |
+ |
public int getCellIndex() |
|
87 |
+ |
{ |
|
88 |
+ |
return cellIndex; |
|
89 |
+ |
} |
|
90 |
+ |
|
|
91 |
+ |
/** |
|
92 |
+ |
* @return the row index |
|
93 |
+ |
*/ |
|
94 |
+ |
public int getRowIndex() |
|
95 |
+ |
{ |
|
96 |
+ |
return rowIndex; |
|
97 |
+ |
} |
|
98 |
+ |
|
|
99 |
+ |
/** |
|
100 |
+ |
* @return the table that opened the editor |
|
101 |
+ |
*/ |
|
102 |
+ |
public HTMLTable getTable() |
|
103 |
+ |
{ |
|
104 |
+ |
return table; |
|
105 |
+ |
} |
91 |
106 |
|
} |
92 |
107 |
|
|
93 |
108 |
|
/** |
94 |
|
- |
* @return the table that opened the editor |
|
109 |
+ |
* Handle a request to edit a cell. |
|
110 |
+ |
* |
|
111 |
+ |
* @param cellEditInfo information about the source of the edit request |
|
112 |
+ |
* @param cellValue the value in the cell to edit |
|
113 |
+ |
* @param callback callback used when editing is complete |
95 |
114 |
|
*/ |
96 |
|
- |
public HTMLTable getTable() { |
97 |
|
- |
return table; |
98 |
|
- |
} |
99 |
|
- |
} |
100 |
|
- |
|
101 |
|
- |
/** |
102 |
|
- |
* Handle a request to edit a cell. |
103 |
|
- |
* |
104 |
|
- |
* @param cellEditInfo information about the source of the edit request |
105 |
|
- |
* @param cellValue the value in the cell to edit |
106 |
|
- |
* @param callback callback used when editing is complete |
107 |
|
- |
*/ |
108 |
|
- |
void editCell(CellEditInfo cellEditInfo, ColType cellValue, |
109 |
|
- |
Callback<ColType> callback); |
|
115 |
+ |
void editCell( CellEditInfo cellEditInfo, ColType cellValue, Callback<ColType> callback ); |
110 |
116 |
|
} |