com.google.web.bindery.event.shared.Event Java Examples
The following examples show how to use
com.google.web.bindery.event.shared.Event.
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> 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 #2
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 #3
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 #4
Source File: InteractionCoordinator.java From core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Event delegation. Uses the dialog ID as source. * * @param event */ public void fireEvent(final Event<?> event) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { bus.fireEventFromSource(event, dialog.getInterfaceModel().getId()); } }); }
Example #5
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 #6
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 #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 | 5 votes |
private <H> void doFire(Event<H> event, Object source) { if (event == null) { throw new NullPointerException("Cannot fire null event"); } try { firingDepth++; if (source != null) { setSourceOfEvent(event, source); } JsArray<H> handlers = getDispatchList(event.getAssociatedType(), source); JsArray<Throwable> causes = null; for (int i = 0; i < handlers.length(); i++) { H handler = handlers.get(i); try { dispatchEvent(event, handler); } catch (Exception e) { if (causes == null) { causes = JsCollections.array(); } causes.set(causes.length(), e); } } if (causes != null) { throw new RuntimeException(causes.get(0)); } } finally { firingDepth--; if (firingDepth == 0) { handleQueuedAddsAndRemoves(); } } }
Example #9
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 5 votes |
@Override public void fireEventFromSource(Event<?> event, Object source) { if (source == null) { throw new NullPointerException("Cannot fire from a null source"); } doFire(event, source); }
Example #10
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 #11
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 #12
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 #13
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 #14
Source File: SimpleEventBus.java From flow with Apache License 2.0 | 4 votes |
@Override public void fireEvent(Event<?> event) { doFire(event, null); }
Example #15
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 #16
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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
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(); }
Example #23
Source File: RequestResponseTracker.java From flow with Apache License 2.0 | 2 votes |
/** * Fires the given event using the event bus for this class. * * @param event * the event to fire */ void fireEvent(Event<?> event) { eventBus.fireEvent(event); }