Java Code Examples for com.google.web.bindery.event.shared.Event#Type
The following examples show how to use
com.google.web.bindery.event.shared.Event#Type .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 6 votes |
private <H> HandlerRegistration doAdd(final Event.Type<H> type, final Object source, final H handler) { if (type == null) { throw new NullPointerException( "Cannot add a handler with a null type"); } if (handler == null) { throw new NullPointerException("Cannot add a null handler"); } if (firingDepth > 0) { enqueueAdd(type, source, handler); } else { doAddNow(type, source, handler); } return () -> doRemove(type, source, handler); }
Example 2
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 6 votes |
private <H> JsArray<H> ensureHandlerList(Event.Type<H> type, Object source) { JsMap<Object, JsArray<?>> sourceMap = map.get(type); if (sourceMap == null) { sourceMap = JsCollections.map(); map.set(type, sourceMap); } // safe, we control the puts. @SuppressWarnings("unchecked") JsArray<H> handlers = (JsArray<H>) sourceMap.get(source); if (handlers == null) { handlers = JsCollections.array(); sourceMap.set(source, handlers); } return handlers; }
Example 3
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 5 votes |
private void prune(Event.Type<?> type, Object source) { JsMap<Object, JsArray<?>> sourceMap = map.get(type); JsArray<?> pruned = sourceMap.get(source); sourceMap.delete(source); assert pruned != null : "Can't prune what wasn't there"; assert pruned.isEmpty() : "Pruned unempty list!"; if (sourceMap.isEmpty()) { map.delete(type); } }
Example 4
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 5 votes |
private <H> void doRemoveNow(Event.Type<H> type, Object source, H handler) { JsArray<H> l = getHandlerList(type, source); boolean removed = l.remove(handler); if (removed && l.isEmpty()) { prune(type, source); } }
Example 5
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 5 votes |
private <H> JsArray<H> getHandlerList(Event.Type<H> type, Object source) { JsMap<Object, JsArray<?>> sourceMap = map.get(type); if (sourceMap == null) { return JsCollections.array(); } // safe, we control the puts. @SuppressWarnings("unchecked") JsArray<H> handlers = (JsArray<H>) sourceMap.get(source); if (handlers == null) { return JsCollections.array(); } return handlers; }
Example 6
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 5 votes |
@Override public <H> HandlerRegistration addHandlerToSource(final Event.Type<H> type, final Object source, final H handler) { if (source == null) { throw new NullPointerException( "Cannot add a handler with a null source"); } return doAdd(type, source, handler); }
Example 7
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 5 votes |
private <H> JsArray<H> getDispatchList(Event.Type<H> type, Object source) { JsArray<H> directHandlers = getHandlerList(type, source); if (source == null) { return directHandlers; } JsArray<H> globalHandlers = getHandlerList(type, null); JsArray<H> rtn = JsCollections.array(); rtn.pushArray(directHandlers); rtn.pushArray(globalHandlers); return rtn; }
Example 8
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 4 votes |
private <H> void enqueueRemove(final Event.Type<H> type, final Object source, final H handler) { defer(() -> doRemoveNow(type, source, handler)); }
Example 9
Source File: HandlerManager.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
private boolean superIsEventHandled(Event.Type<?> eventKey) { return super.isEventHandled(eventKey); }
Example 10
Source File: HandlerManager.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
private int superGetHandlerCount(Event.Type<?> eventKey) { return super.getHandlerCount(eventKey); }
Example 11
Source File: HandlerManager.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
private <H> H superGetHandler(Event.Type<H> type, int index) { return super.getHandler(type, index); }
Example 12
Source File: HandlerManager.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
private <H> void superDoRemove(Event.Type<H> type, Object source, H handler) { super.doRemove(type, source, handler); }
Example 13
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 4 votes |
private <H> void enqueueAdd(final Event.Type<H> type, final Object source, final H handler) { defer(() -> doAddNow(type, source, handler)); }
Example 14
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private <H> void doAddNow(Event.Type<H> type, Object source, H handler) { JsArray<H> l = ensureHandlerList(type, source); l.push(handler); }
Example 15
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 3 votes |
/** * Not documented in GWT, required by legacy features in GWT's old * HandlerManager. * * @param type * the type * @param index * the index * @param <H> * the handler type * @return the handler * * @deprecated required by legacy features in GWT's old HandlerManager */ @Deprecated protected <H> H getHandler(Event.Type<H> type, int index) { assert index < getHandlerCount(type) : "handlers for " + type.getClass() + " have size: " + getHandlerCount(type) + " so do not have a handler at index: " + index; JsArray<H> l = getHandlerList(type, null); return l.get(index); }
Example 16
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 3 votes |
/** * Not documented in GWT, required by legacy features in GWT's old * HandlerManager. * * @param type * the type * @param source * the source * @param handler * the handler * @param <H> * the handler type * @deprecated required by legacy features in GWT's old HandlerManager */ @Deprecated protected <H> void doRemove(Event.Type<H> type, Object source, H handler) { if (firingDepth > 0) { enqueueRemove(type, source, handler); } else { doRemoveNow(type, source, handler); } }
Example 17
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 2 votes |
/** * Not documented in GWT, required by legacy features in GWT's old * HandlerManager. * * @param eventKey * the event type * @return {@code true} if the event is handled, {@code false} otherwise * @deprecated required by legacy features in GWT's old HandlerManager */ @Deprecated protected boolean isEventHandled(Event.Type<?> eventKey) { return map.has(eventKey); }
Example 18
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 2 votes |
/** * Not documented in GWT, required by legacy features in GWT's old * HandlerManager. * * @param eventKey * the event type * @return the handlers count * * @deprecated required by legacy features in GWT's old HandlerManager */ @Deprecated protected int getHandlerCount(Event.Type<?> eventKey) { return getHandlerList(eventKey, null).length(); }