List of usage examples for com.google.gwt.event.shared HandlerManager getHandlerCount
public int getHandlerCount(GwtEvent.Type<?> type)
From source file:sk.turn.gwtmvp.client.EventManager.java
License:Apache License
/** * Sets an event handler for an {@code Element}. All previous event handlers of this type of event are removed. * @param element The element to bind the event handler for * @param eventType The event type (e.g. {@code ClickEvent.getType()}) * @param handler The handler that handler the event *//*from ww w . ja v a2s . c o m*/ public static <H extends EventHandler> void setEventHandler(final Element element, DomEvent.Type<H> eventType, H handler) { if (element == null) { return; } HandlerManager hm = handlerManagers.get(element); if (hm == null) { handlerManagers.put(element, hm = new HandlerManager(element)); DOM.setEventListener(element, new EventListener() { @Override public void onBrowserEvent(Event event) { DomEvent.fireNativeEvent(event, handlerManagers.get(element), element); } }); } DOM.sinkBitlessEvent(element, eventType.getName()); while (hm.getHandlerCount(eventType) > 0) { hm.removeHandler(eventType, hm.getHandler(eventType, 0)); } hm.addHandler(eventType, handler); }
From source file:sk.turn.gwtmvp.client.EventManager.java
License:Apache License
/** * Clears all event handlers of a specific event type from an element. * @param element The element to clear the event handlers from * @param eventType The event type/* w w w . j a v a 2 s. c om*/ */ public static <H extends EventHandler> void clearEventHandlers(Element element, GwtEvent.Type<H> eventType) { HandlerManager hm = handlerManagers.get(element); while (hm != null && hm.getHandlerCount(eventType) > 0) { hm.removeHandler(eventType, hm.getHandler(eventType, 0)); } }