final TextBoxBase textBox = (TextBoxBase) widget;
textBox.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(final KeyUpEvent event) {
final PTInstruction changeHandlerInstruction = new PTInstruction();
changeHandlerInstruction.setObjectID(addHandler.getObjectID());
changeHandlerInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
changeHandlerInstruction.put(HANDLER.KEY, HANDLER.KEY_.STRING_VALUE_CHANGE_HANDLER);
changeHandlerInstruction.put(PROPERTY.VALUE, textBox.getText());
final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
eventInstruction.put(PROPERTY.VALUE, event.getNativeEvent().getKeyCode());
if (addHandler.containsKey(PROPERTY.KEY_FILTER)) {
final JSONArray jsonArray = addHandler.get(PROPERTY.KEY_FILTER).isArray();
for (int i = 0; i < jsonArray.size(); i++) {
final JSONNumber keyCode = jsonArray.get(i).isNumber();
if (keyCode.doubleValue() == event.getNativeEvent().getKeyCode()) {
uiService.stackInstrution(changeHandlerInstruction);
uiService.stackInstrution(eventInstruction);
uiService.flushEvents();
break;
}
}
} else {
uiService.stackInstrution(changeHandlerInstruction);
uiService.stackInstrution(eventInstruction);
uiService.flushEvents();
}
preventOrStopEvent(event);
}
});
} else {
widget.addDomHandler(new KeyUpHandler() {
@Override
public void onKeyUp(final KeyUpEvent event) {
final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
eventInstruction.put(PROPERTY.VALUE, event.getNativeEvent().getKeyCode());
if (addHandler.containsKey(PROPERTY.KEY_FILTER)) {
final JSONArray jsonArray = addHandler.get(PROPERTY.KEY_FILTER).isArray();
for (int i = 0; i < jsonArray.size(); i++) {
final JSONNumber keyCode = jsonArray.get(i).isNumber();
if (keyCode.doubleValue() == event.getNativeEvent().getKeyCode()) {
uiService.sendDataToServer(eventInstruction);
uiService.flushEvents();
break;
}
}
} else {
uiService.sendDataToServer(eventInstruction);
uiService.flushEvents();
}
preventOrStopEvent(event);
}
}, KeyUpEvent.getType());
}
break;
case DRAG_START:
widget.getElement().setDraggable(Element.DRAGGABLE_TRUE);
widget.addBitlessDomHandler(new DragStartHandler() {
@Override
public void onDragStart(final DragStartEvent event) {
event.setData("text", Long.toString(addHandler.getObjectID()));
event.getDataTransfer().setDragImage(uiObject.getElement(), 10, 10);
triggerDomEvent(addHandler, domHandlerType, uiService, event);
}
}, DragStartEvent.getType());
break;
case DRAG_END:
widget.addBitlessDomHandler(new DragEndHandler() {
@Override
public void onDragEnd(final DragEndEvent event) {
triggerDomEvent(addHandler, domHandlerType, uiService, event);
}
}, DragEndEvent.getType());
break;
case DRAG_ENTER:
widget.addBitlessDomHandler(new DragEnterHandler() {
@Override
public void onDragEnter(final DragEnterEvent event) {
triggerDomEvent(addHandler, domHandlerType, uiService, event);
}
}, DragEnterEvent.getType());
break;
case DRAG_LEAVE:
widget.addBitlessDomHandler(new DragLeaveHandler() {
@Override
public void onDragLeave(final DragLeaveEvent event) {
triggerDomEvent(addHandler, domHandlerType, uiService, event);
}
}, DragLeaveEvent.getType());
break;
case DROP:
widget.addBitlessDomHandler(new DragOverHandler() {
@Override
public void onDragOver(final DragOverEvent event) {
// required by GWT api
// triggerDomEvent(addHandler, domHandlerType, uiService);
}
}, DragOverEvent.getType());
widget.addBitlessDomHandler(new DropHandler() {
@Override
public void onDrop(final DropEvent event) {
event.preventDefault();
final String dragWidgetID = event.getData("text");
final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
if (dragWidgetID != null) eventInstruction.put(PROPERTY.DRAG_SRC, Long.parseLong(dragWidgetID));
uiService.sendDataToServer(eventInstruction);
}
}, DropEvent.getType());
break;
case CONTEXT_MENU: