1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["java.util.Hashtable", "java.util.Locale"], "javax.swing.UIDefaults", ["java.lang.Boolean", "$.Error", "java.util.HashMap", "$.Vector", "java.awt.Color", "$.Dimension", "$.Font", "$.Insets", "javax.swing.Icon", "$.SwingUtilities", "javax.swing.border.Border", "javax.swing.event.SwingPropertyChangeSupport", "swingjs.JSToolkit"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.changeSupport = null;
5 this.resourceBundles = null;
6 this.defaultLocale = null;
7 this.resourceCache = null;
8 Clazz.instantialize (this, arguments);
9 }, javax.swing, "UIDefaults", java.util.Hashtable);
10 Clazz.prepareFields (c$, function () {
11 this.defaultLocale = java.util.Locale.getDefault ();
13 Clazz.makeConstructor (c$,
15 this.construct (700, .75);
17 Clazz.makeConstructor (c$,
18 function (initialCapacity, loadFactor) {
19 Clazz.superConstructor (this, javax.swing.UIDefaults, [initialCapacity, loadFactor]);
20 this.resourceCache = new java.util.HashMap ();
22 Clazz.makeConstructor (c$,
23 function (keyValueList) {
24 Clazz.superConstructor (this, javax.swing.UIDefaults, [Clazz.doubleToInt (keyValueList.length / 2)]);
25 for (var i = 0; i < keyValueList.length; i += 2) {
26 Clazz.superCall (this, javax.swing.UIDefaults, "put", [keyValueList[i], keyValueList[i + 1]]);
29 Clazz.defineMethod (c$, "get",
31 var value = this.getFromHashtable (key);
32 return (value != null) ? value : this.getFromResourceBundle (key, null);
34 Clazz.defineMethod (c$, "getFromHashtable",
36 var value = Clazz.superCall (this, javax.swing.UIDefaults, "get", [key]);
37 if (value == null && (Clazz.instanceOf (key, String))) {
39 if (skey.endsWith (".font") || skey.endsWith (".background") || skey.endsWith (".foreground")) value = Clazz.superCall (this, javax.swing.UIDefaults, "get", ["*" + skey.substring (skey.lastIndexOf ("."))]);
40 }if ((value !== javax.swing.UIDefaults.PENDING) && !(Clazz.instanceOf (value, javax.swing.UIDefaults.ActiveValue)) && !(Clazz.instanceOf (value, javax.swing.UIDefaults.LazyValue))) {
42 }if (!(Clazz.instanceOf (value, javax.swing.UIDefaults.ActiveValue))) {
44 }if (Clazz.instanceOf (value, javax.swing.UIDefaults.LazyValue)) {
46 value = (value).createValue (this);
49 Clazz.superCall (this, javax.swing.UIDefaults, "remove", [key]);
51 Clazz.superCall (this, javax.swing.UIDefaults, "put", [key, value]);
54 value = (value).createValue (this);
57 Clazz.defineMethod (c$, "get",
59 var value = this.getFromHashtable (key);
60 return (value != null) ? value : this.getFromResourceBundle (key, l);
61 }, "~O,java.util.Locale");
62 Clazz.defineMethod (c$, "getFromResourceBundle",
64 if (this.resourceBundles == null || this.resourceBundles.isEmpty () || !(Clazz.instanceOf (key, String))) {
67 if (this.defaultLocale == null) return null;
68 else l = this.defaultLocale;
70 return this.getResourceCache (l).get (key);
71 }}, "~O,java.util.Locale");
72 Clazz.defineMethod (c$, "getResourceCache",
75 }, "java.util.Locale");
76 Clazz.defineMethod (c$, "put",
77 function (key, value) {
78 var oldValue = (value == null) ? Clazz.superCall (this, javax.swing.UIDefaults, "remove", [key]) : Clazz.superCall (this, javax.swing.UIDefaults, "put", [key, value]);
79 if (Clazz.instanceOf (key, String)) {
80 this.firePropertyChange (key, oldValue, value);
83 Clazz.defineMethod (c$, "putDefaults",
84 function (keyValueList) {
85 for (var i = 0, max = keyValueList.length; i < max; i += 2) {
86 var value = keyValueList[i + 1];
88 Clazz.superCall (this, javax.swing.UIDefaults, "remove", [keyValueList[i]]);
90 Clazz.superCall (this, javax.swing.UIDefaults, "put", [keyValueList[i], value]);
92 this.firePropertyChange ("UIDefaults", null, null);
94 Clazz.defineMethod (c$, "getFont",
96 var value = this.get (key);
97 return (Clazz.instanceOf (value, java.awt.Font)) ? value : null;
99 Clazz.defineMethod (c$, "getFont",
101 var value = this.get (key, l);
102 return (Clazz.instanceOf (value, java.awt.Font)) ? value : null;
103 }, "~O,java.util.Locale");
104 Clazz.defineMethod (c$, "getColor",
106 var value = this.get (key);
107 return (Clazz.instanceOf (value, java.awt.Color)) ? value : null;
109 Clazz.defineMethod (c$, "getColor",
111 var value = this.get (key, l);
112 return (Clazz.instanceOf (value, java.awt.Color)) ? value : null;
113 }, "~O,java.util.Locale");
114 Clazz.defineMethod (c$, "getIcon",
116 var value = this.get (key);
117 return (Clazz.instanceOf (value, javax.swing.Icon)) ? value : null;
119 Clazz.defineMethod (c$, "getIcon",
121 var value = this.get (key, l);
122 return (Clazz.instanceOf (value, javax.swing.Icon)) ? value : null;
123 }, "~O,java.util.Locale");
124 Clazz.defineMethod (c$, "getBorder",
126 var value = this.get (key);
127 return (Clazz.instanceOf (value, javax.swing.border.Border)) ? value : null;
129 Clazz.defineMethod (c$, "getBorder",
131 var value = this.get (key, l);
132 return (Clazz.instanceOf (value, javax.swing.border.Border)) ? value : null;
133 }, "~O,java.util.Locale");
134 Clazz.defineMethod (c$, "getString",
136 var value = this.get (key);
137 return (Clazz.instanceOf (value, String)) ? value : null;
139 Clazz.defineMethod (c$, "getString",
141 var value = this.get (key, l);
142 return (Clazz.instanceOf (value, String)) ? value : null;
143 }, "~O,java.util.Locale");
144 Clazz.defineMethod (c$, "getInt",
146 var value = this.get (key);
147 return (Clazz.instanceOf (value, Integer)) ? (value).intValue () : 0;
149 Clazz.defineMethod (c$, "getInt",
151 var value = this.get (key, l);
152 return (Clazz.instanceOf (value, Integer)) ? (value).intValue () : 0;
153 }, "~O,java.util.Locale");
154 Clazz.defineMethod (c$, "getBoolean",
156 var value = this.get (key);
157 return (Clazz.instanceOf (value, Boolean)) ? (value).booleanValue () : false;
159 Clazz.defineMethod (c$, "getBoolean",
161 var value = this.get (key, l);
162 return (Clazz.instanceOf (value, Boolean)) ? (value).booleanValue () : false;
163 }, "~O,java.util.Locale");
164 Clazz.defineMethod (c$, "getInsets",
166 var value = this.get (key);
167 return (Clazz.instanceOf (value, java.awt.Insets)) ? value : null;
169 Clazz.defineMethod (c$, "getInsets",
171 var value = this.get (key, l);
172 return (Clazz.instanceOf (value, java.awt.Insets)) ? value : null;
173 }, "~O,java.util.Locale");
174 Clazz.defineMethod (c$, "getDimension",
176 var value = this.get (key);
177 return (Clazz.instanceOf (value, java.awt.Dimension)) ? value : null;
179 Clazz.defineMethod (c$, "getDimension",
181 var value = this.get (key, l);
182 return (Clazz.instanceOf (value, java.awt.Dimension)) ? value : null;
183 }, "~O,java.util.Locale");
184 Clazz.defineMethod (c$, "getUIClass",
185 function (uiClassID, uiClassLoader) {
187 var className = this.get (uiClassID);
188 if (className != null) {
189 var cls = this.get (className);
191 if (uiClassLoader == null) {
192 cls = javax.swing.SwingUtilities.loadSystemClass (className);
194 cls = uiClassLoader.loadClass (className);
196 this.put (className, cls);
199 if (Clazz.exceptionOf (e$$, ClassNotFoundException)) {
204 } else if (Clazz.exceptionOf (e$$, ClassCastException)) {
214 }, "~S,ClassLoader");
215 Clazz.defineMethod (c$, "getUIClass",
216 function (uiClassID) {
217 return this.getUIClass (uiClassID, null);
219 Clazz.defineMethod (c$, "getUIError",
221 System.err.println ("UIDefaults.getUI() failed: " + msg);
225 e.printStackTrace ();
228 Clazz.defineMethod (c$, "getUI",
230 return swingjs.JSToolkit.getComponentUI (target);
231 }, "javax.swing.JComponent");
232 Clazz.defineMethod (c$, "addPropertyChangeListener",
233 function (listener) {
234 if (this.changeSupport == null) {
235 this.changeSupport = new javax.swing.event.SwingPropertyChangeSupport (this);
236 }this.changeSupport.addPropertyChangeListener (listener);
237 }, "java.beans.PropertyChangeListener");
238 Clazz.defineMethod (c$, "removePropertyChangeListener",
239 function (listener) {
240 if (this.changeSupport != null) {
241 this.changeSupport.removePropertyChangeListener (listener);
242 }}, "java.beans.PropertyChangeListener");
243 Clazz.defineMethod (c$, "getPropertyChangeListeners",
245 if (this.changeSupport == null) {
246 return new Array (0);
247 }return this.changeSupport.getPropertyChangeListeners ();
249 Clazz.defineMethod (c$, "firePropertyChange",
250 function (propertyName, oldValue, newValue) {
251 if (this.changeSupport != null) {
252 this.changeSupport.firePropertyChange (propertyName, oldValue, newValue);
254 Clazz.defineMethod (c$, "addResourceBundle",
255 function (bundleName) {
256 if (bundleName == null) {
258 }if (this.resourceBundles == null) {
259 this.resourceBundles = new java.util.Vector (5);
260 }if (!this.resourceBundles.contains (bundleName)) {
261 this.resourceBundles.add (bundleName);
262 this.resourceCache.clear ();
264 Clazz.defineMethod (c$, "removeResourceBundle",
265 function (bundleName) {
266 if (this.resourceBundles != null) {
267 this.resourceBundles.remove (bundleName);
268 }this.resourceCache.clear ();
270 Clazz.defineMethod (c$, "setDefaultLocale",
272 this.defaultLocale = l;
273 }, "java.util.Locale");
274 Clazz.defineMethod (c$, "getDefaultLocale",
276 return this.defaultLocale;
278 Clazz.declareInterface (javax.swing.UIDefaults, "LazyValue");
279 Clazz.declareInterface (javax.swing.UIDefaults, "ActiveValue");
280 c$.PENDING = c$.prototype.PENDING = String.instantialize ("Pending");