* @author Uri Boness
*/
public class DefaultTextCellEditor implements CellEditor<String> {
public void edit(Element cell, Record record, String value, DataType<String> type, final Callback<String> callback) {
final InputElement input = InputElement.as(DOM.createElement("input"));
input.setValue(value);
input.getStyle().setWidth(100, Style.Unit.PCT);
input.getStyle().setHeight(100, Style.Unit.PCT);
EventUtils.addHandler(input.<Element>cast(), Event.ONKEYPRESS | Event.ONBLUR, new Handler<Event>() {
public void handle(Event event) {
if (event.getTypeInt() == Event.ONKEYPRESS && event.getKeyCode() != KeyCodes.KEY_ENTER) {
return;
}
String value = input.getValue();
callback.handleNewValue(value);
}
});
cell.setInnerHTML("");
cell.appendChild(input);
input.focus();
}