JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / javajs / swing / AbstractButton.js
1 Clazz.declarePackage ("javajs.swing");
2 Clazz.load (["javajs.api.SC", "javajs.swing.JComponent"], "javajs.swing.AbstractButton", null, function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.itemListener = null;
5 this.applet = null;
6 this.htmlName = null;
7 this.selected = false;
8 this.popupMenu = null;
9 this.icon = null;
10 Clazz.instantialize (this, arguments);
11 }, javajs.swing, "AbstractButton", javajs.swing.JComponent, javajs.api.SC);
12 Clazz.makeConstructor (c$, 
13 function (type) {
14 Clazz.superConstructor (this, javajs.swing.AbstractButton, [type]);
15 this.enabled = true;
16 }, "~S");
17 Clazz.overrideMethod (c$, "setSelected", 
18 function (selected) {
19 this.selected = selected;
20 {
21 SwingController.setSelected(this);
22 }}, "~B");
23 Clazz.overrideMethod (c$, "isSelected", 
24 function () {
25 return this.selected;
26 });
27 Clazz.overrideMethod (c$, "addItemListener", 
28 function (listener) {
29 this.itemListener = listener;
30 }, "~O");
31 Clazz.overrideMethod (c$, "getIcon", 
32 function () {
33 return this.icon;
34 });
35 Clazz.overrideMethod (c$, "setIcon", 
36 function (icon) {
37 this.icon = icon;
38 }, "~O");
39 Clazz.overrideMethod (c$, "init", 
40 function (text, icon, actionCommand, popupMenu) {
41 this.text = text;
42 this.icon = icon;
43 this.actionCommand = actionCommand;
44 this.popupMenu = popupMenu;
45 {
46 SwingController.initMenuItem(this);
47 }}, "~S,~O,~S,javajs.api.SC");
48 Clazz.defineMethod (c$, "getTopPopupMenu", 
49 function () {
50 return this.popupMenu;
51 });
52 Clazz.defineMethod (c$, "add", 
53 function (item) {
54 this.addComponent (item);
55 }, "javajs.api.SC");
56 Clazz.overrideMethod (c$, "insert", 
57 function (subMenu, index) {
58 this.insertComponent (subMenu, index);
59 }, "javajs.api.SC,~N");
60 Clazz.overrideMethod (c$, "getPopupMenu", 
61 function () {
62 return null;
63 });
64 Clazz.defineMethod (c$, "getMenuHTML", 
65 function () {
66 var label = (this.icon != null ? this.icon : this.text != null ? this.text : null);
67 var s = (label == null ? "" : "<li><a>" + label + "</a>" + this.htmlMenuOpener ("ul"));
68 var n = this.getComponentCount ();
69 if (n > 0) for (var i = 0; i < n; i++) s += this.getComponent (i).toHTML ();
70
71 if (label != null) s += "</ul></li>";
72 return s;
73 });
74 Clazz.defineMethod (c$, "htmlMenuOpener", 
75 function (type) {
76 return "<" + type + " id=\"" + this.id + "\"" + (this.enabled ? "" : this.getHtmlDisabled ()) + ">";
77 }, "~S");
78 Clazz.defineMethod (c$, "getHtmlDisabled", 
79 function () {
80 return " disabled=\"disabled\"";
81 });
82 });