e5556ac7cd721308421b2e7246762e1e1d5f81fc
[jalviewjs.git] / site / swingjs / j2s / jssun / awt / AWTAutoShutdown.js
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;
6 this.peerMap = null;
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 ();
12 });
13 Clazz.makeConstructor (c$, 
14  function () {
15 });
16 c$.getInstance = Clazz.defineMethod (c$, "getInstance", 
17 function () {
18 return (jssun.awt.AWTAutoShutdown.theInstance == null ? (jssun.awt.AWTAutoShutdown.theInstance =  new jssun.awt.AWTAutoShutdown ()) : jssun.awt.AWTAutoShutdown.theInstance);
19 });
20 c$.notifyToolkitThreadBusy = Clazz.defineMethod (c$, "notifyToolkitThreadBusy", 
21 function () {
22 jssun.awt.AWTAutoShutdown.getInstance ().setToolkitBusy (true);
23 });
24 c$.notifyToolkitThreadFree = Clazz.defineMethod (c$, "notifyToolkitThreadFree", 
25 function () {
26 jssun.awt.AWTAutoShutdown.getInstance ().setToolkitBusy (false);
27 });
28 Clazz.defineMethod (c$, "notifyThreadBusy", 
29 function (thread) {
30 this.busyThreadSet.add (thread);
31 }, "Thread");
32 Clazz.defineMethod (c$, "notifyThreadFree", 
33 function (thread) {
34 this.busyThreadSet.remove (thread);
35 }, "Thread");
36 Clazz.defineMethod (c$, "notifyPeerMapUpdated", 
37 function () {
38 if (!this.isReadyToShutdown ()) {
39 this.activateBlockerThread ();
40 }});
41 Clazz.defineMethod (c$, "isReadyToShutdown", 
42  function () {
43 return (!this.toolkitThreadBusy && this.peerMap.isEmpty () && this.busyThreadSet.isEmpty ());
44 });
45 Clazz.defineMethod (c$, "setToolkitBusy", 
46  function (busy) {
47 if (busy != this.toolkitThreadBusy) {
48 if (busy != this.toolkitThreadBusy) {
49 if (busy) {
50 this.toolkitThreadBusy = busy;
51 } else {
52 this.toolkitThreadBusy = busy;
53 }}}}, "~B");
54 Clazz.overrideMethod (c$, "run", 
55 function () {
56 });
57 c$.getShutdownEvent = Clazz.defineMethod (c$, "getShutdownEvent", 
58 function () {
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));
60 });
61 Clazz.defineMethod (c$, "activateBlockerThread", 
62  function () {
63 });
64 Clazz.defineMethod (c$, "registerPeer", 
65 function (target, peer) {
66 this.peerMap.put (target, peer);
67 this.notifyPeerMapUpdated ();
68 }, "~O,~O");
69 Clazz.defineMethod (c$, "unregisterPeer", 
70 function (target, peer) {
71 if (this.peerMap.get (target) === peer) {
72 this.peerMap.remove (target);
73 }}, "~O,~O");
74 Clazz.defineMethod (c$, "getPeer", 
75 function (target) {
76 return this.peerMap.get (target);
77 }, "~O");
78 Clazz.defineMethod (c$, "dumpPeers", 
79 function (aLog) {
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));
83 }
84 }, "java.util.logging.Logger");
85 c$.$AWTAutoShutdown$1$ = function () {
86 Clazz.pu$h(self.c$);
87 c$ = Clazz.declareAnonymous (jssun.awt, "AWTAutoShutdown$1", java.awt.AWTEvent);
88 c$ = Clazz.p0p ();
89 };
90 Clazz.defineStatics (c$,
91 "theInstance", null);
92 });