|
30 | 30 | import com.google.gwt.event.dom.client.KeyPressHandler; |
31 | 31 | import com.google.gwt.event.dom.client.KeyUpEvent; |
32 | 32 | import com.google.gwt.event.dom.client.KeyUpHandler; |
| 33 | +import com.google.gwt.event.logical.shared.ValueChangeHandler; |
33 | 34 | import com.google.gwt.event.shared.HandlerRegistration; |
34 | 35 | import com.google.gwt.uibinder.client.UiBinder; |
35 | 36 | import com.google.gwt.uibinder.client.UiField; |
36 | 37 | import com.google.gwt.user.client.ui.Composite; |
37 | 38 | import com.google.gwt.user.client.ui.HasText; |
| 39 | +import com.google.gwt.user.client.ui.HasValue; |
38 | 40 | import com.google.gwt.user.client.ui.Label; |
39 | 41 | import com.google.gwt.user.client.ui.TextBox; |
40 | 42 | import com.google.gwt.user.client.ui.Widget; |
41 | 43 |
|
42 | | -public class MaterialTextBox extends Composite implements HasText,HasKeyUpHandlers{ |
| 44 | +public class MaterialTextBox extends Composite implements HasText, HasKeyUpHandlers, HasValue<String> { |
43 | 45 |
|
44 | 46 | private static MaterialTextBoxUiBinder uiBinder = GWT.create(MaterialTextBoxUiBinder.class); |
45 | 47 |
|
@@ -104,10 +106,12 @@ public void backToDefault() { |
104 | 106 | txtBox.getElement().removeClassName("invalid"); |
105 | 107 | } |
106 | 108 |
|
| 109 | + @Override |
107 | 110 | public String getText() { |
108 | 111 | return txtBox.getText(); |
109 | 112 | } |
110 | 113 |
|
| 114 | + @Override |
111 | 115 | public void setText(String text) { |
112 | 116 | txtBox.setText(text); |
113 | 117 | customLabel.addStyleName("active"); |
@@ -173,24 +177,37 @@ public void setEnabled(boolean enabled) { |
173 | 177 |
|
174 | 178 | } |
175 | 179 |
|
176 | | - |
177 | | - |
178 | 180 | @Override |
179 | 181 | public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) { |
180 | 182 | return addDomHandler(handler, KeyUpEvent.getType()); |
181 | 183 | } |
182 | 184 |
|
183 | | - |
184 | | - |
185 | 185 | public String getLength() { |
186 | 186 | return length; |
187 | 187 | } |
188 | 188 |
|
189 | | - |
190 | | - |
191 | 189 | public void setLength(String length) { |
192 | 190 | this.length = length; |
193 | 191 | txtBox.getElement().setAttribute("length", length); |
194 | 192 | } |
195 | | - |
| 193 | + |
| 194 | + @Override |
| 195 | + public HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) { |
| 196 | + return txtBox.addValueChangeHandler(handler); |
| 197 | + } |
| 198 | + |
| 199 | + @Override |
| 200 | + public String getValue() { |
| 201 | + return txtBox.getValue(); |
| 202 | + } |
| 203 | + |
| 204 | + @Override |
| 205 | + public void setValue(String value) { |
| 206 | + txtBox.setValue(value); |
| 207 | + } |
| 208 | + |
| 209 | + @Override |
| 210 | + public void setValue(String value, boolean fireEvents) { |
| 211 | + txtBox.setValue(value, fireEvents); |
| 212 | + } |
196 | 213 | } |
0 commit comments