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