JAL-1807 Bob
[jalviewjs.git] / site / j2s / swingjs / plaf / JSRadioButtonUI.js
1 Clazz.declarePackage ("swingjs.plaf");
2 Clazz.load (["swingjs.plaf.JSButtonUI"], "swingjs.plaf.JSRadioButtonUI", ["java.util.HashMap", "javax.swing.DefaultButtonModel", "swingjs.api.DOMNode"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.label = null;
5 Clazz.instantialize (this, arguments);
6 }, swingjs.plaf, "JSRadioButtonUI", swingjs.plaf.JSButtonUI);
7 Clazz.overrideMethod (c$, "getDOMObject", 
8 function () {
9 return this.getButtonObject ("radio");
10 });
11 Clazz.overrideMethod (c$, "getPropertyPrefix", 
12 function () {
13 return "RadioButton.";
14 });
15 Clazz.overrideMethod (c$, "setHTMLSize", 
16 function (obj, addCSS) {
17 swingjs.api.DOMNode.setStyles (this.domBtn, ["position", null]);
18 swingjs.api.DOMNode.setStyles (this.label, ["position", null]);
19 var d = this.setHTMLSize1 (obj, addCSS, false);
20 swingjs.api.DOMNode.setStyles (this.domBtn, ["position", "absolute"]);
21 swingjs.api.DOMNode.setStyles (this.label, ["position", "absolute"]);
22 return d;
23 }, "swingjs.api.DOMNode,~B");
24 Clazz.defineMethod (c$, "getButtonObject", 
25 function (myType) {
26 var b = this.c;
27 var isNew = false;
28 var doAll = false;
29 if (this.domNode == null) {
30 doAll = true;
31 if (swingjs.plaf.JSRadioButtonUI.groupNames == null) swingjs.plaf.JSRadioButtonUI.groupNames =  new java.util.HashMap ();
32 var bg = null;
33 var name = this.id;
34 isNew = true;
35 if (Clazz.instanceOf (b.getModel (), javax.swing.DefaultButtonModel)) {
36 bg = (b.getModel ()).getGroup ();
37 name = swingjs.plaf.JSRadioButtonUI.groupNames.get (bg);
38 if (name == null) swingjs.plaf.JSRadioButtonUI.groupNames.put (bg, name = this.id);
39  else isNew = false;
40 }this.domBtn = this.enableNode = this.createDOMObject ("input", this.id, ["type", myType, "name", name]);
41 this.label = this.textNode = this.createDOMObject ("label", this.id + "l", ["htmlFor", this.id]);
42 }if (b.isSelected () || isNew) swingjs.api.DOMNode.setAttr (this.domBtn, "checked", "true");
43 this.setCssFont (swingjs.api.DOMNode.setAttr (this.label, "innerHTML", (this.c).getText ()), this.c.getFont ());
44 var drad = this.setHTMLSize1 (this.domBtn, false, false);
45 this.setHTMLSize1 (this.label, false, false);
46 var obj = this.wrap ("div", "", [this.domBtn, this.label]);
47 var dobj = this.setHTMLSize1 (obj, true, true);
48 swingjs.plaf.JSComponentUI.vCenter (this.domBtn, -75);
49 swingjs.plaf.JSComponentUI.vCenter (this.label, -50);
50 swingjs.api.DOMNode.setStyles (this.label, ["position", "absolute", "left", drad.width + "px"]);
51 swingjs.api.DOMNode.setStyles (this.domBtn, ["position", "absolute"]);
52 if (doAll) {
53 obj = this.wrap ("div", this.id + "_0", [this.domBtn, this.label]);
54 swingjs.api.DOMNode.setStyles (obj, ["position", "absolute"]);
55 } else {
56 obj = this.domNode;
57 obj.appendChild (this.domBtn);
58 obj.appendChild (this.label);
59 }return swingjs.api.DOMNode.setSize (obj, dobj.width, dobj.height);
60 }, "~S");
61 Clazz.defineStatics (c$,
62 "groupNames", null);
63 });