Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/com/google/gwt/gen2/event/dom/client/DomEvent.java

Diff revisions: vs.
  @@ -15,12 +15,12 @@
15 15 */
16 16 package com.google.gwt.gen2.event.dom.client;
17 17
18 - import java.util.*;
19 -
20 18 import com.google.gwt.core.client.*;
21 19 import com.google.gwt.gen2.event.shared.*;
22 20 import com.google.gwt.user.client.*;
23 21
22 + import java.util.*;
23 +
24 24 /**
25 25 * {@link DomEvent} is a subclass of AbstractEvent that provides events that map
26 26 * to DOM Level 2 Events. It provides an additional method to access the
  @@ -30,8 +30,7 @@
30 30 * @deprecated use the com.google.gwt.event.dom.client classes instead
31 31 */
32 32 @Deprecated
33 - public abstract class DomEvent extends AbstractEvent
34 - {
33 + public abstract class DomEvent extends AbstractEvent {
35 34
36 35 /**
37 36 * Type class used by BrowserEvent subclasses.
  @@ -39,8 +38,7 @@
39 38 * @param <EventType> event type
40 39 * @param <HandlerType> handler type
41 40 */
42 - public abstract static class Type<EventType extends DomEvent, HandlerType extends EventHandler> extends AbstractEvent.Type<EventType, HandlerType>
43 - {
41 + public abstract static class Type<EventType extends DomEvent, HandlerType extends EventHandler> extends AbstractEvent.Type<EventType, HandlerType> {
44 42 private int nativeEventType;
45 43 DomEvent cached;
46 44
  @@ -49,11 +47,9 @@
49 47 *
50 48 * @param nativeEventType the native event type
51 49 */
52 - public Type( int nativeEventType )
53 - {
50 + public Type( int nativeEventType ) {
54 51 // All clinit activity should take place here for DomEvent.
55 - if ( registered == null )
56 - {
52 + if ( registered == null ) {
57 53 registered = new WrappedKeyMap();
58 54 }
59 55 this.nativeEventType = nativeEventType;
  @@ -66,8 +62,7 @@
66 62 *
67 63 * @return the native event type
68 64 */
69 - public int getNativeEventType()
70 - {
65 + public int getNativeEventType() {
71 66 return nativeEventType;
72 67 }
73 68
  @@ -82,17 +77,13 @@
82 77 }
83 78
84 79 // Eventually should be replaced by JsStringMap.
85 - private static class WrappedKeyMap
86 - {
87 - private static class KeyMap extends JavaScriptObject
88 - {
89 - public static KeyMap create()
90 - {
80 + private static class WrappedKeyMap {
81 + private static class KeyMap extends JavaScriptObject {
82 + public static KeyMap create() {
91 83 return (KeyMap) JavaScriptObject.createObject();
92 84 }
93 85
94 - protected KeyMap()
95 - {
86 + protected KeyMap() {
96 87 }
97 88
98 89 public final native DomEvent.Type get( String nativeEventType ) /*-{
  @@ -108,38 +99,26 @@
108 99
109 100 private HashMap<String, DomEvent.Type> javaMap;
110 101
111 - WrappedKeyMap()
112 - {
113 - if ( GWT.isScript() )
114 - {
102 + WrappedKeyMap() {
103 + if ( GWT.isScript() ) {
115 104 map = KeyMap.create();
116 - }
117 - else
118 - {
105 + } else {
119 106 javaMap = new HashMap<String, DomEvent.Type>();
120 107 }
121 108 }
122 109
123 - public final DomEvent.Type get( String nativeEventType )
124 - {
125 - if ( GWT.isScript() )
126 - {
110 + public final DomEvent.Type get( String nativeEventType ) {
111 + if ( GWT.isScript() ) {
127 112 return map.get( nativeEventType );
128 - }
129 - else
130 - {
113 + } else {
131 114 return javaMap.get( nativeEventType );
132 115 }
133 116 }
134 117
135 - public final void put( String nativeEventType, DomEvent.Type key )
136 - {
137 - if ( GWT.isScript() )
138 - {
118 + public final void put( String nativeEventType, DomEvent.Type key ) {
119 + if ( GWT.isScript() ) {
139 120 map.put( nativeEventType, key );
140 - }
141 - else
142 - {
121 + } else {
143 122 javaMap.put( nativeEventType, key );
144 123 }
145 124 }
  @@ -161,19 +140,13 @@
161 140 * event.
162 141 * @param manager the event manager
163 142 */
164 - public static void fireNativeEvent( int eventType, HandlerManager manager )
165 - {
166 - if ( registered != null )
167 - {
143 + public static void fireNativeEvent( int eventType, HandlerManager manager ) {
144 + if ( registered != null ) {
168 145 DomEvent.Type typeKey = registered.get( getType( eventType ) );
169 - if ( typeKey != null && manager.isEventHandled( typeKey ) )
170 - {
171 - if ( typeKey.cached == null || typeKey.cached.isLive() )
172 - {
146 + if ( typeKey != null && manager.isEventHandled( typeKey ) ) {
147 + if ( typeKey.cached == null || typeKey.cached.isLive() ) {
173 148 typeKey.cached = typeKey.wrap( null );
174 - }
175 - else
176 - {
149 + } else {
177 150 typeKey.cached.reset( null );
178 151 }
179 152 manager.fireEvent( typeKey.cached );
  @@ -187,19 +160,13 @@
187 160 * @param nativeEvent the native event
188 161 * @param manager the event manager
189 162 */
190 - public static void fireNativeEvent( Event nativeEvent, HandlerManager manager )
191 - {
192 - if ( registered != null )
193 - {
163 + public static void fireNativeEvent( Event nativeEvent, HandlerManager manager ) {
164 + if ( registered != null ) {
194 165 DomEvent.Type typeKey = registered.get( nativeEvent.getType() );
195 - if ( typeKey != null && manager.isEventHandled( typeKey ) )
196 - {
197 - if ( typeKey.cached == null || typeKey.cached.isLive() )
198 - {
166 + if ( typeKey != null && manager.isEventHandled( typeKey ) ) {
167 + if ( typeKey.cached == null || typeKey.cached.isLive() ) {
199 168 typeKey.cached = typeKey.wrap( nativeEvent );
200 - }
201 - else
202 - {
169 + } else {
203 170 typeKey.cached.reset( nativeEvent );
204 171 }
205 172 manager.fireEvent( typeKey.cached );
  @@ -207,10 +174,8 @@
207 174 }
208 175 }
209 176
210 - private static String getType( int type )
211 - {
212 - switch ( type )
213 - {
177 + private static String getType( int type ) {
178 + switch ( type ) {
214 179 case 0x01000:
215 180 return "blur";
216 181 case 0x00400:
  @@ -261,8 +226,7 @@
261 226 *
262 227 * @param nativeEvent the native event
263 228 */
264 - protected DomEvent( Event nativeEvent )
265 - {
229 + protected DomEvent( Event nativeEvent ) {
266 230 this.nativeEvent = nativeEvent;
267 231 }
268 232
  @@ -271,8 +235,7 @@
271 235 *
272 236 * @return gets the native event
273 237 */
274 - public final Event getNativeEvent()
275 - {
238 + public final Event getNativeEvent() {
276 239 assertLive();
277 240 return nativeEvent;
278 241 }
  @@ -280,8 +243,7 @@
280 243 /**
281 244 * Prevents the wrapped native event's default action.
282 245 */
283 - public void preventDefault()
284 - {
246 + public void preventDefault() {
285 247 assertLive();
286 248 nativeEvent.preventDefault();
287 249 }
  @@ -289,23 +251,20 @@
289 251 /**
290 252 * Stops the propagation of the underlying native event.
291 253 */
292 - public void stopPropagation()
293 - {
254 + public void stopPropagation() {
294 255 assertLive();
295 256 nativeEvent.cancelBubble( true );
296 257 }
297 258
298 259 @Override
299 - public String toString()
300 - {
260 + public String toString() {
301 261 return getType( getType().getNativeEventType() ) + " event";
302 262 }
303 263
304 264 @Override
305 265 protected abstract DomEvent.Type getType();
306 266
307 - void reset( Event event )
308 - {
267 + void reset( Event event ) {
309 268 super.revive();
310 269 nativeEvent = event;
311 270 }