1 Clazz.declarePackage ("jssun.awt");
2 Clazz.load (["java.util.HashSet", "$.IdentityHashMap"], "jssun.awt.AWTAutoShutdown", ["java.awt.AWTEvent"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.busyThreadSet = null;
5 this.toolkitThreadBusy = false;
7 Clazz.instantialize (this, arguments);
8 }, jssun.awt, "AWTAutoShutdown", null, Runnable);
9 Clazz.prepareFields (c$, function () {
10 this.busyThreadSet = new java.util.HashSet (7);
11 this.peerMap = new java.util.IdentityHashMap ();
13 Clazz.makeConstructor (c$,
16 c$.getInstance = Clazz.defineMethod (c$, "getInstance",
18 return (jssun.awt.AWTAutoShutdown.theInstance == null ? (jssun.awt.AWTAutoShutdown.theInstance = new jssun.awt.AWTAutoShutdown ()) : jssun.awt.AWTAutoShutdown.theInstance);
20 c$.notifyToolkitThreadBusy = Clazz.defineMethod (c$, "notifyToolkitThreadBusy",
22 jssun.awt.AWTAutoShutdown.getInstance ().setToolkitBusy (true);
24 c$.notifyToolkitThreadFree = Clazz.defineMethod (c$, "notifyToolkitThreadFree",
26 jssun.awt.AWTAutoShutdown.getInstance ().setToolkitBusy (false);
28 Clazz.defineMethod (c$, "notifyThreadBusy",
30 this.busyThreadSet.add (thread);
32 Clazz.defineMethod (c$, "notifyThreadFree",
34 this.busyThreadSet.remove (thread);
36 Clazz.defineMethod (c$, "notifyPeerMapUpdated",
38 if (!this.isReadyToShutdown ()) {
39 this.activateBlockerThread ();
41 Clazz.defineMethod (c$, "isReadyToShutdown",
43 return (!this.toolkitThreadBusy && this.peerMap.isEmpty () && this.busyThreadSet.isEmpty ());
45 Clazz.defineMethod (c$, "setToolkitBusy",
47 if (busy != this.toolkitThreadBusy) {
48 if (busy != this.toolkitThreadBusy) {
50 this.toolkitThreadBusy = busy;
52 this.toolkitThreadBusy = busy;
54 Clazz.overrideMethod (c$, "run",
57 c$.getShutdownEvent = Clazz.defineMethod (c$, "getShutdownEvent",
59 return ((Clazz.isClassDefined ("jssun.awt.AWTAutoShutdown$1") ? 0 : jssun.awt.AWTAutoShutdown.$AWTAutoShutdown$1$ ()), Clazz.innerTypeInstance (jssun.awt.AWTAutoShutdown$1, this, null, jssun.awt.AWTAutoShutdown.getInstance (), 0));
61 Clazz.defineMethod (c$, "activateBlockerThread",
64 Clazz.defineMethod (c$, "registerPeer",
65 function (target, peer) {
66 this.peerMap.put (target, peer);
67 this.notifyPeerMapUpdated ();
69 Clazz.defineMethod (c$, "unregisterPeer",
70 function (target, peer) {
71 if (this.peerMap.get (target) === peer) {
72 this.peerMap.remove (target);
74 Clazz.defineMethod (c$, "getPeer",
76 return this.peerMap.get (target);
78 Clazz.defineMethod (c$, "dumpPeers",
80 aLog.fine ("Mapped peers:");
81 for (var key, $key = this.peerMap.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) {
82 aLog.fine (key + "->" + this.peerMap.get (key));
84 }, "java.util.logging.Logger");
85 c$.$AWTAutoShutdown$1$ = function () {
87 c$ = Clazz.declareAnonymous (jssun.awt, "AWTAutoShutdown$1", java.awt.AWTEvent);
90 Clazz.defineStatics (c$,