use of com.google.gwt.event.logical.shared.HasValueChangeHandlers in project gwt-test-utils by gwt-test-utils.
the class UiBinderInvocationHandler method addHandlers.
@SuppressWarnings("unchecked")
private <H extends EventHandler> void addHandlers(Object owner) {
Map<Method, UiHandler> uiHandlerMethods = GwtReflectionUtils.getAnnotatedMethod(owner.getClass(), UiHandler.class);
for (Map.Entry<Method, UiHandler> entry : uiHandlerMethods.entrySet()) {
for (String uiFieldName : entry.getValue().value()) {
Widget uiField = GwtReflectionUtils.getPrivateFieldValue(owner, uiFieldName);
GwtEvent.Type<H> eventType = (GwtEvent.Type<H>) getEventType(entry.getKey());
H handler = (H) createHandler(uiField, entry.getKey(), owner);
if (eventType instanceof DomEvent.Type) {
uiField.addDomHandler(handler, (DomEvent.Type<H>) eventType);
} else {
if (uiField instanceof HasValueChangeHandlers && handler instanceof ValueChangeHandler) {
((HasValueChangeHandlers<Object>) uiField).addValueChangeHandler((ValueChangeHandler<Object>) handler);
} else {
uiField.addHandler(handler, eventType);
}
}
}
}
}
Aggregations