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