I’ve analyzed HandlerManager and I do not see how it handles event source. Line 117:
public void fireEvent(GwtEvent<?> event) {
...
Object oldSource = event.getSource();
event.overrideSource(source);
try {
// May throw an UmbrellaException.
eventBus.fireEvent(event); // <--- LOOK HERE
} catch (com.google.web.bindery.event.shared.UmbrellaException e) {
throw new UmbrellaException(e.getCauses());
} finally {
....
}
}
But simple event bus implementation has following code, line 86:
@Override
public void fireEvent(Event<?> event) {
doFire(event, null); // <---- SOURCE IS NULL???
}
@Override
public void fireEventFromSource(Event<?> event, Object source) {
if (source == null) {
throw new NullPointerException("Cannot fire from a null source");
}
doFire(event, source);
}
So, HandlerManager does not fire events with source, because it always calls doFire(event, null);
Could you make it clear how does HandlerManager fire event for source? As HandlerManager used in Widget, how does it fire events for Widget instance only?
doFireinSimpleEventBusonly changes the event’s source if thesourceargument is notnull.HandlerManagerfirst sets the event’s source withoverrideSourceand then calldoFirewith an implicitnullsource so it won’t overwrite it.QED.