litesoft
@ 950
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / client / foundation / widget / input / 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 60 61 62 63 64 65 |
package com.temp.client.foundation.widget.input.support; import com.google.gwt.event.shared.*; import com.temp.client.foundation.widget.input.support.events.*; import com.temp.shared.utils.*; import java.util.*; /** * @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 ) { if ( !(event instanceof NonDomEvent) ) { throw new IllegalStateException( "NonDomHandlerManager can currently only dispatch Events than implement NonDomEvent" ); } NonDomEvent<H> ndEvent = ObjectUtils.cast( event ); ndEvent.setSource( source ); for ( H handler : handlers ) { if ( handler != null ) { ndEvent.dispatch( 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/client/foundation/widget/input/support/NonDomHandlerManager.java
Revision | Author | Commited | Message |
---|---|---|---|
950 Diff | GeorgeS | Thu 19 Jun, 2014 17:57:04 +0000 | New Lines |
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
626 | GeorgeS | Wed 11 Apr, 2012 19:39:41 +0000 |