1 Clazz.declarePackage ("swingjs.plaf");
2 Clazz.load (["java.awt.event.FocusListener", "$.MouseListener", "$.MouseMotionListener", "java.beans.PropertyChangeListener", "javax.swing.event.ChangeListener", "jssun.swing.UIAction"], "swingjs.plaf.JSButtonListener", ["javax.swing.AbstractButton", "$.KeyStroke", "$.SwingUtilities", "javax.swing.plaf.ComponentInputMapUIResource", "swingjs.plaf.LazyActionMap"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.lastPressedTimestamp = -1;
5 this.shouldDiscardRelease = false;
7 Clazz.instantialize (this, arguments);
8 }, swingjs.plaf, "JSButtonListener", null, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.FocusListener, javax.swing.event.ChangeListener, java.beans.PropertyChangeListener]);
9 c$.loadActionMap = Clazz.defineMethod (c$, "loadActionMap",
11 map.put ( new swingjs.plaf.JSButtonListener.Actions ("pressed"));
12 map.put ( new swingjs.plaf.JSButtonListener.Actions ("released"));
13 }, "swingjs.plaf.LazyActionMap");
14 Clazz.makeConstructor (c$,
17 }, "javax.swing.AbstractButton");
18 Clazz.overrideMethod (c$, "propertyChange",
20 var prop = e.getPropertyName ();
21 if (prop === "mnemonic") {
22 this.updateMnemonicBinding (e.getSource ());
23 } else if (prop === "contentAreaFilled") {
24 this.checkOpacity (e.getSource ());
25 } else if (prop === "text" || "font" === prop || "foreground" === prop) {
26 var b = e.getSource ();
27 (b.getUI ()).notifyPropertyChanged (prop);
28 }}, "java.beans.PropertyChangeEvent");
29 Clazz.defineMethod (c$, "checkOpacity",
31 b.setOpaque (b.isContentAreaFilled ());
32 }, "javax.swing.AbstractButton");
33 Clazz.defineMethod (c$, "installKeyboardActions",
36 this.updateMnemonicBinding (b);
37 swingjs.plaf.LazyActionMap.installLazyActionMap (c, swingjs.plaf.JSButtonListener, "Button.actionMap");
38 var km = this.getInputMap (0, c);
39 javax.swing.SwingUtilities.replaceUIInputMap (c, 0, km);
40 }, "javax.swing.JComponent");
41 Clazz.defineMethod (c$, "uninstallKeyboardActions",
43 javax.swing.SwingUtilities.replaceUIInputMap (c, 2, null);
44 javax.swing.SwingUtilities.replaceUIInputMap (c, 0, null);
45 javax.swing.SwingUtilities.replaceUIActionMap (c, null);
46 }, "javax.swing.JComponent");
47 Clazz.defineMethod (c$, "getInputMap",
48 function (condition, c) {
50 }, "~N,javax.swing.JComponent");
51 Clazz.defineMethod (c$, "updateMnemonicBinding",
53 var m = b.getMnemonic ();
55 var map = javax.swing.SwingUtilities.getUIInputMap (b, 2);
57 map = new javax.swing.plaf.ComponentInputMapUIResource (b);
58 javax.swing.SwingUtilities.replaceUIInputMap (b, 2, map);
60 map.put (javax.swing.KeyStroke.getKeyStroke (m, 8, false), "pressed");
61 map.put (javax.swing.KeyStroke.getKeyStroke (m, 8, true), "released");
62 map.put (javax.swing.KeyStroke.getKeyStroke (m, 0, true), "released");
64 var map = javax.swing.SwingUtilities.getUIInputMap (b, 2);
67 }}}, "javax.swing.AbstractButton");
68 Clazz.overrideMethod (c$, "stateChanged",
70 var b = e.getSource ();
72 }, "javax.swing.event.ChangeEvent");
73 Clazz.overrideMethod (c$, "focusGained",
75 }, "java.awt.event.FocusEvent");
76 Clazz.overrideMethod (c$, "focusLost",
78 var b = e.getSource ();
79 var model = b.getModel ();
80 model.setArmed (false);
81 model.setPressed (false);
82 }, "java.awt.event.FocusEvent");
83 Clazz.overrideMethod (c$, "mouseMoved",
85 }, "java.awt.event.MouseEvent");
86 Clazz.overrideMethod (c$, "mouseDragged",
88 }, "java.awt.event.MouseEvent");
89 Clazz.overrideMethod (c$, "mouseClicked",
91 }, "java.awt.event.MouseEvent");
92 Clazz.overrideMethod (c$, "mousePressed",
94 if (javax.swing.SwingUtilities.isLeftMouseButton (e)) {
95 var b = e.getSource ();
96 if (!b.contains (e.getX (), e.getY ())) return;
97 (b.getUI ()).verifyButtonClick (false);
98 var multiClickThreshhold = b.getMultiClickThreshhold ();
99 var lastTime = this.lastPressedTimestamp;
100 var currentTime = this.lastPressedTimestamp = e.getWhen ();
101 if (lastTime != -1 && currentTime - lastTime < multiClickThreshhold) {
102 this.shouldDiscardRelease = true;
104 }var model = b.getModel ();
105 if (!model.isEnabled ()) {
107 }if (!model.isArmed ()) {
108 model.setArmed (true);
109 }model.setPressed (true);
110 if (!b.hasFocus () && b.isRequestFocusEnabled ()) {
112 }}}, "java.awt.event.MouseEvent");
113 Clazz.overrideMethod (c$, "mouseReleased",
115 if (javax.swing.SwingUtilities.isLeftMouseButton (e)) {
116 if (this.shouldDiscardRelease) {
117 this.shouldDiscardRelease = false;
119 }var b = e.getSource ();
120 if (!(b.getUI ()).verifyButtonClick (true)) return;
121 var model = b.getModel ();
122 model.setPressed (false);
123 model.setArmed (false);
124 }}, "java.awt.event.MouseEvent");
125 Clazz.overrideMethod (c$, "mouseEntered",
127 var b = e.getSource ();
128 var model = b.getModel ();
129 if (b.isRolloverEnabled () && !javax.swing.SwingUtilities.isLeftMouseButton (e)) {
130 model.setRollover (true);
131 }if (model.isPressed ()) model.setArmed (true);
132 }, "java.awt.event.MouseEvent");
133 Clazz.overrideMethod (c$, "mouseExited",
135 var b = e.getSource ();
136 var model = b.getModel ();
137 if (b.isRolloverEnabled ()) {
138 model.setRollover (false);
139 }model.setArmed (false);
140 }, "java.awt.event.MouseEvent");
142 c$ = Clazz.declareType (swingjs.plaf.JSButtonListener, "Actions", jssun.swing.UIAction);
143 Clazz.overrideMethod (c$, "actionPerformed",
145 var b = a.getSource ();
146 var c = this.getName ();
147 if (c === "pressed") {
148 var d = b.getModel ();
151 if (!b.hasFocus ()) {
153 }} else if (c === "released") {
154 var d = b.getModel ();
155 d.setPressed (false);
157 }}, "java.awt.event.ActionEvent");
158 Clazz.defineMethod (c$, "isEnabled",
160 if (a != null && (Clazz.instanceOf (a, javax.swing.AbstractButton)) && !(a).getModel ().isEnabled ()) {
165 Clazz.defineStatics (c$,
167 "RELEASE", "released");