1 Clazz.declarePackage ("jssun.awt");
\r
2 Clazz.load (["java.lang.StringBuffer", "java.util.Collections", "$.HashMap", "$.IdentityHashMap"], ["jssun.awt.AppContext", "$.MostRecentThreadAppContext", "$.MostRecentKeyValue"], ["java.lang.Thread", "java.util.HashSet", "java.beans.PropertyChangeSupport"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
5 this.threadGroup = null;
\r
6 this.changeSupport = null;
\r
7 this.$isDisposed = false;
\r
8 this.mostRecentKeyValue = null;
\r
9 this.shadowMostRecentKeyValue = null;
\r
10 Clazz.instantialize (this, arguments);
\r
11 }, jssun.awt, "AppContext");
\r
12 Clazz.prepareFields (c$, function () {
\r
13 this.table = new java.util.HashMap ();
\r
15 c$.getAppContexts = Clazz.defineMethod (c$, "getAppContexts",
\r
17 return new java.util.HashSet (jssun.awt.AppContext.threadGroup2appContext.values ());
\r
19 Clazz.defineMethod (c$, "isDisposed",
\r
21 return this.$isDisposed;
\r
23 Clazz.makeConstructor (c$,
\r
24 function (threadGroup) {
\r
25 jssun.awt.AppContext.numAppContexts++;
\r
26 this.threadGroup = threadGroup;
\r
27 jssun.awt.AppContext.threadGroup2appContext.put (threadGroup, this);
\r
29 c$.getAppContext = Clazz.defineMethod (c$, "getAppContext",
\r
31 var currentThread = Thread.currentThread ();
\r
32 var appContext = null;
\r
33 var recent = jssun.awt.AppContext.mostRecentThreadAppContext;
\r
34 if ((recent != null) && (recent.thread === currentThread)) {
\r
35 appContext = recent.appContext;
\r
37 var currentThreadGroup = currentThread.getThreadGroup ();
\r
38 var threadGroup = currentThreadGroup;
\r
39 appContext = jssun.awt.AppContext.threadGroup2appContext.get (threadGroup);
\r
40 while (appContext == null) {
\r
41 threadGroup = threadGroup.getParent ();
\r
42 if (threadGroup == null) {
\r
44 }appContext = jssun.awt.AppContext.threadGroup2appContext.get (threadGroup);
\r
46 for (var tg = currentThreadGroup; tg !== threadGroup; tg = tg.getParent ()) {
\r
47 jssun.awt.AppContext.threadGroup2appContext.put (tg, appContext);
\r
49 jssun.awt.AppContext.mostRecentThreadAppContext = new jssun.awt.MostRecentThreadAppContext (currentThread, appContext);
\r
52 c$.isMainContext = Clazz.defineMethod (c$, "isMainContext",
\r
55 }, "jssun.awt.AppContext");
\r
56 Clazz.defineMethod (c$, "dispose",
\r
59 Clazz.defineMethod (c$, "get",
\r
62 var recent = this.mostRecentKeyValue;
\r
63 if ((recent != null) && (recent.key === key)) {
\r
64 return recent.value;
\r
65 }var value = this.table.get (key);
\r
66 if (this.mostRecentKeyValue == null) {
\r
67 this.mostRecentKeyValue = new jssun.awt.MostRecentKeyValue (key, value);
\r
68 this.shadowMostRecentKeyValue = new jssun.awt.MostRecentKeyValue (key, value);
\r
70 var auxKeyValue = this.mostRecentKeyValue;
\r
71 this.shadowMostRecentKeyValue.setPair (key, value);
\r
72 this.mostRecentKeyValue = this.shadowMostRecentKeyValue;
\r
73 this.shadowMostRecentKeyValue = auxKeyValue;
\r
76 Clazz.defineMethod (c$, "put",
\r
77 function (key, value) {
\r
79 var recent = this.mostRecentKeyValue;
\r
80 if ((recent != null) && (recent.key === key)) recent.value = value;
\r
81 return this.table.put (key, value);
\r
83 Clazz.defineMethod (c$, "remove",
\r
86 var recent = this.mostRecentKeyValue;
\r
87 if ((recent != null) && (recent.key === key)) recent.value = null;
\r
88 return this.table.remove (key);
\r
90 Clazz.defineMethod (c$, "getThreadGroup",
\r
92 return this.threadGroup;
\r
94 Clazz.overrideMethod (c$, "toString",
\r
96 return this.getClass ().getName () + "[threadGroup=" + this.threadGroup.getName () + "]";
\r
98 Clazz.defineMethod (c$, "getPropertyChangeListeners",
\r
100 if (this.changeSupport == null) {
\r
101 return new Array (0);
\r
102 }return this.changeSupport.getPropertyChangeListeners ();
\r
104 Clazz.defineMethod (c$, "addPropertyChangeListener",
\r
105 function (propertyName, listener) {
\r
106 if (listener == null) {
\r
108 }if (this.changeSupport == null) {
\r
109 this.changeSupport = new java.beans.PropertyChangeSupport (this);
\r
110 }this.changeSupport.addPropertyChangeListener (propertyName, listener);
\r
111 }, "~S,java.beans.PropertyChangeListener");
\r
112 Clazz.defineMethod (c$, "removePropertyChangeListener",
\r
113 function (propertyName, listener) {
\r
114 if (listener == null || this.changeSupport == null) {
\r
116 }this.changeSupport.removePropertyChangeListener (propertyName, listener);
\r
117 }, "~S,java.beans.PropertyChangeListener");
\r
118 Clazz.defineMethod (c$, "getPropertyChangeListeners",
\r
119 function (propertyName) {
\r
120 if (this.changeSupport == null) {
\r
121 return new Array (0);
\r
122 }return this.changeSupport.getPropertyChangeListeners (propertyName);
\r
124 c$.EVENT_QUEUE_KEY = c$.prototype.EVENT_QUEUE_KEY = new StringBuffer ("EventQueue");
\r
125 c$.threadGroup2appContext = c$.prototype.threadGroup2appContext = java.util.Collections.synchronizedMap ( new java.util.IdentityHashMap ());
\r
126 Clazz.defineStatics (c$,
\r
127 "DISPOSED_PROPERTY_NAME", "disposed",
\r
128 "GUI_DISPOSED", "guidisposed",
\r
129 "numAppContexts", 0,
\r
130 "mostRecentThreadAppContext", null);
\r
131 c$ = Clazz.decorateAsClass (function () {
\r
132 this.thread = null;
\r
133 this.appContext = null;
\r
134 Clazz.instantialize (this, arguments);
\r
135 }, jssun.awt, "MostRecentThreadAppContext");
\r
136 Clazz.makeConstructor (c$,
\r
137 function (key, value) {
\r
139 this.appContext = value;
\r
140 }, "Thread,jssun.awt.AppContext");
\r
141 c$ = Clazz.decorateAsClass (function () {
\r
144 Clazz.instantialize (this, arguments);
\r
145 }, jssun.awt, "MostRecentKeyValue");
\r
146 Clazz.makeConstructor (c$,
\r
151 Clazz.defineMethod (c$, "setPair",
\r