JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / swingjs / j2s / javax / swing / JList.js
1 Clazz.declarePackage ("javax.swing");\r
2 Clazz.load (["javax.swing.JComponent", "$.Scrollable", "javax.swing.event.ListSelectionListener"], "javax.swing.JList", ["java.lang.IllegalArgumentException", "java.awt.Component", "$.Dimension", "$.Point", "java.awt.event.MouseEvent", "javax.swing.AbstractListModel", "$.DefaultListSelectionModel", "$.JViewport", "$.SwingUtilities", "$.UIManager", "javax.swing.event.ListSelectionEvent", "javax.swing.text.Position"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.fixedCellWidth = -1;\r
5 this.fixedCellHeight = -1;\r
6 this.horizontalScrollIncrement = -1;\r
7 this.prototypeCellValue = null;\r
8 this.visibleRowCount = 8;\r
9 this.selectionForeground = null;\r
10 this.selectionBackground = null;\r
11 this.dragEnabled = false;\r
12 this.selectionModel = null;\r
13 this.dataModel = null;\r
14 this.cellRenderer = null;\r
15 this.selectionListener = null;\r
16 this.layoutOrientation = 0;\r
17 if (!Clazz.isClassDefined ("javax.swing.JList.ListSelectionHandler")) {\r
18 javax.swing.JList.$JList$ListSelectionHandler$ ();\r
19 }\r
20 Clazz.instantialize (this, arguments);\r
21 }, javax.swing, "JList", javax.swing.JComponent, javax.swing.Scrollable);\r
22 Clazz.makeConstructor (c$, \r
23 function (dataModel) {\r
24 Clazz.superConstructor (this, javax.swing.JList, []);\r
25 if (dataModel == null) {\r
26 throw  new IllegalArgumentException ("dataModel must be non null");\r
27 }this.layoutOrientation = 0;\r
28 this.dataModel = dataModel;\r
29 this.selectionModel = this.createSelectionModel ();\r
30 this.setAutoscrolls (true);\r
31 this.setOpaque (true);\r
32 this.updateUI ();\r
33 }, "javax.swing.ListModel");\r
34 Clazz.makeConstructor (c$, \r
35 function (listData) {\r
36 this.construct (((Clazz.isClassDefined ("javax.swing.JList$1") ? 0 : javax.swing.JList.$JList$1$ ()), Clazz.innerTypeInstance (javax.swing.JList$1, this, Clazz.cloneFinals ("listData", listData))));\r
37 }, "~A");\r
38 Clazz.makeConstructor (c$, \r
39 function (listData) {\r
40 this.construct (((Clazz.isClassDefined ("javax.swing.JList$2") ? 0 : javax.swing.JList.$JList$2$ ()), Clazz.innerTypeInstance (javax.swing.JList$2, this, Clazz.cloneFinals ("listData", listData))));\r
41 }, "java.util.Vector");\r
42 Clazz.makeConstructor (c$, \r
43 function () {\r
44 this.construct (((Clazz.isClassDefined ("javax.swing.JList$3") ? 0 : javax.swing.JList.$JList$3$ ()), Clazz.innerTypeInstance (javax.swing.JList$3, this, null)));\r
45 });\r
46 Clazz.overrideMethod (c$, "getUI", \r
47 function () {\r
48 return this.ui;\r
49 });\r
50 Clazz.overrideMethod (c$, "updateUI", \r
51 function () {\r
52 this.setUI (javax.swing.UIManager.getUI (this));\r
53 var renderer = this.getCellRenderer ();\r
54 if (Clazz.instanceOf (renderer, java.awt.Component)) {\r
55 javax.swing.SwingUtilities.updateComponentTreeUI (renderer);\r
56 }});\r
57 Clazz.overrideMethod (c$, "getUIClassID", \r
58 function () {\r
59 return "ListUI";\r
60 });\r
61 Clazz.defineMethod (c$, "updateFixedCellSize", \r
62  function () {\r
63 var cr = this.getCellRenderer ();\r
64 var value = this.getPrototypeCellValue ();\r
65 if ((cr != null) && (value != null)) {\r
66 var c = cr.getListCellRendererComponent (this, value, 0, false, false);\r
67 var f = c.getFont ();\r
68 c.setFont (this.getFont ());\r
69 var d = c.getPreferredSize ();\r
70 this.fixedCellWidth = d.width;\r
71 this.fixedCellHeight = d.height;\r
72 c.setFont (f);\r
73 }});\r
74 Clazz.defineMethod (c$, "getPrototypeCellValue", \r
75 function () {\r
76 return this.prototypeCellValue;\r
77 });\r
78 Clazz.defineMethod (c$, "setPrototypeCellValue", \r
79 function (prototypeCellValue) {\r
80 var oldValue = this.prototypeCellValue;\r
81 this.prototypeCellValue = prototypeCellValue;\r
82 if ((prototypeCellValue != null) && !prototypeCellValue.equals (oldValue)) {\r
83 this.updateFixedCellSize ();\r
84 }this.firePropertyChangeObject ("prototypeCellValue", oldValue, prototypeCellValue);\r
85 }, "~O");\r
86 Clazz.defineMethod (c$, "getFixedCellWidth", \r
87 function () {\r
88 return this.fixedCellWidth;\r
89 });\r
90 Clazz.defineMethod (c$, "setFixedCellWidth", \r
91 function (width) {\r
92 var oldValue = this.fixedCellWidth;\r
93 this.fixedCellWidth = width;\r
94 this.firePropertyChangeInt ("fixedCellWidth", oldValue, this.fixedCellWidth);\r
95 }, "~N");\r
96 Clazz.defineMethod (c$, "getFixedCellHeight", \r
97 function () {\r
98 return this.fixedCellHeight;\r
99 });\r
100 Clazz.defineMethod (c$, "setFixedCellHeight", \r
101 function (height) {\r
102 var oldValue = this.fixedCellHeight;\r
103 this.fixedCellHeight = height;\r
104 this.firePropertyChangeInt ("fixedCellHeight", oldValue, this.fixedCellHeight);\r
105 }, "~N");\r
106 Clazz.defineMethod (c$, "getCellRenderer", \r
107 function () {\r
108 return this.cellRenderer;\r
109 });\r
110 Clazz.defineMethod (c$, "setCellRenderer", \r
111 function (cellRenderer) {\r
112 var oldValue = this.cellRenderer;\r
113 this.cellRenderer = cellRenderer;\r
114 if ((cellRenderer != null) && !cellRenderer.equals (oldValue)) {\r
115 this.updateFixedCellSize ();\r
116 }this.firePropertyChangeObject ("cellRenderer", oldValue, cellRenderer);\r
117 }, "javax.swing.ListCellRenderer");\r
118 Clazz.defineMethod (c$, "getSelectionForeground", \r
119 function () {\r
120 return this.selectionForeground;\r
121 });\r
122 Clazz.defineMethod (c$, "setSelectionForeground", \r
123 function (selectionForeground) {\r
124 var oldValue = this.selectionForeground;\r
125 this.selectionForeground = selectionForeground;\r
126 this.firePropertyChangeObject ("selectionForeground", oldValue, selectionForeground);\r
127 }, "java.awt.Color");\r
128 Clazz.defineMethod (c$, "getSelectionBackground", \r
129 function () {\r
130 return this.selectionBackground;\r
131 });\r
132 Clazz.defineMethod (c$, "setSelectionBackground", \r
133 function (selectionBackground) {\r
134 var oldValue = this.selectionBackground;\r
135 this.selectionBackground = selectionBackground;\r
136 this.firePropertyChangeObject ("selectionBackground", oldValue, selectionBackground);\r
137 }, "java.awt.Color");\r
138 Clazz.defineMethod (c$, "getVisibleRowCount", \r
139 function () {\r
140 return this.visibleRowCount;\r
141 });\r
142 Clazz.defineMethod (c$, "setVisibleRowCount", \r
143 function (visibleRowCount) {\r
144 var oldValue = this.visibleRowCount;\r
145 this.visibleRowCount = Math.max (0, visibleRowCount);\r
146 this.firePropertyChangeInt ("visibleRowCount", oldValue, visibleRowCount);\r
147 }, "~N");\r
148 Clazz.defineMethod (c$, "getLayoutOrientation", \r
149 function () {\r
150 return this.layoutOrientation;\r
151 });\r
152 Clazz.defineMethod (c$, "setLayoutOrientation", \r
153 function (layoutOrientation) {\r
154 var oldValue = this.layoutOrientation;\r
155 switch (layoutOrientation) {\r
156 case 0:\r
157 case 1:\r
158 case 2:\r
159 this.layoutOrientation = layoutOrientation;\r
160 this.firePropertyChangeInt ("layoutOrientation", oldValue, layoutOrientation);\r
161 break;\r
162 default:\r
163 throw  new IllegalArgumentException ("layoutOrientation must be one of: VERTICAL, HORIZONTAL_WRAP or VERTICAL_WRAP");\r
164 }\r
165 }, "~N");\r
166 Clazz.defineMethod (c$, "getFirstVisibleIndex", \r
167 function () {\r
168 var r = this.getVisibleRect ();\r
169 var first;\r
170 if (this.getComponentOrientation ().isLeftToRight ()) {\r
171 first = this.locationToIndex (r.getLocation ());\r
172 } else {\r
173 first = this.locationToIndex ( new java.awt.Point ((r.x + r.width) - 1, r.y));\r
174 }if (first != -1) {\r
175 var bounds = this.getCellBounds (first, first);\r
176 if (bounds != null) {\r
177 javax.swing.SwingUtilities.computeIntersection (r.x, r.y, r.width, r.height, bounds);\r
178 if (bounds.width == 0 || bounds.height == 0) {\r
179 first = -1;\r
180 }}}return first;\r
181 });\r
182 Clazz.defineMethod (c$, "getLastVisibleIndex", \r
183 function () {\r
184 var leftToRight = this.getComponentOrientation ().isLeftToRight ();\r
185 var r = this.getVisibleRect ();\r
186 var lastPoint;\r
187 if (leftToRight) {\r
188 lastPoint =  new java.awt.Point ((r.x + r.width) - 1, (r.y + r.height) - 1);\r
189 } else {\r
190 lastPoint =  new java.awt.Point (r.x, (r.y + r.height) - 1);\r
191 }var location = this.locationToIndex (lastPoint);\r
192 if (location != -1) {\r
193 var bounds = this.getCellBounds (location, location);\r
194 if (bounds != null) {\r
195 javax.swing.SwingUtilities.computeIntersection (r.x, r.y, r.width, r.height, bounds);\r
196 if (bounds.width == 0 || bounds.height == 0) {\r
197 var isHorizontalWrap = (this.getLayoutOrientation () == 2);\r
198 var visibleLocation = isHorizontalWrap ?  new java.awt.Point (lastPoint.x, r.y) :  new java.awt.Point (r.x, lastPoint.y);\r
199 var last;\r
200 var visIndex = -1;\r
201 var lIndex = location;\r
202 location = -1;\r
203 do {\r
204 last = visIndex;\r
205 visIndex = this.locationToIndex (visibleLocation);\r
206 if (visIndex != -1) {\r
207 bounds = this.getCellBounds (visIndex, visIndex);\r
208 if (visIndex != lIndex && bounds != null && bounds.contains (visibleLocation)) {\r
209 location = visIndex;\r
210 if (isHorizontalWrap) {\r
211 visibleLocation.y = bounds.y + bounds.height;\r
212 if (visibleLocation.y >= lastPoint.y) {\r
213 last = visIndex;\r
214 }} else {\r
215 visibleLocation.x = bounds.x + bounds.width;\r
216 if (visibleLocation.x >= lastPoint.x) {\r
217 last = visIndex;\r
218 }}} else {\r
219 last = visIndex;\r
220 }}} while (visIndex != -1 && last != visIndex);\r
221 }}}return location;\r
222 });\r
223 Clazz.defineMethod (c$, "ensureIndexIsVisible", \r
224 function (index) {\r
225 var cellBounds = this.getCellBounds (index, index);\r
226 if (cellBounds != null) {\r
227 this.scrollRectToVisible (cellBounds);\r
228 }}, "~N");\r
229 Clazz.defineMethod (c$, "setDragEnabled", \r
230 function (b) {\r
231 this.dragEnabled = b;\r
232 }, "~B");\r
233 Clazz.defineMethod (c$, "getDragEnabled", \r
234 function () {\r
235 return this.dragEnabled;\r
236 });\r
237 Clazz.defineMethod (c$, "getNextMatch", \r
238 function (prefix, startIndex, bias) {\r
239 var model = this.getModel ();\r
240 var max = model.getSize ();\r
241 if (prefix == null) {\r
242 throw  new IllegalArgumentException ();\r
243 }if (startIndex < 0 || startIndex >= max) {\r
244 throw  new IllegalArgumentException ();\r
245 }prefix = prefix.toUpperCase ();\r
246 var increment = (bias === javax.swing.text.Position.Bias.Forward) ? 1 : -1;\r
247 var index = startIndex;\r
248 do {\r
249 var o = model.getElementAt (index);\r
250 if (o != null) {\r
251 var string;\r
252 if (Clazz.instanceOf (o, String)) {\r
253 string = (o).toUpperCase ();\r
254 } else {\r
255 string = o.toString ();\r
256 if (string != null) {\r
257 string = string.toUpperCase ();\r
258 }}if (string != null && string.startsWith (prefix)) {\r
259 return index;\r
260 }}index = (index + increment + max) % max;\r
261 } while (index != startIndex);\r
262 return -1;\r
263 }, "~S,~N,javax.swing.text.Position.Bias");\r
264 Clazz.defineMethod (c$, "getToolTipText", \r
265 function (event) {\r
266 if (event != null) {\r
267 var p = event.getPoint ();\r
268 var index = this.locationToIndex (p);\r
269 var r = this.getCellRenderer ();\r
270 var cellBounds;\r
271 if (index != -1 && r != null && (cellBounds = this.getCellBounds (index, index)) != null && cellBounds.contains (p.x, p.y)) {\r
272 var lsm = this.getSelectionModel ();\r
273 var rComponent = r.getListCellRendererComponent (this, this.getModel ().getElementAt (index), index, lsm.isSelectedIndex (index), (this.hasFocus () && (lsm.getLeadSelectionIndex () == index)));\r
274 if (Clazz.instanceOf (rComponent, javax.swing.JComponent)) {\r
275 var newEvent;\r
276 p.translate (-cellBounds.x, -cellBounds.y);\r
277 newEvent =  new java.awt.event.MouseEvent (rComponent, event.getID (), event.getWhen (), event.getModifiers (), p.x, p.y, event.getXOnScreen (), event.getYOnScreen (), event.getClickCount (), event.isPopupTrigger (), 0);\r
278 var tip = (rComponent).getToolTipText (newEvent);\r
279 if (tip != null) {\r
280 return tip;\r
281 }}}}return Clazz.superCall (this, javax.swing.JList, "getToolTipText", []);\r
282 }, "java.awt.event.MouseEvent");\r
283 Clazz.defineMethod (c$, "locationToIndex", \r
284 function (location) {\r
285 var ui = this.getUI ();\r
286 return (ui != null) ? ui.locationToIndex (this, location) : -1;\r
287 }, "java.awt.Point");\r
288 Clazz.defineMethod (c$, "indexToLocation", \r
289 function (index) {\r
290 var ui = this.getUI ();\r
291 return (ui != null) ? ui.indexToLocation (this, index) : null;\r
292 }, "~N");\r
293 Clazz.defineMethod (c$, "getCellBounds", \r
294 function (index0, index1) {\r
295 var ui = this.getUI ();\r
296 return (ui != null) ? ui.getCellBounds (this, index0, index1) : null;\r
297 }, "~N,~N");\r
298 Clazz.defineMethod (c$, "getModel", \r
299 function () {\r
300 return this.dataModel;\r
301 });\r
302 Clazz.defineMethod (c$, "setModel", \r
303 function (model) {\r
304 if (model == null) {\r
305 throw  new IllegalArgumentException ("model must be non null");\r
306 }var oldValue = this.dataModel;\r
307 this.dataModel = model;\r
308 this.firePropertyChangeObject ("model", oldValue, this.dataModel);\r
309 this.clearSelection ();\r
310 }, "javax.swing.ListModel");\r
311 Clazz.defineMethod (c$, "setListData", \r
312 function (listData) {\r
313 this.setModel (((Clazz.isClassDefined ("javax.swing.JList$4") ? 0 : javax.swing.JList.$JList$4$ ()), Clazz.innerTypeInstance (javax.swing.JList$4, this, Clazz.cloneFinals ("listData", listData))));\r
314 }, "~A");\r
315 Clazz.defineMethod (c$, "setListData", \r
316 function (listData) {\r
317 this.setModel (((Clazz.isClassDefined ("javax.swing.JList$5") ? 0 : javax.swing.JList.$JList$5$ ()), Clazz.innerTypeInstance (javax.swing.JList$5, this, Clazz.cloneFinals ("listData", listData))));\r
318 }, "java.util.Vector");\r
319 Clazz.defineMethod (c$, "createSelectionModel", \r
320 function () {\r
321 return  new javax.swing.DefaultListSelectionModel ();\r
322 });\r
323 Clazz.defineMethod (c$, "getSelectionModel", \r
324 function () {\r
325 return this.selectionModel;\r
326 });\r
327 Clazz.defineMethod (c$, "fireSelectionValueChanged", \r
328 function (firstIndex, lastIndex, isAdjusting) {\r
329 var listeners = this.listenerList.getListenerList ();\r
330 var e = null;\r
331 for (var i = listeners.length - 2; i >= 0; i -= 2) {\r
332 if (listeners[i] === javax.swing.event.ListSelectionListener) {\r
333 if (e == null) {\r
334 e =  new javax.swing.event.ListSelectionEvent (this, firstIndex, lastIndex, isAdjusting);\r
335 }(listeners[i + 1]).valueChanged (e);\r
336 }}\r
337 }, "~N,~N,~B");\r
338 Clazz.defineMethod (c$, "addListSelectionListener", \r
339 function (listener) {\r
340 if (this.selectionListener == null) {\r
341 this.selectionListener = Clazz.innerTypeInstance (javax.swing.JList.ListSelectionHandler, this, null);\r
342 this.getSelectionModel ().addListSelectionListener (this.selectionListener);\r
343 }this.listenerList.add (javax.swing.event.ListSelectionListener, listener);\r
344 }, "javax.swing.event.ListSelectionListener");\r
345 Clazz.defineMethod (c$, "removeListSelectionListener", \r
346 function (listener) {\r
347 this.listenerList.remove (javax.swing.event.ListSelectionListener, listener);\r
348 }, "javax.swing.event.ListSelectionListener");\r
349 Clazz.defineMethod (c$, "getListSelectionListeners", \r
350 function () {\r
351 return this.listenerList.getListeners (javax.swing.event.ListSelectionListener);\r
352 });\r
353 Clazz.defineMethod (c$, "setSelectionModel", \r
354 function (selectionModel) {\r
355 if (selectionModel == null) {\r
356 throw  new IllegalArgumentException ("selectionModel must be non null");\r
357 }if (this.selectionListener != null) {\r
358 this.selectionModel.removeListSelectionListener (this.selectionListener);\r
359 selectionModel.addListSelectionListener (this.selectionListener);\r
360 }var oldValue = this.selectionModel;\r
361 this.selectionModel = selectionModel;\r
362 this.firePropertyChangeObject ("selectionModel", oldValue, selectionModel);\r
363 }, "javax.swing.ListSelectionModel");\r
364 Clazz.defineMethod (c$, "setSelectionMode", \r
365 function (selectionMode) {\r
366 this.getSelectionModel ().setSelectionMode (selectionMode);\r
367 }, "~N");\r
368 Clazz.defineMethod (c$, "getSelectionMode", \r
369 function () {\r
370 return this.getSelectionModel ().getSelectionMode ();\r
371 });\r
372 Clazz.defineMethod (c$, "getAnchorSelectionIndex", \r
373 function () {\r
374 return this.getSelectionModel ().getAnchorSelectionIndex ();\r
375 });\r
376 Clazz.defineMethod (c$, "getLeadSelectionIndex", \r
377 function () {\r
378 return this.getSelectionModel ().getLeadSelectionIndex ();\r
379 });\r
380 Clazz.defineMethod (c$, "getMinSelectionIndex", \r
381 function () {\r
382 return this.getSelectionModel ().getMinSelectionIndex ();\r
383 });\r
384 Clazz.defineMethod (c$, "getMaxSelectionIndex", \r
385 function () {\r
386 return this.getSelectionModel ().getMaxSelectionIndex ();\r
387 });\r
388 Clazz.defineMethod (c$, "isSelectedIndex", \r
389 function (index) {\r
390 return this.getSelectionModel ().isSelectedIndex (index);\r
391 }, "~N");\r
392 Clazz.defineMethod (c$, "isSelectionEmpty", \r
393 function () {\r
394 return this.getSelectionModel ().isSelectionEmpty ();\r
395 });\r
396 Clazz.defineMethod (c$, "clearSelection", \r
397 function () {\r
398 this.getSelectionModel ().clearSelection ();\r
399 });\r
400 Clazz.defineMethod (c$, "setSelectionInterval", \r
401 function (anchor, lead) {\r
402 this.getSelectionModel ().setSelectionInterval (anchor, lead);\r
403 }, "~N,~N");\r
404 Clazz.defineMethod (c$, "addSelectionInterval", \r
405 function (anchor, lead) {\r
406 this.getSelectionModel ().addSelectionInterval (anchor, lead);\r
407 }, "~N,~N");\r
408 Clazz.defineMethod (c$, "removeSelectionInterval", \r
409 function (index0, index1) {\r
410 this.getSelectionModel ().removeSelectionInterval (index0, index1);\r
411 }, "~N,~N");\r
412 Clazz.defineMethod (c$, "setValueIsAdjusting", \r
413 function (b) {\r
414 this.getSelectionModel ().setValueIsAdjusting (b);\r
415 }, "~B");\r
416 Clazz.defineMethod (c$, "getValueIsAdjusting", \r
417 function () {\r
418 return this.getSelectionModel ().getValueIsAdjusting ();\r
419 });\r
420 Clazz.defineMethod (c$, "getSelectedIndices", \r
421 function () {\r
422 var sm = this.getSelectionModel ();\r
423 var iMin = sm.getMinSelectionIndex ();\r
424 var iMax = sm.getMaxSelectionIndex ();\r
425 if ((iMin < 0) || (iMax < 0)) {\r
426 return  Clazz.newIntArray (0, 0);\r
427 }var rvTmp =  Clazz.newIntArray (1 + (iMax - iMin), 0);\r
428 var n = 0;\r
429 for (var i = iMin; i <= iMax; i++) {\r
430 if (sm.isSelectedIndex (i)) {\r
431 rvTmp[n++] = i;\r
432 }}\r
433 var rv =  Clazz.newIntArray (n, 0);\r
434 System.arraycopy (rvTmp, 0, rv, 0, n);\r
435 return rv;\r
436 });\r
437 Clazz.defineMethod (c$, "setSelectedIndex", \r
438 function (index) {\r
439 if (index >= this.getModel ().getSize ()) {\r
440 return;\r
441 }this.getSelectionModel ().setSelectionInterval (index, index);\r
442 }, "~N");\r
443 Clazz.defineMethod (c$, "setSelectedIndices", \r
444 function (indices) {\r
445 var sm = this.getSelectionModel ();\r
446 sm.clearSelection ();\r
447 var size = this.getModel ().getSize ();\r
448 for (var i = 0; i < indices.length; i++) {\r
449 if (indices[i] < size) {\r
450 sm.addSelectionInterval (indices[i], indices[i]);\r
451 }}\r
452 }, "~A");\r
453 Clazz.defineMethod (c$, "getSelectedValues", \r
454 function () {\r
455 var sm = this.getSelectionModel ();\r
456 var dm = this.getModel ();\r
457 var iMin = sm.getMinSelectionIndex ();\r
458 var iMax = sm.getMaxSelectionIndex ();\r
459 if ((iMin < 0) || (iMax < 0)) {\r
460 return  new Array (0);\r
461 }var rvTmp =  new Array (1 + (iMax - iMin));\r
462 var n = 0;\r
463 for (var i = iMin; i <= iMax; i++) {\r
464 if (sm.isSelectedIndex (i)) {\r
465 rvTmp[n++] = dm.getElementAt (i);\r
466 }}\r
467 var rv =  new Array (n);\r
468 System.arraycopy (rvTmp, 0, rv, 0, n);\r
469 return rv;\r
470 });\r
471 Clazz.defineMethod (c$, "getSelectedIndex", \r
472 function () {\r
473 return this.getMinSelectionIndex ();\r
474 });\r
475 Clazz.defineMethod (c$, "getSelectedValue", \r
476 function () {\r
477 var i = this.getMinSelectionIndex ();\r
478 return (i == -1) ? null : this.getModel ().getElementAt (i);\r
479 });\r
480 Clazz.defineMethod (c$, "setSelectedValue", \r
481 function (anObject, shouldScroll) {\r
482 if (anObject == null) this.setSelectedIndex (-1);\r
483  else if (!anObject.equals (this.getSelectedValue ())) {\r
484 var i;\r
485 var c;\r
486 var dm = this.getModel ();\r
487 for (i = 0, c = dm.getSize (); i < c; i++) if (anObject.equals (dm.getElementAt (i))) {\r
488 this.setSelectedIndex (i);\r
489 if (shouldScroll) this.ensureIndexIsVisible (i);\r
490 this.repaint ();\r
491 return;\r
492 }\r
493 this.setSelectedIndex (-1);\r
494 }this.repaint ();\r
495 }, "~O,~B");\r
496 Clazz.defineMethod (c$, "checkScrollableParameters", \r
497  function (visibleRect, orientation) {\r
498 if (visibleRect == null) {\r
499 throw  new IllegalArgumentException ("visibleRect must be non-null");\r
500 }switch (orientation) {\r
501 case 1:\r
502 case 0:\r
503 break;\r
504 default:\r
505 throw  new IllegalArgumentException ("orientation must be one of: VERTICAL, HORIZONTAL");\r
506 }\r
507 }, "java.awt.Rectangle,~N");\r
508 Clazz.overrideMethod (c$, "getPreferredScrollableViewportSize", \r
509 function () {\r
510 if (this.getLayoutOrientation () != 0) {\r
511 return this.getPreferredSize ();\r
512 }var insets = this.getInsets ();\r
513 var dx = insets.left + insets.right;\r
514 var dy = insets.top + insets.bottom;\r
515 var visibleRowCount = this.getVisibleRowCount ();\r
516 var fixedCellWidth = this.getFixedCellWidth ();\r
517 var fixedCellHeight = this.getFixedCellHeight ();\r
518 if ((fixedCellWidth > 0) && (fixedCellHeight > 0)) {\r
519 var width = fixedCellWidth + dx;\r
520 var height = (visibleRowCount * fixedCellHeight) + dy;\r
521 return  new java.awt.Dimension (width, height);\r
522 } else if (this.getModel ().getSize () > 0) {\r
523 var width = this.getPreferredSize ().width;\r
524 var height;\r
525 var r = this.getCellBounds (0, 0);\r
526 if (r != null) {\r
527 height = (visibleRowCount * r.height) + dy;\r
528 } else {\r
529 height = 1;\r
530 }return  new java.awt.Dimension (width, height);\r
531 } else {\r
532 fixedCellWidth = (fixedCellWidth > 0) ? fixedCellWidth : 256;\r
533 fixedCellHeight = (fixedCellHeight > 0) ? fixedCellHeight : 16;\r
534 return  new java.awt.Dimension (fixedCellWidth, fixedCellHeight * visibleRowCount);\r
535 }});\r
536 Clazz.overrideMethod (c$, "getScrollableUnitIncrement", \r
537 function (visibleRect, orientation, direction) {\r
538 this.checkScrollableParameters (visibleRect, orientation);\r
539 if (orientation == 1) {\r
540 var row = this.locationToIndex (visibleRect.getLocation ());\r
541 if (row == -1) {\r
542 return 0;\r
543 } else {\r
544 if (direction > 0) {\r
545 var r = this.getCellBounds (row, row);\r
546 return (r == null) ? 0 : r.height - (visibleRect.y - r.y);\r
547 } else {\r
548 var r = this.getCellBounds (row, row);\r
549 if ((r.y == visibleRect.y) && (row == 0)) {\r
550 return 0;\r
551 } else if (r.y == visibleRect.y) {\r
552 var loc = r.getLocation ();\r
553 loc.y--;\r
554 var prevIndex = this.locationToIndex (loc);\r
555 var prevR = this.getCellBounds (prevIndex, prevIndex);\r
556 if (prevR == null || prevR.y >= r.y) {\r
557 return 0;\r
558 }return prevR.height;\r
559 } else {\r
560 return visibleRect.y - r.y;\r
561 }}}} else if (orientation == 0 && this.getLayoutOrientation () != 0) {\r
562 var leftToRight = this.getComponentOrientation ().isLeftToRight ();\r
563 var index;\r
564 var leadingPoint;\r
565 if (leftToRight) {\r
566 leadingPoint = visibleRect.getLocation ();\r
567 } else {\r
568 leadingPoint =  new java.awt.Point (visibleRect.x + visibleRect.width - 1, visibleRect.y);\r
569 }index = this.locationToIndex (leadingPoint);\r
570 if (index != -1) {\r
571 var cellBounds = this.getCellBounds (index, index);\r
572 if (cellBounds != null && cellBounds.contains (leadingPoint)) {\r
573 var leadingVisibleEdge;\r
574 var leadingCellEdge;\r
575 if (leftToRight) {\r
576 leadingVisibleEdge = visibleRect.x;\r
577 leadingCellEdge = cellBounds.x;\r
578 } else {\r
579 leadingVisibleEdge = visibleRect.x + visibleRect.width;\r
580 leadingCellEdge = cellBounds.x + cellBounds.width;\r
581 }if (leadingCellEdge != leadingVisibleEdge) {\r
582 if (direction < 0) {\r
583 return Math.abs (leadingVisibleEdge - leadingCellEdge);\r
584 } else if (leftToRight) {\r
585 return leadingCellEdge + cellBounds.width - leadingVisibleEdge;\r
586 } else {\r
587 return leadingVisibleEdge - cellBounds.x;\r
588 }}return cellBounds.width;\r
589 }}}var f = this.getFont ();\r
590 return (f != null) ? f.getSize () : 1;\r
591 }, "java.awt.Rectangle,~N,~N");\r
592 Clazz.overrideMethod (c$, "getScrollableBlockIncrement", \r
593 function (visibleRect, orientation, direction) {\r
594 this.checkScrollableParameters (visibleRect, orientation);\r
595 if (orientation == 1) {\r
596 var inc = visibleRect.height;\r
597 if (direction > 0) {\r
598 var last = this.locationToIndex ( new java.awt.Point (visibleRect.x, visibleRect.y + visibleRect.height - 1));\r
599 if (last != -1) {\r
600 var lastRect = this.getCellBounds (last, last);\r
601 if (lastRect != null) {\r
602 inc = lastRect.y - visibleRect.y;\r
603 if ((inc == 0) && (last < this.getModel ().getSize () - 1)) {\r
604 inc = lastRect.height;\r
605 }}}} else {\r
606 var newFirst = this.locationToIndex ( new java.awt.Point (visibleRect.x, visibleRect.y - visibleRect.height));\r
607 var first = this.getFirstVisibleIndex ();\r
608 if (newFirst != -1) {\r
609 if (first == -1) {\r
610 first = this.locationToIndex (visibleRect.getLocation ());\r
611 }var newFirstRect = this.getCellBounds (newFirst, newFirst);\r
612 var firstRect = this.getCellBounds (first, first);\r
613 if ((newFirstRect != null) && (firstRect != null)) {\r
614 while ((newFirstRect.y + visibleRect.height < firstRect.y + firstRect.height) && (newFirstRect.y < firstRect.y)) {\r
615 newFirst++;\r
616 newFirstRect = this.getCellBounds (newFirst, newFirst);\r
617 }\r
618 inc = visibleRect.y - newFirstRect.y;\r
619 if ((inc <= 0) && (newFirstRect.y > 0)) {\r
620 newFirst--;\r
621 newFirstRect = this.getCellBounds (newFirst, newFirst);\r
622 if (newFirstRect != null) {\r
623 inc = visibleRect.y - newFirstRect.y;\r
624 }}}}}return inc;\r
625 } else if (orientation == 0 && this.getLayoutOrientation () != 0) {\r
626 var leftToRight = this.getComponentOrientation ().isLeftToRight ();\r
627 var inc = visibleRect.width;\r
628 if (direction > 0) {\r
629 var x = visibleRect.x + (leftToRight ? (visibleRect.width - 1) : 0);\r
630 var last = this.locationToIndex ( new java.awt.Point (x, visibleRect.y));\r
631 if (last != -1) {\r
632 var lastRect = this.getCellBounds (last, last);\r
633 if (lastRect != null) {\r
634 if (leftToRight) {\r
635 inc = lastRect.x - visibleRect.x;\r
636 } else {\r
637 inc = visibleRect.x + visibleRect.width - (lastRect.x + lastRect.width);\r
638 }if (inc < 0) {\r
639 inc += lastRect.width;\r
640 } else if ((inc == 0) && (last < this.getModel ().getSize () - 1)) {\r
641 inc = lastRect.width;\r
642 }}}} else {\r
643 var x = visibleRect.x + (leftToRight ? -visibleRect.width : visibleRect.width - 1 + visibleRect.width);\r
644 var first = this.locationToIndex ( new java.awt.Point (x, visibleRect.y));\r
645 if (first != -1) {\r
646 var firstRect = this.getCellBounds (first, first);\r
647 if (firstRect != null) {\r
648 var firstRight = firstRect.x + firstRect.width;\r
649 if (leftToRight) {\r
650 if ((firstRect.x < visibleRect.x - visibleRect.width) && (firstRight < visibleRect.x)) {\r
651 inc = visibleRect.x - firstRight;\r
652 } else {\r
653 inc = visibleRect.x - firstRect.x;\r
654 }} else {\r
655 var visibleRight = visibleRect.x + visibleRect.width;\r
656 if ((firstRight > visibleRight + visibleRect.width) && (firstRect.x > visibleRight)) {\r
657 inc = firstRect.x - visibleRight;\r
658 } else {\r
659 inc = firstRight - visibleRight;\r
660 }}}}}return inc;\r
661 }return visibleRect.width;\r
662 }, "java.awt.Rectangle,~N,~N");\r
663 Clazz.overrideMethod (c$, "getScrollableTracksViewportWidth", \r
664 function () {\r
665 if (this.getLayoutOrientation () == 2 && this.getVisibleRowCount () <= 0) {\r
666 return true;\r
667 }if (Clazz.instanceOf (this.getParent (), javax.swing.JViewport)) {\r
668 return ((this.getParent ()).getWidth () > this.getPreferredSize ().width);\r
669 }return false;\r
670 });\r
671 Clazz.overrideMethod (c$, "getScrollableTracksViewportHeight", \r
672 function () {\r
673 if (this.getLayoutOrientation () == 1 && this.getVisibleRowCount () <= 0) {\r
674 return true;\r
675 }if (Clazz.instanceOf (this.getParent (), javax.swing.JViewport)) {\r
676 return ((this.getParent ()).getHeight () > this.getPreferredSize ().height);\r
677 }return false;\r
678 });\r
679 Clazz.defineMethod (c$, "paramString", \r
680 function () {\r
681 var selectionForegroundString = (this.selectionForeground != null ? this.selectionForeground.toString () : "");\r
682 var selectionBackgroundString = (this.selectionBackground != null ? this.selectionBackground.toString () : "");\r
683 return Clazz.superCall (this, javax.swing.JList, "paramString", []) + ",fixedCellHeight=" + this.fixedCellHeight + ",fixedCellWidth=" + this.fixedCellWidth + ",horizontalScrollIncrement=" + this.horizontalScrollIncrement + ",selectionBackground=" + selectionBackgroundString + ",selectionForeground=" + selectionForegroundString + ",visibleRowCount=" + this.visibleRowCount + ",layoutOrientation=" + this.layoutOrientation;\r
684 });\r
685 c$.$JList$ListSelectionHandler$ = function () {\r
686 Clazz.pu$h(self.c$);\r
687 c$ = Clazz.decorateAsClass (function () {\r
688 Clazz.prepareCallback (this, arguments);\r
689 Clazz.instantialize (this, arguments);\r
690 }, javax.swing.JList, "ListSelectionHandler", null, javax.swing.event.ListSelectionListener);\r
691 Clazz.overrideMethod (c$, "valueChanged", \r
692 function (a) {\r
693 this.b$["javax.swing.JList"].fireSelectionValueChanged (a.getFirstIndex (), a.getLastIndex (), a.getValueIsAdjusting ());\r
694 }, "javax.swing.event.ListSelectionEvent");\r
695 c$ = Clazz.p0p ();\r
696 };\r
697 c$.$JList$1$ = function () {\r
698 Clazz.pu$h(self.c$);\r
699 c$ = Clazz.declareAnonymous (javax.swing, "JList$1", javax.swing.AbstractListModel);\r
700 Clazz.defineMethod (c$, "getSize", \r
701 function () {\r
702 return this.f$.listData.length;\r
703 });\r
704 Clazz.defineMethod (c$, "getElementAt", \r
705 function (i) {\r
706 return this.f$.listData[i];\r
707 }, "~N");\r
708 c$ = Clazz.p0p ();\r
709 };\r
710 c$.$JList$2$ = function () {\r
711 Clazz.pu$h(self.c$);\r
712 c$ = Clazz.declareAnonymous (javax.swing, "JList$2", javax.swing.AbstractListModel);\r
713 Clazz.defineMethod (c$, "getSize", \r
714 function () {\r
715 return this.f$.listData.size ();\r
716 });\r
717 Clazz.defineMethod (c$, "getElementAt", \r
718 function (i) {\r
719 return this.f$.listData.elementAt (i);\r
720 }, "~N");\r
721 c$ = Clazz.p0p ();\r
722 };\r
723 c$.$JList$3$ = function () {\r
724 Clazz.pu$h(self.c$);\r
725 c$ = Clazz.declareAnonymous (javax.swing, "JList$3", javax.swing.AbstractListModel);\r
726 Clazz.defineMethod (c$, "getSize", \r
727 function () {\r
728 return 0;\r
729 });\r
730 Clazz.defineMethod (c$, "getElementAt", \r
731 function (i) {\r
732 return "No Data Model";\r
733 }, "~N");\r
734 c$ = Clazz.p0p ();\r
735 };\r
736 c$.$JList$4$ = function () {\r
737 Clazz.pu$h(self.c$);\r
738 c$ = Clazz.declareAnonymous (javax.swing, "JList$4", javax.swing.AbstractListModel);\r
739 Clazz.defineMethod (c$, "getSize", \r
740 function () {\r
741 return this.f$.listData.length;\r
742 });\r
743 Clazz.defineMethod (c$, "getElementAt", \r
744 function (i) {\r
745 return this.f$.listData[i];\r
746 }, "~N");\r
747 c$ = Clazz.p0p ();\r
748 };\r
749 c$.$JList$5$ = function () {\r
750 Clazz.pu$h(self.c$);\r
751 c$ = Clazz.declareAnonymous (javax.swing, "JList$5", javax.swing.AbstractListModel);\r
752 Clazz.defineMethod (c$, "getSize", \r
753 function () {\r
754 return this.f$.listData.size ();\r
755 });\r
756 Clazz.defineMethod (c$, "getElementAt", \r
757 function (i) {\r
758 return this.f$.listData.elementAt (i);\r
759 }, "~N");\r
760 c$ = Clazz.p0p ();\r
761 };\r
762 Clazz.defineStatics (c$,\r
763 "$uiClassID", "ListUI",\r
764 "VERTICAL", 0,\r
765 "VERTICAL_WRAP", 1,\r
766 "HORIZONTAL_WRAP", 2);\r
767 });\r