JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / javax / swing / DefaultCellEditor.js
1 Clazz.declarePackage ("javax.swing");\r
2 Clazz.load (["java.awt.event.ActionListener", "$.ItemListener", "javax.swing.AbstractCellEditor", "javax.swing.table.TableCellEditor", "javax.swing.tree.TreeCellEditor"], "javax.swing.DefaultCellEditor", ["java.lang.Boolean", "java.awt.event.ActionEvent", "$.MouseEvent", "javax.swing.JCheckBox", "$.JComponent"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.editorComponent = null;\r
5 this.delegate = null;\r
6 this.clickCountToStart = 1;\r
7 if (!Clazz.isClassDefined ("javax.swing.DefaultCellEditor.EditorDelegate")) {\r
8 javax.swing.DefaultCellEditor.$DefaultCellEditor$EditorDelegate$ ();\r
9 }\r
10 Clazz.instantialize (this, arguments);\r
11 }, javax.swing, "DefaultCellEditor", javax.swing.AbstractCellEditor, [javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor]);\r
12 Clazz.makeConstructor (c$, \r
13 function (textField) {\r
14 Clazz.superConstructor (this, javax.swing.DefaultCellEditor, []);\r
15 this.editorComponent = textField;\r
16 this.clickCountToStart = 2;\r
17 this.delegate = ((Clazz.isClassDefined ("javax.swing.DefaultCellEditor$1") ? 0 : javax.swing.DefaultCellEditor.$DefaultCellEditor$1$ ()), Clazz.innerTypeInstance (javax.swing.DefaultCellEditor$1, this, Clazz.cloneFinals ("textField", textField)));\r
18 textField.addActionListener (this.delegate);\r
19 }, "javax.swing.JTextField");\r
20 Clazz.makeConstructor (c$, \r
21 function (checkBox) {\r
22 Clazz.superConstructor (this, javax.swing.DefaultCellEditor, []);\r
23 this.editorComponent = checkBox;\r
24 this.delegate = ((Clazz.isClassDefined ("javax.swing.DefaultCellEditor$2") ? 0 : javax.swing.DefaultCellEditor.$DefaultCellEditor$2$ ()), Clazz.innerTypeInstance (javax.swing.DefaultCellEditor$2, this, Clazz.cloneFinals ("checkBox", checkBox)));\r
25 checkBox.addActionListener (this.delegate);\r
26 checkBox.setRequestFocusEnabled (false);\r
27 }, "javax.swing.JCheckBox");\r
28 Clazz.makeConstructor (c$, \r
29 function (comboBox) {\r
30 Clazz.superConstructor (this, javax.swing.DefaultCellEditor, []);\r
31 this.editorComponent = comboBox;\r
32 comboBox.putClientProperty ("JComboBox.isTableCellEditor", Boolean.TRUE);\r
33 this.delegate = ((Clazz.isClassDefined ("javax.swing.DefaultCellEditor$3") ? 0 : javax.swing.DefaultCellEditor.$DefaultCellEditor$3$ ()), Clazz.innerTypeInstance (javax.swing.DefaultCellEditor$3, this, Clazz.cloneFinals ("comboBox", comboBox)));\r
34 comboBox.addActionListener (this.delegate);\r
35 }, "javax.swing.JComboBox");\r
36 Clazz.defineMethod (c$, "getComponent", \r
37 function () {\r
38 return this.editorComponent;\r
39 });\r
40 Clazz.defineMethod (c$, "setClickCountToStart", \r
41 function (count) {\r
42 this.clickCountToStart = count;\r
43 }, "~N");\r
44 Clazz.defineMethod (c$, "getClickCountToStart", \r
45 function () {\r
46 return this.clickCountToStart;\r
47 });\r
48 Clazz.overrideMethod (c$, "getCellEditorValue", \r
49 function () {\r
50 return this.delegate.getCellEditorValue ();\r
51 });\r
52 Clazz.overrideMethod (c$, "isCellEditable", \r
53 function (anEvent) {\r
54 return this.delegate.isCellEditable (anEvent);\r
55 }, "java.util.EventObject");\r
56 Clazz.overrideMethod (c$, "shouldSelectCell", \r
57 function (anEvent) {\r
58 return this.delegate.shouldSelectCell (anEvent);\r
59 }, "java.util.EventObject");\r
60 Clazz.overrideMethod (c$, "stopCellEditing", \r
61 function () {\r
62 return this.delegate.stopCellEditing ();\r
63 });\r
64 Clazz.overrideMethod (c$, "cancelCellEditing", \r
65 function () {\r
66 this.delegate.cancelCellEditing ();\r
67 });\r
68 Clazz.overrideMethod (c$, "getTreeCellEditorComponent", \r
69 function (tree, value, isSelected, expanded, leaf, row) {\r
70 var stringValue = tree.convertValueToText (value, isSelected, expanded, leaf, row, false);\r
71 this.delegate.setValue (stringValue);\r
72 return this.editorComponent;\r
73 }, "javax.swing.JTree,~O,~B,~B,~B,~N");\r
74 Clazz.overrideMethod (c$, "getTableCellEditorComponent", \r
75 function (table, value, isSelected, row, column) {\r
76 this.delegate.setValue (value);\r
77 if (Clazz.instanceOf (this.editorComponent, javax.swing.JCheckBox)) {\r
78 var renderer = table.getCellRenderer (row, column);\r
79 var c = renderer.getTableCellRendererComponent (table, value, isSelected, true, row, column);\r
80 if (c != null) {\r
81 this.editorComponent.setOpaque (true);\r
82 this.editorComponent.setBackground (c.getBackground ());\r
83 if (Clazz.instanceOf (c, javax.swing.JComponent)) {\r
84 this.editorComponent.setBorder ((c).getBorder ());\r
85 }} else {\r
86 this.editorComponent.setOpaque (false);\r
87 }}return this.editorComponent;\r
88 }, "javax.swing.JTable,~O,~B,~N,~N");\r
89 c$.$DefaultCellEditor$EditorDelegate$ = function () {\r
90 Clazz.pu$h(self.c$);\r
91 c$ = Clazz.decorateAsClass (function () {\r
92 Clazz.prepareCallback (this, arguments);\r
93 this.value = null;\r
94 Clazz.instantialize (this, arguments);\r
95 }, javax.swing.DefaultCellEditor, "EditorDelegate", null, [java.awt.event.ActionListener, java.awt.event.ItemListener]);\r
96 Clazz.defineMethod (c$, "getCellEditorValue", \r
97 function () {\r
98 return this.value;\r
99 });\r
100 Clazz.defineMethod (c$, "setValue", \r
101 function (a) {\r
102 this.value = a;\r
103 }, "~O");\r
104 Clazz.defineMethod (c$, "isCellEditable", \r
105 function (a) {\r
106 if (Clazz.instanceOf (a, java.awt.event.MouseEvent)) {\r
107 return (a).getClickCount () >= this.b$["javax.swing.DefaultCellEditor"].clickCountToStart;\r
108 }return true;\r
109 }, "java.util.EventObject");\r
110 Clazz.defineMethod (c$, "shouldSelectCell", \r
111 function (a) {\r
112 return true;\r
113 }, "java.util.EventObject");\r
114 Clazz.defineMethod (c$, "startCellEditing", \r
115 function (a) {\r
116 return true;\r
117 }, "java.util.EventObject");\r
118 Clazz.defineMethod (c$, "stopCellEditing", \r
119 function () {\r
120 this.b$["javax.swing.DefaultCellEditor"].fireEditingStopped ();\r
121 return true;\r
122 });\r
123 Clazz.defineMethod (c$, "cancelCellEditing", \r
124 function () {\r
125 this.b$["javax.swing.DefaultCellEditor"].fireEditingCanceled ();\r
126 });\r
127 Clazz.overrideMethod (c$, "actionPerformed", \r
128 function (a) {\r
129 this.b$["javax.swing.DefaultCellEditor"].stopCellEditing ();\r
130 }, "java.awt.event.ActionEvent");\r
131 Clazz.overrideMethod (c$, "itemStateChanged", \r
132 function (a) {\r
133 this.b$["javax.swing.DefaultCellEditor"].stopCellEditing ();\r
134 }, "java.awt.event.ItemEvent");\r
135 c$ = Clazz.p0p ();\r
136 };\r
137 c$.$DefaultCellEditor$1$ = function () {\r
138 Clazz.pu$h(self.c$);\r
139 c$ = Clazz.declareAnonymous (javax.swing, "DefaultCellEditor$1", javax.swing.DefaultCellEditor.EditorDelegate);\r
140 Clazz.defineMethod (c$, "setValue", \r
141 function (value) {\r
142 this.f$.textField.setText ((value != null) ? value.toString () : "");\r
143 }, "~O");\r
144 Clazz.defineMethod (c$, "getCellEditorValue", \r
145 function () {\r
146 return this.f$.textField.getText ();\r
147 });\r
148 c$ = Clazz.p0p ();\r
149 };\r
150 c$.$DefaultCellEditor$2$ = function () {\r
151 Clazz.pu$h(self.c$);\r
152 c$ = Clazz.declareAnonymous (javax.swing, "DefaultCellEditor$2", javax.swing.DefaultCellEditor.EditorDelegate);\r
153 Clazz.defineMethod (c$, "setValue", \r
154 function (value) {\r
155 var selected = false;\r
156 if (Clazz.instanceOf (value, Boolean)) {\r
157 selected = (value).booleanValue ();\r
158 } else if (Clazz.instanceOf (value, String)) {\r
159 selected = value.equals ("true");\r
160 }this.f$.checkBox.setSelected (selected);\r
161 }, "~O");\r
162 Clazz.defineMethod (c$, "getCellEditorValue", \r
163 function () {\r
164 return Boolean.$valueOf (this.f$.checkBox.isSelected ());\r
165 });\r
166 c$ = Clazz.p0p ();\r
167 };\r
168 c$.$DefaultCellEditor$3$ = function () {\r
169 Clazz.pu$h(self.c$);\r
170 c$ = Clazz.declareAnonymous (javax.swing, "DefaultCellEditor$3", javax.swing.DefaultCellEditor.EditorDelegate);\r
171 Clazz.defineMethod (c$, "setValue", \r
172 function (value) {\r
173 this.f$.comboBox.setSelectedItem (value);\r
174 }, "~O");\r
175 Clazz.defineMethod (c$, "getCellEditorValue", \r
176 function () {\r
177 return this.f$.comboBox.getSelectedItem ();\r
178 });\r
179 Clazz.defineMethod (c$, "shouldSelectCell", \r
180 function (anEvent) {\r
181 if (Clazz.instanceOf (anEvent, java.awt.event.MouseEvent)) {\r
182 var e = anEvent;\r
183 return e.getID () != 506;\r
184 }return true;\r
185 }, "java.util.EventObject");\r
186 Clazz.defineMethod (c$, "stopCellEditing", \r
187 function () {\r
188 if (this.f$.comboBox.isEditable ()) {\r
189 this.f$.comboBox.actionPerformed ( new java.awt.event.ActionEvent (this.b$["javax.swing.DefaultCellEditor"], 0, ""));\r
190 }return Clazz.superCall (this, javax.swing.DefaultCellEditor$3, "stopCellEditing", []);\r
191 });\r
192 c$ = Clazz.p0p ();\r
193 };\r
194 });\r