JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / jssun / awt / AWTAutoShutdown.js
1 Clazz.declarePackage ("jssun.awt");\r
2 Clazz.load (["java.util.HashSet", "$.IdentityHashMap"], "jssun.awt.AWTAutoShutdown", ["java.awt.AWTEvent"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.busyThreadSet = null;\r
5 this.toolkitThreadBusy = false;\r
6 this.peerMap = null;\r
7 Clazz.instantialize (this, arguments);\r
8 }, jssun.awt, "AWTAutoShutdown", null, Runnable);\r
9 Clazz.prepareFields (c$, function () {\r
10 this.busyThreadSet =  new java.util.HashSet (7);\r
11 this.peerMap =  new java.util.IdentityHashMap ();\r
12 });\r
13 Clazz.makeConstructor (c$, \r
14  function () {\r
15 });\r
16 c$.getInstance = Clazz.defineMethod (c$, "getInstance", \r
17 function () {\r
18 return (jssun.awt.AWTAutoShutdown.theInstance == null ? (jssun.awt.AWTAutoShutdown.theInstance =  new jssun.awt.AWTAutoShutdown ()) : jssun.awt.AWTAutoShutdown.theInstance);\r
19 });\r
20 c$.notifyToolkitThreadBusy = Clazz.defineMethod (c$, "notifyToolkitThreadBusy", \r
21 function () {\r
22 jssun.awt.AWTAutoShutdown.getInstance ().setToolkitBusy (true);\r
23 });\r
24 c$.notifyToolkitThreadFree = Clazz.defineMethod (c$, "notifyToolkitThreadFree", \r
25 function () {\r
26 jssun.awt.AWTAutoShutdown.getInstance ().setToolkitBusy (false);\r
27 });\r
28 Clazz.defineMethod (c$, "notifyThreadBusy", \r
29 function (thread) {\r
30 this.busyThreadSet.add (thread);\r
31 }, "Thread");\r
32 Clazz.defineMethod (c$, "notifyThreadFree", \r
33 function (thread) {\r
34 this.busyThreadSet.remove (thread);\r
35 }, "Thread");\r
36 Clazz.defineMethod (c$, "notifyPeerMapUpdated", \r
37 function () {\r
38 if (!this.isReadyToShutdown ()) {\r
39 this.activateBlockerThread ();\r
40 }});\r
41 Clazz.defineMethod (c$, "isReadyToShutdown", \r
42  function () {\r
43 return (!this.toolkitThreadBusy && this.peerMap.isEmpty () && this.busyThreadSet.isEmpty ());\r
44 });\r
45 Clazz.defineMethod (c$, "setToolkitBusy", \r
46  function (busy) {\r
47 if (busy != this.toolkitThreadBusy) {\r
48 if (busy != this.toolkitThreadBusy) {\r
49 if (busy) {\r
50 this.toolkitThreadBusy = busy;\r
51 } else {\r
52 this.toolkitThreadBusy = busy;\r
53 }}}}, "~B");\r
54 Clazz.overrideMethod (c$, "run", \r
55 function () {\r
56 });\r
57 c$.getShutdownEvent = Clazz.defineMethod (c$, "getShutdownEvent", \r
58 function () {\r
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));\r
60 });\r
61 Clazz.defineMethod (c$, "activateBlockerThread", \r
62  function () {\r
63 });\r
64 Clazz.defineMethod (c$, "registerPeer", \r
65 function (target, peer) {\r
66 this.peerMap.put (target, peer);\r
67 this.notifyPeerMapUpdated ();\r
68 }, "~O,~O");\r
69 Clazz.defineMethod (c$, "unregisterPeer", \r
70 function (target, peer) {\r
71 if (this.peerMap.get (target) === peer) {\r
72 this.peerMap.remove (target);\r
73 }}, "~O,~O");\r
74 Clazz.defineMethod (c$, "getPeer", \r
75 function (target) {\r
76 return this.peerMap.get (target);\r
77 }, "~O");\r
78 Clazz.defineMethod (c$, "dumpPeers", \r
79 function (aLog) {\r
80 aLog.fine ("Mapped peers:");\r
81 for (var key, $key = this.peerMap.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) {\r
82 aLog.fine (key + "->" + this.peerMap.get (key));\r
83 }\r
84 }, "java.util.logging.Logger");\r
85 c$.$AWTAutoShutdown$1$ = function () {\r
86 Clazz.pu$h(self.c$);\r
87 c$ = Clazz.declareAnonymous (jssun.awt, "AWTAutoShutdown$1", java.awt.AWTEvent);\r
88 c$ = Clazz.p0p ();\r
89 };\r
90 Clazz.defineStatics (c$,\r
91 "theInstance", null);\r
92 });\r