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