|
@@ -15,71 +15,78 @@ |
15 |
15 |
|
*/ |
16 |
16 |
|
package com.google.gwt.gen2.table.client; |
17 |
17 |
|
|
18 |
|
- |
import com.google.gwt.user.client.ui.TextBox; |
19 |
|
- |
import com.google.gwt.user.client.ui.TextBoxBase; |
|
18 |
+ |
import com.google.gwt.user.client.ui.*; |
20 |
19 |
|
|
21 |
20 |
|
/** |
22 |
21 |
|
* An {@link InlineCellEditor} that can be used to edit {@link String Strings}. |
23 |
22 |
|
*/ |
24 |
|
- |
public class TextCellEditor extends InlineCellEditor<String> { |
25 |
|
- |
/** |
26 |
|
- |
* The text field used in this editor. |
27 |
|
- |
*/ |
28 |
|
- |
private TextBoxBase textBox; |
29 |
|
- |
|
30 |
|
- |
/** |
31 |
|
- |
* Construct a new {@link TextCellEditor} using a normal {@link TextBox}. |
32 |
|
- |
*/ |
33 |
|
- |
public TextCellEditor() { |
34 |
|
- |
this(new TextBox()); |
35 |
|
- |
} |
36 |
|
- |
|
37 |
|
- |
/** |
38 |
|
- |
* Construct a new {@link TextCellEditor} using the specified {@link TextBox}. |
39 |
|
- |
* |
40 |
|
- |
* @param textBox the text box to use |
41 |
|
- |
*/ |
42 |
|
- |
public TextCellEditor(TextBoxBase textBox) { |
43 |
|
- |
super(textBox); |
44 |
|
- |
this.textBox = textBox; |
45 |
|
- |
} |
46 |
|
- |
|
47 |
|
- |
/** |
48 |
|
- |
* Construct a new {@link TextCellEditor} using the specified {@link TextBox} |
49 |
|
- |
* and images. |
50 |
|
- |
* |
51 |
|
- |
* @param textBox the text box to use |
52 |
|
- |
* @param images the images to use for the accept/cancel buttons |
53 |
|
- |
*/ |
54 |
|
- |
public TextCellEditor(TextBoxBase textBox, InlineCellEditorImages images) { |
55 |
|
- |
super(textBox, images); |
56 |
|
- |
this.textBox = textBox; |
57 |
|
- |
} |
58 |
|
- |
|
59 |
|
- |
@Override |
60 |
|
- |
public void editCell(CellEditInfo cellEditInfo, String cellValue, |
61 |
|
- |
Callback<String> callback) { |
62 |
|
- |
super.editCell(cellEditInfo, cellValue, callback); |
63 |
|
- |
textBox.setFocus(true); |
64 |
|
- |
} |
65 |
|
- |
|
66 |
|
- |
/** |
67 |
|
- |
* @return the text box used in the editor |
68 |
|
- |
*/ |
69 |
|
- |
protected TextBoxBase getTextBox() { |
70 |
|
- |
return textBox; |
71 |
|
- |
} |
72 |
|
- |
|
73 |
|
- |
@Override |
74 |
|
- |
protected String getValue() { |
75 |
|
- |
return textBox.getText(); |
76 |
|
- |
} |
77 |
|
- |
|
78 |
|
- |
@Override |
79 |
|
- |
protected void setValue(String cellValue) { |
80 |
|
- |
if (cellValue == null) { |
81 |
|
- |
cellValue = ""; |
|
23 |
+ |
public class TextCellEditor extends InlineCellEditor<String> |
|
24 |
+ |
{ |
|
25 |
+ |
/** |
|
26 |
+ |
* The text field used in this editor. |
|
27 |
+ |
*/ |
|
28 |
+ |
private TextBoxBase textBox; |
|
29 |
+ |
|
|
30 |
+ |
/** |
|
31 |
+ |
* Construct a new {@link TextCellEditor} using a normal {@link TextBox}. |
|
32 |
+ |
*/ |
|
33 |
+ |
public TextCellEditor() |
|
34 |
+ |
{ |
|
35 |
+ |
this( new TextBox() ); |
|
36 |
+ |
} |
|
37 |
+ |
|
|
38 |
+ |
/** |
|
39 |
+ |
* Construct a new {@link TextCellEditor} using the specified {@link TextBox}. |
|
40 |
+ |
* |
|
41 |
+ |
* @param textBox the text box to use |
|
42 |
+ |
*/ |
|
43 |
+ |
public TextCellEditor( TextBoxBase textBox ) |
|
44 |
+ |
{ |
|
45 |
+ |
super( textBox ); |
|
46 |
+ |
this.textBox = textBox; |
|
47 |
+ |
} |
|
48 |
+ |
|
|
49 |
+ |
/** |
|
50 |
+ |
* Construct a new {@link TextCellEditor} using the specified {@link TextBox} |
|
51 |
+ |
* and images. |
|
52 |
+ |
* |
|
53 |
+ |
* @param textBox the text box to use |
|
54 |
+ |
* @param images the images to use for the accept/cancel buttons |
|
55 |
+ |
*/ |
|
56 |
+ |
public TextCellEditor( TextBoxBase textBox, InlineCellEditorImages images ) |
|
57 |
+ |
{ |
|
58 |
+ |
super( textBox, images ); |
|
59 |
+ |
this.textBox = textBox; |
|
60 |
+ |
} |
|
61 |
+ |
|
|
62 |
+ |
@Override |
|
63 |
+ |
public void editCell( CellEditInfo cellEditInfo, String cellValue, Callback<String> callback ) |
|
64 |
+ |
{ |
|
65 |
+ |
super.editCell( cellEditInfo, cellValue, callback ); |
|
66 |
+ |
textBox.setFocus( true ); |
|
67 |
+ |
} |
|
68 |
+ |
|
|
69 |
+ |
/** |
|
70 |
+ |
* @return the text box used in the editor |
|
71 |
+ |
*/ |
|
72 |
+ |
protected TextBoxBase getTextBox() |
|
73 |
+ |
{ |
|
74 |
+ |
return textBox; |
|
75 |
+ |
} |
|
76 |
+ |
|
|
77 |
+ |
@Override |
|
78 |
+ |
protected String getValue() |
|
79 |
+ |
{ |
|
80 |
+ |
return textBox.getText(); |
|
81 |
+ |
} |
|
82 |
+ |
|
|
83 |
+ |
@Override |
|
84 |
+ |
protected void setValue( String cellValue ) |
|
85 |
+ |
{ |
|
86 |
+ |
if ( cellValue == null ) |
|
87 |
+ |
{ |
|
88 |
+ |
cellValue = ""; |
|
89 |
+ |
} |
|
90 |
+ |
textBox.setText( cellValue ); |
82 |
91 |
|
} |
83 |
|
- |
textBox.setText(cellValue); |
84 |
|
- |
} |
85 |
92 |
|
} |