JAL-1807 Bob
[jalviewjs.git] / site / j2s / swingjs / plaf / JSButtonUI.js
1 Clazz.declarePackage ("swingjs.plaf");
2 Clazz.load (["swingjs.plaf.JSComponentUI"], "swingjs.plaf.JSButtonUI", ["javax.swing.LookAndFeel", "$.UIManager", "javax.swing.plaf.UIResource", "swingjs.api.DOMNode", "swingjs.plaf.JSButtonListener"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.domBtn = null;
5 this.shiftOffset = 0;
6 this.defaultTextShiftOffset = 0;
7 Clazz.instantialize (this, arguments);
8 }, swingjs.plaf, "JSButtonUI", swingjs.plaf.JSComponentUI);
9 Clazz.overrideMethod (c$, "getDOMObject", 
10 function () {
11 if (this.domNode == null) this.domBtn = this.enableNode = this.valueNode = this.domNode = this.createDOMObject ("input", this.id, ["type", "button"]);
12 this.setCssFont (swingjs.api.DOMNode.setAttr (this.domNode, "value", (this.c).getText ()), this.c.getFont ());
13 return this.domNode;
14 });
15 Clazz.defineMethod (c$, "verifyButtonClick", 
16 function (isRelease) {
17 return true;
18 }, "~B");
19 Clazz.overrideMethod (c$, "installJSUI", 
20 function () {
21 this.installDefaults (this.c);
22 this.installListeners (this.c);
23 this.installKeyboardActions (this.c);
24 });
25 Clazz.overrideMethod (c$, "uninstallJSUI", 
26 function () {
27 this.uninstallKeyboardActions (this.c);
28 this.uninstallListeners (this.c);
29 });
30 Clazz.defineMethod (c$, "installListeners", 
31 function (b) {
32 var listener =  new swingjs.plaf.JSButtonListener (b);
33 if (listener != null) {
34 b.addMouseListener (listener);
35 b.addMouseMotionListener (listener);
36 b.addFocusListener (listener);
37 b.addPropertyChangeListener (listener);
38 b.addChangeListener (listener);
39 }}, "javax.swing.AbstractButton");
40 Clazz.defineMethod (c$, "uninstallListeners", 
41 function (b) {
42 var listener = this.getButtonListener (b);
43 if (listener != null) {
44 b.removeMouseListener (listener);
45 b.removeMouseMotionListener (listener);
46 b.removeFocusListener (listener);
47 b.removeChangeListener (listener);
48 b.removePropertyChangeListener (listener);
49 }}, "javax.swing.AbstractButton");
50 Clazz.defineMethod (c$, "installKeyboardActions", 
51 function (b) {
52 var listener = this.getButtonListener (b);
53 if (listener != null) {
54 listener.installKeyboardActions (b);
55 }}, "javax.swing.AbstractButton");
56 Clazz.defineMethod (c$, "uninstallKeyboardActions", 
57 function (b) {
58 var listener = this.getButtonListener (b);
59 if (listener != null) {
60 listener.uninstallKeyboardActions (b);
61 }}, "javax.swing.AbstractButton");
62 Clazz.defineMethod (c$, "getButtonListener", 
63 function (b) {
64 var listeners = b.getMouseMotionListeners ();
65 if (listeners != null) {
66 for (var counter = 0; counter < listeners.length; counter++) {
67 if (Clazz.instanceOf (listeners[counter], swingjs.plaf.JSButtonListener)) {
68 return listeners[counter];
69 }}
70 }return null;
71 }, "javax.swing.AbstractButton");
72 Clazz.defineMethod (c$, "getPropertyPrefix", 
73 function () {
74 return "Button.";
75 });
76 Clazz.defineMethod (c$, "installDefaults", 
77 function (b) {
78 var pp = this.getPropertyPrefix ();
79 this.defaultTextShiftOffset = javax.swing.UIManager.getInt (pp + "textShiftOffset");
80 if (b.getMargin () == null || (Clazz.instanceOf (b.getMargin (), javax.swing.plaf.UIResource))) {
81 b.setMargin (javax.swing.UIManager.getInsets (pp + "margin"));
82 }javax.swing.LookAndFeel.installColorsAndFont (b, pp + "background", pp + "foreground", pp + "font");
83 javax.swing.LookAndFeel.installProperty (b, "iconTextGap",  new Integer (4));
84 }, "javax.swing.AbstractButton");
85 });