1 Clazz.declarePackage ("java.awt");
\r
2 Clazz.load (["java.awt.AWTEvent", "$.ActiveEvent", "$.EventFilter", "swingjs.JSThread", "java.util.Vector"], "java.awt.EventDispatchThread", ["java.lang.Error", "$.RuntimeException", "$.Thread", "java.awt.Component", "$.Container", "$.ModalEventFilter", "$.Window", "jssun.awt.AWTAutoShutdown", "$.ModalExclude", "$.SunToolkit", "swingjs.JSToolkit"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.theQueue = null;
\r
5 this.eventFilters = null;
\r
6 this.modalFiltersCount = 0;
\r
10 this.doDispatch = true;
\r
11 if (!Clazz.isClassDefined ("java.awt.EventDispatchThread.StopDispatchEvent")) {
\r
12 java.awt.EventDispatchThread.$EventDispatchThread$StopDispatchEvent$ ();
\r
14 Clazz.instantialize (this, arguments);
\r
15 }, java.awt, "EventDispatchThread", swingjs.JSThread);
\r
16 Clazz.prepareFields (c$, function () {
\r
17 this.eventFilters = new java.util.Vector ();
\r
19 Clazz.makeConstructor (c$,
\r
20 function (group, name, queue) {
\r
21 Clazz.superConstructor (this, java.awt.EventDispatchThread, [group, name]);
\r
22 this.theQueue = queue;
\r
23 }, "ThreadGroup,~S,java.awt.EventQueue");
\r
24 Clazz.defineMethod (c$, "stopDispatchingImpl",
\r
26 var stopEvent = Clazz.innerTypeInstance (java.awt.EventDispatchThread.StopDispatchEvent, this, null);
\r
27 if (Thread.currentThread () !== this) {
\r
28 this.theQueue.postEventPrivate (stopEvent);
\r
33 if (Clazz.exceptionOf (e, InterruptedException)) {
\r
39 stopEvent.dispatch ();
\r
41 if (this.theQueue.getDispatchThread () === this) {
\r
42 this.theQueue.detachDispatchThread ();
\r
44 Clazz.defineMethod (c$, "stopDispatching",
\r
46 this.stopDispatchingImpl (true);
\r
48 Clazz.defineMethod (c$, "stopDispatchingLater",
\r
50 this.stopDispatchingImpl (false);
\r
52 Clazz.overrideMethod (c$, "run",
\r
54 this.pumpEvents (-1, null);
\r
56 Clazz.defineMethod (c$, "pumpEvents",
\r
57 function (id, cond) {
\r
58 this.pumpEventsForHierarchy (id, cond, null);
\r
59 }, "~N,java.awt.Conditional");
\r
60 Clazz.defineMethod (c$, "pumpEventsForHierarchy",
\r
61 function (id, cond, modalComponent) {
\r
62 this.pumpEventsForFilter (id, cond, new java.awt.EventDispatchThread.HierarchyEventFilter (modalComponent));
\r
63 }, "~N,java.awt.Conditional,java.awt.Component");
\r
64 Clazz.defineMethod (c$, "pumpEventsForFilter",
\r
65 function (id, cond, filter) {
\r
66 this.filter = filter;
\r
70 }, "~N,java.awt.Conditional,java.awt.EventFilter");
\r
71 Clazz.overrideMethod (c$, "run1",
\r
74 while (true) switch (mode) {
\r
76 this.addEventFilter (this.filter);
\r
79 if (!this.doDispatch || this.cond != null && !this.cond.evaluate () || this.isInterrupted ()) {
\r
80 this.doDispatch = false;
\r
82 }var myid = this.id;
\r
83 var r = ((Clazz.isClassDefined ("java.awt.EventDispatchThread$1") ? 0 : java.awt.EventDispatchThread.$EventDispatchThread$1$ ()), Clazz.innerTypeInstance (java.awt.EventDispatchThread$1, this, Clazz.cloneFinals ("myid", myid)));
\r
84 this.dispatchAndReturn (r, mode);
\r
85 if (this.isJS) return;
\r
88 this.doDispatch = false;
\r
93 if (!this.doDispatch) this.finish ();
\r
96 Clazz.defineMethod (c$, "dispatchAndReturn",
\r
97 function (r, mode) {
\r
101 f = function() {r.run();me.run1(mode)
\r
103 }swingjs.JSToolkit.setTimeout (f, 0, 0);
\r
105 Clazz.defineMethod (c$, "finish",
\r
107 this.doDispatch = false;
\r
108 this.removeEventFilter (this.filter);
\r
110 if (this.theQueue.getDispatchThread () === this) {
\r
111 this.theQueue.detachDispatchThread ();
\r
112 }if (this.theQueue.peekEvent () != null || !jssun.awt.SunToolkit.isPostEventQueueEmpty ()) {
\r
113 this.theQueue.initDispatchThread ();
\r
114 }jssun.awt.AWTAutoShutdown.getInstance ().notifyThreadFree (this);
\r
116 Clazz.defineMethod (c$, "addEventFilter",
\r
117 function (filter) {
\r
119 if (!this.eventFilters.contains (filter)) {
\r
120 if (Clazz.instanceOf (filter, java.awt.ModalEventFilter)) {
\r
121 var newFilter = filter;
\r
123 for (k = 0; k < this.eventFilters.size (); k++) {
\r
124 var f = this.eventFilters.get (k);
\r
125 if (Clazz.instanceOf (f, java.awt.ModalEventFilter)) {
\r
127 if (cf.compareTo (newFilter) > 0) {
\r
130 this.eventFilters.add (k, filter);
\r
131 this.modalFiltersCount++;
\r
133 this.eventFilters.add (filter);
\r
134 }}}}, "java.awt.EventFilter");
\r
135 Clazz.defineMethod (c$, "removeEventFilter",
\r
136 function (filter) {
\r
138 if (this.eventFilters.contains (filter)) {
\r
139 if (Clazz.instanceOf (filter, java.awt.ModalEventFilter)) {
\r
140 this.modalFiltersCount--;
\r
141 }this.eventFilters.remove (filter);
\r
142 }}}, "java.awt.EventFilter");
\r
143 Clazz.defineMethod (c$, "pumpOneEventForFilters",
\r
149 event = (id == -1) ? this.theQueue.getNextEvent () : this.theQueue.getNextEventForID (id);
\r
150 if (event == null) return (this.doDispatch = false);
\r
153 for (var i = this.eventFilters.size () - 1; i >= 0; i--) {
\r
154 var f = this.eventFilters.get (i);
\r
155 var accept = f.acceptEvent (event);
\r
156 if (accept === java.awt.EventFilter.FilterAction.REJECT) {
\r
159 } else if (accept === java.awt.EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
\r
164 }} while (eventOK == false);
\r
165 this.theQueue.dispatchEvent (event);
\r
166 return this.doDispatch = true;
\r
168 if (Clazz.exceptionOf (e$$, ThreadDeath)) {
\r
171 return this.doDispatch = false;
\r
173 } else if (Clazz.exceptionOf (e$$, InterruptedException)) {
\r
174 var interruptedException = e$$;
\r
176 return this.doDispatch = false;
\r
181 this.processException (e, this.modalFiltersCount > 0);
\r
185 return this.doDispatch = true;
\r
187 Clazz.defineMethod (c$, "processException",
\r
188 function (e, isModal) {
\r
189 if (!this.handleException (e)) {
\r
191 System.err.println ("Exception occurred during event dispatching:");
\r
192 e.printStackTrace ();
\r
193 } else if (Clazz.instanceOf (e, RuntimeException)) {
\r
195 } else if (Clazz.instanceOf (e, Error)) {
\r
197 }}}, "Throwable,~B");
\r
198 Clazz.defineMethod (c$, "handleException",
\r
199 function (thrown) {
\r
202 Clazz.defineMethod (c$, "isDispatching",
\r
204 return this.theQueue.equals (eq);
\r
205 }, "java.awt.EventQueue");
\r
206 Clazz.defineMethod (c$, "getEventQueue",
\r
208 return this.theQueue;
\r
210 c$.$EventDispatchThread$StopDispatchEvent$ = function () {
\r
211 Clazz.pu$h(self.c$);
\r
212 c$ = Clazz.decorateAsClass (function () {
\r
213 Clazz.prepareCallback (this, arguments);
\r
214 Clazz.instantialize (this, arguments);
\r
215 }, java.awt.EventDispatchThread, "StopDispatchEvent", java.awt.AWTEvent, java.awt.ActiveEvent);
\r
216 Clazz.makeConstructor (c$,
\r
218 Clazz.superConstructor (this, java.awt.EventDispatchThread.StopDispatchEvent, [this.b$["java.awt.EventDispatchThread"], 0]);
\r
220 Clazz.overrideMethod (c$, "dispatch",
\r
222 this.b$["java.awt.EventDispatchThread"].doDispatch = false;
\r
226 c$.$EventDispatchThread$1$ = function () {
\r
227 Clazz.pu$h(self.c$);
\r
228 c$ = Clazz.declareAnonymous (java.awt, "EventDispatchThread$1", null, Runnable);
\r
229 Clazz.overrideMethod (c$, "run",
\r
231 this.b$["java.awt.EventDispatchThread"].pumpOneEventForFilters (this.f$.myid);
\r
235 Clazz.pu$h(self.c$);
\r
236 c$ = Clazz.decorateAsClass (function () {
\r
237 this.modalComponent = null;
\r
238 Clazz.instantialize (this, arguments);
\r
239 }, java.awt.EventDispatchThread, "HierarchyEventFilter", null, java.awt.EventFilter);
\r
240 Clazz.makeConstructor (c$,
\r
242 this.modalComponent = a;
\r
243 }, "java.awt.Component");
\r
244 Clazz.overrideMethod (c$, "acceptEvent",
\r
246 if (this.modalComponent != null) {
\r
247 var b = a.getID ();
\r
248 var c = (b >= 500) && (b <= 507);
\r
249 var d = (b >= 1001) && (b <= 1001);
\r
250 var e = (b == 201);
\r
251 if (java.awt.Component.isInstanceOf (this.modalComponent, "javax.swing.JInternalFrame")) {
\r
252 return e ? java.awt.EventFilter.FilterAction.REJECT : java.awt.EventFilter.FilterAction.ACCEPT;
\r
253 }if (c || d || e) {
\r
254 var f = a.getSource ();
\r
255 if (Clazz.instanceOf (f, jssun.awt.ModalExclude)) {
\r
256 return java.awt.EventFilter.FilterAction.ACCEPT;
\r
257 } else if (Clazz.instanceOf (f, java.awt.Component)) {
\r
260 if (Clazz.instanceOf (this.modalComponent, java.awt.Container)) {
\r
261 while (g !== this.modalComponent && g != null) {
\r
262 if ((Clazz.instanceOf (g, java.awt.Window)) && (jssun.awt.SunToolkit.isModalExcluded (g))) {
\r
265 }g = g.getParent ();
\r
267 }if (!h && (g !== this.modalComponent)) {
\r
268 return java.awt.EventFilter.FilterAction.REJECT;
\r
269 }}}}return java.awt.EventFilter.FilterAction.ACCEPT;
\r
270 }, "java.awt.AWTEvent");
\r
272 Clazz.defineStatics (c$,
\r