|
@@ -37,13 +37,11 @@ |
37 |
37 |
|
* |
38 |
38 |
|
* @param <ColType> the data type of the column |
39 |
39 |
|
*/ |
40 |
|
- |
public abstract class InlineCellEditor<ColType> extends PopupPanel implements CellEditor<ColType> |
41 |
|
- |
{ |
|
40 |
+ |
public abstract class InlineCellEditor<ColType> extends PopupPanel implements CellEditor<ColType> { |
42 |
41 |
|
/** |
43 |
42 |
|
* An {@link ImageBundle} that provides images for {@link InlineCellEditor}. |
44 |
43 |
|
*/ |
45 |
|
- |
public static interface InlineCellEditorImages extends ImageBundle |
46 |
|
- |
{ |
|
44 |
+ |
public static interface InlineCellEditorImages extends ImageBundle { |
47 |
45 |
|
/** |
48 |
46 |
|
* An image used to fill the available width. |
49 |
47 |
|
* |
|
@@ -63,10 +61,8 @@ |
63 |
61 |
|
* <code>ClickDecoratorPanel</code> decorates any widget with the minimal |
64 |
62 |
|
* amount of machinery to receive clicks for delegation to the parent. |
65 |
63 |
|
*/ |
66 |
|
- |
private static final class ClickDecoratorPanel extends SimplePanel |
67 |
|
- |
{ |
68 |
|
- |
public ClickDecoratorPanel( Widget child, ClickHandler delegate ) |
69 |
|
- |
{ |
|
64 |
+ |
private static final class ClickDecoratorPanel extends SimplePanel { |
|
65 |
+ |
public ClickDecoratorPanel( Widget child, ClickHandler delegate ) { |
70 |
66 |
|
setWidget( child ); |
71 |
67 |
|
addDomHandler( delegate, ClickEvent.getType() ); |
72 |
68 |
|
} |
|
@@ -80,10 +76,8 @@ |
80 |
76 |
|
/** |
81 |
77 |
|
* The click listener used to accept. |
82 |
78 |
|
*/ |
83 |
|
- |
private ClickHandler cancelHandler = new ClickHandler() |
84 |
|
- |
{ |
85 |
|
- |
public void onClick( ClickEvent event ) |
86 |
|
- |
{ |
|
79 |
+ |
private ClickHandler cancelHandler = new ClickHandler() { |
|
80 |
+ |
public void onClick( ClickEvent event ) { |
87 |
81 |
|
cancel(); |
88 |
82 |
|
} |
89 |
83 |
|
}; |
|
@@ -91,10 +85,8 @@ |
91 |
85 |
|
/** |
92 |
86 |
|
* The click listener used to accept. |
93 |
87 |
|
*/ |
94 |
|
- |
private ClickHandler acceptHandler = new ClickHandler() |
95 |
|
- |
{ |
96 |
|
- |
public void onClick( ClickEvent event ) |
97 |
|
- |
{ |
|
88 |
+ |
private ClickHandler acceptHandler = new ClickHandler() { |
|
89 |
+ |
public void onClick( ClickEvent event ) { |
98 |
90 |
|
accept(); |
99 |
91 |
|
} |
100 |
92 |
|
}; |
|
@@ -119,8 +111,7 @@ |
119 |
111 |
|
* |
120 |
112 |
|
* @param content the {@link Widget} used to edit |
121 |
113 |
|
*/ |
122 |
|
- |
protected InlineCellEditor( Widget content ) |
123 |
|
- |
{ |
|
114 |
+ |
protected InlineCellEditor( Widget content ) { |
124 |
115 |
|
this( content, GWT.<InlineCellEditorImages>create( InlineCellEditorImages.class ) ); |
125 |
116 |
|
} |
126 |
117 |
|
|
|
@@ -130,8 +121,7 @@ |
130 |
121 |
|
* @param content the {@link Widget} used to edit |
131 |
122 |
|
* @param images the images to use for the accept/cancel buttons |
132 |
123 |
|
*/ |
133 |
|
- |
protected InlineCellEditor( Widget content, InlineCellEditorImages images ) |
134 |
|
- |
{ |
|
124 |
+ |
protected InlineCellEditor( Widget content, InlineCellEditorImages images ) { |
135 |
125 |
|
super( true, true ); |
136 |
126 |
|
setStylePrimaryName( DEFAULT_STYLENAME ); |
137 |
127 |
|
|
|
@@ -153,8 +143,7 @@ |
153 |
143 |
|
setCancelWidget( images.cellEditorCancel().createImage() ); |
154 |
144 |
|
} |
155 |
145 |
|
|
156 |
|
- |
public void editCell( CellEditInfo cellEditInfo, ColType cellValue, Callback<ColType> callback ) |
157 |
|
- |
{ |
|
146 |
+ |
public void editCell( CellEditInfo cellEditInfo, ColType cellValue, Callback<ColType> callback ) { |
158 |
147 |
|
// Save the current values |
159 |
148 |
|
curCallback = callback; |
160 |
149 |
|
curCellEditInfo = cellEditInfo; |
|
@@ -180,8 +169,7 @@ |
180 |
169 |
|
/** |
181 |
170 |
|
* @return the label text |
182 |
171 |
|
*/ |
183 |
|
- |
public String getLabel() |
184 |
|
- |
{ |
|
172 |
+ |
public String getLabel() { |
185 |
173 |
|
return layoutTable.getHTML( 0, 0 ); |
186 |
174 |
|
} |
187 |
175 |
|
|
|
@@ -190,19 +178,16 @@ |
190 |
178 |
|
* |
191 |
179 |
|
* @param label the new label |
192 |
180 |
|
*/ |
193 |
|
- |
public void setLabel( String label ) |
194 |
|
- |
{ |
|
181 |
+ |
public void setLabel( String label ) { |
195 |
182 |
|
layoutTable.setHTML( 0, 0, label ); |
196 |
183 |
|
} |
197 |
184 |
|
|
198 |
185 |
|
/** |
199 |
186 |
|
* Accept the contents of the cell editor as the new cell value. |
200 |
187 |
|
*/ |
201 |
|
- |
protected void accept() |
202 |
|
- |
{ |
|
188 |
+ |
protected void accept() { |
203 |
189 |
|
// Check if we are ready to accept |
204 |
|
- |
if ( !onAccept() ) |
205 |
|
- |
{ |
|
190 |
+ |
if ( !onAccept() ) { |
206 |
191 |
|
return; |
207 |
192 |
|
} |
208 |
193 |
|
|
|
@@ -221,11 +206,9 @@ |
221 |
206 |
|
/** |
222 |
207 |
|
* Cancel the cell edit. |
223 |
208 |
|
*/ |
224 |
|
- |
protected void cancel() |
225 |
|
- |
{ |
|
209 |
+ |
protected void cancel() { |
226 |
210 |
|
// Fire the event |
227 |
|
- |
if ( !onCancel() ) |
228 |
|
- |
{ |
|
211 |
+ |
if ( !onCancel() ) { |
229 |
212 |
|
return; |
230 |
213 |
|
} |
231 |
214 |
|
|
|
@@ -233,8 +216,7 @@ |
233 |
216 |
|
hide(); |
234 |
217 |
|
|
235 |
218 |
|
// Call the callback |
236 |
|
- |
if ( curCallback != null ) |
237 |
|
- |
{ |
|
219 |
+ |
if ( curCallback != null ) { |
238 |
220 |
|
curCallback.onCancel( curCellEditInfo ); |
239 |
221 |
|
curCellEditInfo = null; |
240 |
222 |
|
curCallback = null; |
|
@@ -244,8 +226,7 @@ |
244 |
226 |
|
/** |
245 |
227 |
|
* @return the Widget that is used to accept the current value. |
246 |
228 |
|
*/ |
247 |
|
- |
protected Widget getAcceptWidget() |
248 |
|
- |
{ |
|
229 |
+ |
protected Widget getAcceptWidget() { |
249 |
230 |
|
ClickDecoratorPanel clickPanel = (ClickDecoratorPanel) layoutTable.getWidget( 1, 1 ); |
250 |
231 |
|
return clickPanel.getWidget(); |
251 |
232 |
|
} |
|
@@ -253,8 +234,7 @@ |
253 |
234 |
|
/** |
254 |
235 |
|
* @return the Widget that is used to cancel editing. |
255 |
236 |
|
*/ |
256 |
|
- |
protected Widget getCancelWidget() |
257 |
|
- |
{ |
|
237 |
+ |
protected Widget getCancelWidget() { |
258 |
238 |
|
ClickDecoratorPanel clickPanel = (ClickDecoratorPanel) layoutTable.getWidget( 1, 2 ); |
259 |
239 |
|
return clickPanel.getWidget(); |
260 |
240 |
|
} |
|
@@ -262,8 +242,7 @@ |
262 |
242 |
|
/** |
263 |
243 |
|
* @return the content widget |
264 |
244 |
|
*/ |
265 |
|
- |
protected Widget getContentWidget() |
266 |
|
- |
{ |
|
245 |
+ |
protected Widget getContentWidget() { |
267 |
246 |
|
return layoutTable.getWidget( 1, 0 ); |
268 |
247 |
|
} |
269 |
248 |
|
|
|
@@ -274,8 +253,7 @@ |
274 |
253 |
|
* |
275 |
254 |
|
* @return the additional left offset in pixels |
276 |
255 |
|
*/ |
277 |
|
- |
protected int getOffsetLeft() |
278 |
|
- |
{ |
|
256 |
+ |
protected int getOffsetLeft() { |
279 |
257 |
|
return 0; |
280 |
258 |
|
} |
281 |
259 |
|
|
|
@@ -286,8 +264,7 @@ |
286 |
264 |
|
* |
287 |
265 |
|
* @return the additional top offset in pixels |
288 |
266 |
|
*/ |
289 |
|
- |
protected int getOffsetTop() |
290 |
|
- |
{ |
|
267 |
+ |
protected int getOffsetTop() { |
291 |
268 |
|
return 0; |
292 |
269 |
|
} |
293 |
270 |
|
|
|
@@ -303,8 +280,7 @@ |
303 |
280 |
|
* |
304 |
281 |
|
* @return true to allow the accept, false to prevent it |
305 |
282 |
|
*/ |
306 |
|
- |
protected boolean onAccept() |
307 |
|
- |
{ |
|
283 |
+ |
protected boolean onAccept() { |
308 |
284 |
|
return true; |
309 |
285 |
|
} |
310 |
286 |
|
|
|
@@ -313,8 +289,7 @@ |
313 |
289 |
|
* |
314 |
290 |
|
* @return true to allow the cancel, false to prevent it |
315 |
291 |
|
*/ |
316 |
|
- |
protected boolean onCancel() |
317 |
|
- |
{ |
|
292 |
+ |
protected boolean onCancel() { |
318 |
293 |
|
return true; |
319 |
294 |
|
} |
320 |
295 |
|
|
|
@@ -323,8 +298,7 @@ |
323 |
298 |
|
* |
324 |
299 |
|
* @param w the widget |
325 |
300 |
|
*/ |
326 |
|
- |
protected void setAcceptWidget( Widget w ) |
327 |
|
- |
{ |
|
301 |
+ |
protected void setAcceptWidget( Widget w ) { |
328 |
302 |
|
ClickDecoratorPanel clickPanel = new ClickDecoratorPanel( w, acceptHandler ); |
329 |
303 |
|
clickPanel.setStyleName( "accept" ); |
330 |
304 |
|
layoutTable.setWidget( 1, 1, clickPanel ); |
|
@@ -335,8 +309,7 @@ |
335 |
309 |
|
* |
336 |
310 |
|
* @param w the widget |
337 |
311 |
|
*/ |
338 |
|
- |
protected void setCancelWidget( Widget w ) |
339 |
|
- |
{ |
|
312 |
+ |
protected void setCancelWidget( Widget w ) { |
340 |
313 |
|
ClickDecoratorPanel clickPanel = new ClickDecoratorPanel( w, cancelHandler ); |
341 |
314 |
|
clickPanel.setStyleName( "cancel" ); |
342 |
315 |
|
layoutTable.setWidget( 1, 2, clickPanel ); |