use of com.google.gwt.event.shared.EventHandler in project rstudio by rstudio.
the class EventBus method addHandler.
/**
* Similar to 2-arg form of addHandler, but automatically removes handler
* when the HasAttachHandlers object detaches.
*
* If the HasAttachHandlers object detaches and reattaches, the handler
* will NOT automatically resubscribe.
*/
public <H extends EventHandler> void addHandler(HasAttachHandlers removeWhenDetached, Type<H> type, H handler) {
final HandlerRegistration reg = addHandler(type, handler);
removeWhenDetached.addAttachHandler(new Handler() {
@Override
public void onAttachOrDetach(AttachEvent event) {
if (!event.isAttached())
reg.removeHandler();
}
});
}
use of com.google.gwt.event.shared.EventHandler in project opennms by OpenNMS.
the class SearchControl method doOnAdd.
public Element doOnAdd() {
LOG.info("SearchControl.onAdd() called");
this.add(m_inputBox);
this.add(m_autoComplete);
/* If the backend sends a new search string, set it on the input box
* to make sure we're in sync, but don't re-fire events.
*/
m_eventManager.addHandler(SearchStringSetEvent.TYPE, this);
m_eventManager.addHandler(FilteredMarkersUpdatedEvent.TYPE, this);
final SearchEventHandler searchEventHandler = new SearchEventHandler() {
@Override
protected void onEvent(final DomEvent<? extends EventHandler> event) {
m_stateManager.handleInputEvent(event.getNativeEvent());
}
};
m_autoComplete.addHandler(new KeyDownHandler() {
@Override
public void onKeyDown(final KeyDownEvent event) {
m_stateManager.handleAutocompleteEvent(event.getNativeEvent());
}
}, KeyDownEvent.getType());
m_inputBox.addKeyDownHandler(searchEventHandler);
m_inputBox.addChangeHandler(searchEventHandler);
m_inputBox.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
SearchEvent.fireNativeEvent(Document.get().createChangeEvent(), m_inputBox);
}
});
m_inputBox.addHandler(searchEventHandler, CutEvent.getType());
m_inputBox.addHandler(searchEventHandler, PasteEvent.getType());
m_inputBox.addHandler(searchEventHandler, SearchEvent.getType());
m_componentTracker.ready(getClass());
return this.getElement();
}
use of com.google.gwt.event.shared.EventHandler in project gwt-test-utils by gwt-test-utils.
the class UiBinderInvocationHandler method createHandler.
private EventHandler createHandler(Widget uiField, Method uiHandlerMethod, Object uiHandlerOwner) {
Class<EventHandler> eventHandlerClass = findHandlerClass(uiHandlerMethod);
InvocationHandler eventHandlerInvocationHandler = createEventHandlerInvocationHandler(uiHandlerMethod, uiHandlerOwner);
return (EventHandler) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class<?>[] { eventHandlerClass }, eventHandlerInvocationHandler);
}
use of com.google.gwt.event.shared.EventHandler in project drools-wb by kiegroup.
the class ListBoxSingletonDOMElementFactoryTest method checkDOMElementCreationBlurHandler.
@Test
@SuppressWarnings("unchecked")
public void checkDOMElementCreationBlurHandler() {
final GridBodyCellRenderContext context = mock(GridBodyCellRenderContext.class);
final Consumer<ListBoxDOMElement<String, ListBox>> onCreation = mock(Consumer.class);
final Consumer<ListBoxDOMElement<String, ListBox>> onDisplay = mock(Consumer.class);
when(context.getTransform()).thenReturn(mock(Transform.class));
factory.attachDomElement(context, onCreation, onDisplay);
final ArgumentCaptor<EventHandler> handlerCaptor = ArgumentCaptor.forClass(EventHandler.class);
verify(listBox, times(4)).addDomHandler(handlerCaptor.capture(), any(DomEvent.Type.class));
// KeyDownHandlerCommon
Assertions.assertThat(handlerCaptor.getAllValues().get(0)).isInstanceOf(KeyDownHandlerCommon.class);
// KeyDownHandler - stopPropagation
final KeyDownEvent keyDownEventMock = mock(KeyDownEvent.class);
Assertions.assertThat(handlerCaptor.getAllValues().get(1)).isInstanceOf(KeyDownHandler.class);
((KeyDownHandler) handlerCaptor.getAllValues().get(1)).onKeyDown(keyDownEventMock);
verify(keyDownEventMock).stopPropagation();
// MouseDownHandler - stopPropagation
final MouseDownEvent mouseDownEventMock = mock(MouseDownEvent.class);
Assertions.assertThat(handlerCaptor.getAllValues().get(2)).isInstanceOf(MouseDownHandler.class);
((MouseDownHandler) handlerCaptor.getAllValues().get(2)).onMouseDown(mouseDownEventMock);
verify(mouseDownEventMock).stopPropagation();
// BlurHandler
final BlurEvent blurEventMock = mock(BlurEvent.class);
Assertions.assertThat(handlerCaptor.getAllValues().get(3)).isInstanceOf(BlurHandler.class);
((BlurHandler) handlerCaptor.getAllValues().get(3)).onBlur(blurEventMock);
verify(factory).flush();
verify(gridLayer).batch();
verify(gridLienzoPanel).setFocus(true);
}
Aggregations