6635923eff36e71f4feb4a95818f0eeb4049f027
[jalviewjs.git] / site / swingjs / j2s / jssun / swing / SwingLazyValue.js
1 Clazz.declarePackage ("jssun.swing");\r
2 Clazz.load (["javax.swing.UIDefaults"], "jssun.swing.SwingLazyValue", ["java.lang.Boolean", "java.awt.Color", "javax.swing.plaf.ColorUIResource"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.className = null;\r
5 this.methodName = null;\r
6 this.args = null;\r
7 Clazz.instantialize (this, arguments);\r
8 }, jssun.swing, "SwingLazyValue", null, javax.swing.UIDefaults.LazyValue);\r
9 Clazz.makeConstructor (c$, \r
10 function (c) {\r
11 this.construct (c, Clazz.castNullAs ("String"));\r
12 }, "~S");\r
13 Clazz.makeConstructor (c$, \r
14 function (c, m) {\r
15 this.construct (c, m, null);\r
16 }, "~S,~S");\r
17 Clazz.makeConstructor (c$, \r
18 function (c, o) {\r
19 this.construct (c, null, o);\r
20 }, "~S,~A");\r
21 Clazz.makeConstructor (c$, \r
22 function (c, m, o) {\r
23 this.className = c;\r
24 this.methodName = m;\r
25 if (o != null) {\r
26 this.args = o.clone ();\r
27 }}, "~S,~S,~A");\r
28 Clazz.overrideMethod (c$, "createValue", \r
29 function (table) {\r
30 try {\r
31 var c = Clazz._4Name (this.className, true, null);\r
32 if (this.methodName != null) {\r
33 var types = this.getClassArray (this.args);\r
34 var m = c.getMethod (this.methodName, types);\r
35 return m.invoke (c, this.args);\r
36 } else {\r
37 var types = this.getClassArray (this.args);\r
38 var constructor = c.getConstructor (types);\r
39 return constructor.newInstance (this.args);\r
40 }} catch (e) {\r
41 if (Clazz.exceptionOf (e, Exception)) {\r
42 } else {\r
43 throw e;\r
44 }\r
45 }\r
46 return null;\r
47 }, "javax.swing.UIDefaults");\r
48 Clazz.defineMethod (c$, "getClassArray", \r
49  function (args) {\r
50 var types = null;\r
51 if (args != null) {\r
52 types =  new Array (args.length);\r
53 for (var i = 0; i < args.length; i++) {\r
54 if (Clazz.instanceOf (args[i], Integer)) {\r
55 types[i] = Integer.TYPE;\r
56 } else if (Clazz.instanceOf (args[i], Boolean)) {\r
57 types[i] = Boolean.TYPE;\r
58 } else if (Clazz.instanceOf (args[i], javax.swing.plaf.ColorUIResource)) {\r
59 types[i] = java.awt.Color;\r
60 } else {\r
61 types[i] = args[i].getClass ();\r
62 }}\r
63 }return types;\r
64 }, "~A");\r
65 });\r