litesoft
@ 591
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / foundation / widgets / support / NonDomHandlerManager.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
package com.temp.foundation.widgets.support; import com.google.gwt.event.shared.*; import java.util.ArrayList; import java.util.List; /** * @param <H> interface implemented by handlers of this kind of event */ public class NonDomHandlerManager<H extends EventHandler> implements HasHandlers { private final List<H> handlers = new ArrayList<H>(); private final Object source; public NonDomHandlerManager(Object source) { this.source = source; } @Override public void fireEvent(GwtEvent<?> event) { EventBridge.overrideSource(event, source); for (H handler : handlers) { if (handler != null) { EventBridge.dispatch(event, handler); } } } /** * Adds a handler. * * @param handler the handler * @return the handler registration */ public HandlerRegistration addHandler(H handler) { if (handler == null) { return null; } int index = handlers.size(); handlers.add(handler); return new IndexHandlerRegistration(index); } private class IndexHandlerRegistration implements HandlerRegistration { private final int index; private IndexHandlerRegistration(int index) { this.index = index; } @Override public void removeHandler() { if (index < handlers.size()) { handlers.set(index, null); } } } } |
Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/foundation/widgets/support/NonDomHandlerManager.java
Revision | Author | Commited | Message |
---|---|---|---|
591 | GeorgeS | Fri 20 Jan, 2012 01:57:31 +0000 | New FormEngine |