Subversion Repository Public Repository

litesoft

Diff Revisions 475 vs 948 for /trunk/Java/GWT/Client/src/com/google/gwt/gen2/event/shared/HandlerManager.java

Diff revisions: vs.
  @@ -25,16 +25,14 @@
25 25 * @deprecated use the com.google.gwt.event.shared classes instead
26 26 */
27 27 @Deprecated
28 - public class HandlerManager
29 - {
28 + public class HandlerManager {
30 29 // Used to optimize the JavaScript handler container structure.
31 30 static int EXPECTED_HANDLERS = 5;
32 31
33 32 private static final boolean useJs = GWT.isScript();
34 33 private static int index = -EXPECTED_HANDLERS;
35 34
36 - static int createKeyIndex()
37 - {
35 + static int createKeyIndex() {
38 36 // Need to leave space for the size and the unflattened list if we end up
39 37 // needing it.
40 38 index += EXPECTED_HANDLERS + 2;
  @@ -53,15 +51,11 @@
53 51 *
54 52 * @param source the event source
55 53 */
56 - public HandlerManager( Object source )
57 - {
58 - if ( useJs )
59 - {
54 + public HandlerManager( Object source ) {
55 + if ( useJs ) {
60 56 javaScriptRegistry = JsHandlerRegistry.create();
61 57 javaRegistry = null;
62 - }
63 - else
64 - {
58 + } else {
65 59 javaRegistry = new JavaHandlerRegistry();
66 60 javaScriptRegistry = null;
67 61 }
  @@ -76,16 +70,12 @@
76 70 * @param handler the handler
77 71 *
78 72 * @return the handler registration, can be stored in order to remove the
79 - * handler later
73 + * handler later
80 74 */
81 - public <HandlerType extends EventHandler> HandlerRegistration addHandler( AbstractEvent.Type<?, HandlerType> type, final HandlerType handler )
82 - {
83 - if ( useJs )
84 - {
75 + public <HandlerType extends EventHandler> HandlerRegistration addHandler( AbstractEvent.Type<?, HandlerType> type, final HandlerType handler ) {
76 + if ( useJs ) {
85 77 javaScriptRegistry.addHandler( type, handler );
86 - }
87 - else
88 - {
78 + } else {
89 79 javaRegistry.addHandler( type, handler );
90 80 }
91 81 return new HandlerRegistration( this, type, handler );
  @@ -96,14 +86,10 @@
96 86 *
97 87 * @param type the type
98 88 */
99 - public void clearHandlers( Type<?, ?> type )
100 - {
101 - if ( useJs )
102 - {
89 + public void clearHandlers( Type<?, ?> type ) {
90 + if ( useJs ) {
103 91 javaScriptRegistry.clearHandlers( type );
104 - }
105 - else
106 - {
92 + } else {
107 93 javaRegistry.clearHandlers( type );
108 94 }
109 95 }
  @@ -113,25 +99,18 @@
113 99 *
114 100 * @param event the event
115 101 */
116 - public void fireEvent( AbstractEvent event )
117 - {
102 + public void fireEvent( AbstractEvent event ) {
118 103 Object oldSource = event.getSource();
119 104 event.setSource( source );
120 - if ( useJs )
121 - {
105 + if ( useJs ) {
122 106 javaScriptRegistry.fireEvent( event );
123 - }
124 - else
125 - {
107 + } else {
126 108 javaRegistry.fireEvent( event );
127 109 }
128 - if ( oldSource == null )
129 - {
110 + if ( oldSource == null ) {
130 111 // This was my event, so I should kill it now that I'm done.
131 112 event.kill();
132 - }
133 - else
134 - {
113 + } else {
135 114 // Restoring the source for the next handler to use.
136 115 event.setSource( oldSource );
137 116 }
  @@ -146,14 +125,10 @@
146 125 *
147 126 * @return the given handler
148 127 */
149 - public <HandlerType extends EventHandler> HandlerType getHandler( AbstractEvent.Type<?, HandlerType> type, int index )
150 - {
151 - if ( useJs )
152 - {
128 + public <HandlerType extends EventHandler> HandlerType getHandler( AbstractEvent.Type<?, HandlerType> type, int index ) {
129 + if ( useJs ) {
153 130 return (HandlerType) javaScriptRegistry.getHandler( type, index );
154 - }
155 - else
156 - {
131 + } else {
157 132 return (HandlerType) javaRegistry.getHandler( type, index );
158 133 }
159 134 }
  @@ -165,14 +140,10 @@
165 140 *
166 141 * @return the number of registered handlers
167 142 */
168 - public int getHandlerCount( Type type )
169 - {
170 - if ( useJs )
171 - {
143 + public int getHandlerCount( Type type ) {
144 + if ( useJs ) {
172 145 return javaScriptRegistry.getHandlerCount( type );
173 - }
174 - else
175 - {
146 + } else {
176 147 return javaRegistry.getHandlerCount( type );
177 148 }
178 149 }
  @@ -182,8 +153,7 @@
182 153 *
183 154 * @return the source
184 155 */
185 - public Object getSource()
186 - {
156 + public Object getSource() {
187 157 return source;
188 158 }
189 159
  @@ -194,8 +164,7 @@
194 164 *
195 165 * @return are handlers listening on the given event type
196 166 */
197 - public boolean isEventHandled( Type type )
198 - {
167 + public boolean isEventHandled( Type type ) {
199 168 return getHandlerCount( type ) > 0;
200 169 }
201 170
  @@ -208,14 +177,10 @@
208 177 * @param type the event type
209 178 * @param handler the handler
210 179 */
211 - public <HandlerType extends EventHandler> void removeHandler( AbstractEvent.Type<?, HandlerType> type, final HandlerType handler )
212 - {
213 - if ( useJs )
214 - {
180 + public <HandlerType extends EventHandler> void removeHandler( AbstractEvent.Type<?, HandlerType> type, final HandlerType handler ) {
181 + if ( useJs ) {
215 182 javaScriptRegistry.removeHandler( type, handler );
216 - }
217 - else
218 - {
183 + } else {
219 184 javaRegistry.removeHandler( type, handler );
220 185 }
221 186 }