Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/widget/input/support/NonDomHandlerManager.java

Diff revisions: vs.
  @@ -1,65 +1,65 @@
1 - package com.temp.client.foundation.widget.input.support;
2 -
3 - import com.google.gwt.event.shared.*;
4 - import com.temp.client.foundation.widget.input.support.events.*;
5 - import com.temp.shared.utils.*;
6 -
7 - import java.util.*;
8 -
9 - /**
10 - * @param <H> interface implemented by handlers of this kind of event
11 - */
12 - public class NonDomHandlerManager<H extends EventHandler> implements HasHandlers {
13 -
14 - private final List<H> handlers = new ArrayList<H>();
15 - private final Object source;
16 -
17 - public NonDomHandlerManager( Object source ) {
18 - this.source = source;
19 - }
20 -
21 - @Override
22 - public void fireEvent( GwtEvent<?> event ) {
23 - if ( !(event instanceof NonDomEvent) ) {
24 - throw new IllegalStateException( "NonDomHandlerManager can currently only dispatch Events than implement NonDomEvent" );
25 - }
26 - NonDomEvent<H> ndEvent = ObjectUtils.cast( event );
27 - ndEvent.setSource( source );
28 - for ( H handler : handlers ) {
29 - if ( handler != null ) {
30 - ndEvent.dispatch( handler );
31 - }
32 - }
33 - }
34 -
35 - /**
36 - * Adds a handler.
37 - *
38 - * @param handler the handler
39 - *
40 - * @return the handler registration
41 - */
42 - public HandlerRegistration addHandler( H handler ) {
43 - if ( handler == null ) {
44 - return null;
45 - }
46 - int index = handlers.size();
47 - handlers.add( handler );
48 - return new IndexHandlerRegistration( index );
49 - }
50 -
51 - private class IndexHandlerRegistration implements HandlerRegistration {
52 - private final int index;
53 -
54 - private IndexHandlerRegistration( int index ) {
55 - this.index = index;
56 - }
57 -
58 - @Override
59 - public void removeHandler() {
60 - if ( index < handlers.size() ) {
61 - handlers.set( index, null );
62 - }
63 - }
64 - }
65 - }
1 + package com.temp.client.foundation.widget.input.support;
2 +
3 + import com.google.gwt.event.shared.*;
4 + import com.temp.client.foundation.widget.input.support.events.*;
5 + import com.temp.shared.utils.*;
6 +
7 + import java.util.*;
8 +
9 + /**
10 + * @param <H> interface implemented by handlers of this kind of event
11 + */
12 + public class NonDomHandlerManager<H extends EventHandler> implements HasHandlers {
13 +
14 + private final List<H> handlers = new ArrayList<H>();
15 + private final Object source;
16 +
17 + public NonDomHandlerManager( Object source ) {
18 + this.source = source;
19 + }
20 +
21 + @Override
22 + public void fireEvent( GwtEvent<?> event ) {
23 + if ( !(event instanceof NonDomEvent) ) {
24 + throw new IllegalStateException( "NonDomHandlerManager can currently only dispatch Events than implement NonDomEvent" );
25 + }
26 + NonDomEvent<H> ndEvent = ObjectUtils.cast( event );
27 + ndEvent.setSource( source );
28 + for ( H handler : handlers ) {
29 + if ( handler != null ) {
30 + ndEvent.dispatch( handler );
31 + }
32 + }
33 + }
34 +
35 + /**
36 + * Adds a handler.
37 + *
38 + * @param handler the handler
39 + *
40 + * @return the handler registration
41 + */
42 + public HandlerRegistration addHandler( H handler ) {
43 + if ( handler == null ) {
44 + return null;
45 + }
46 + int index = handlers.size();
47 + handlers.add( handler );
48 + return new IndexHandlerRegistration( index );
49 + }
50 +
51 + private class IndexHandlerRegistration implements HandlerRegistration {
52 + private final int index;
53 +
54 + private IndexHandlerRegistration( int index ) {
55 + this.index = index;
56 + }
57 +
58 + @Override
59 + public void removeHandler() {
60 + if ( index < handlers.size() ) {
61 + handlers.set( index, null );
62 + }
63 + }
64 + }
65 + }