1 Clazz.declarePackage ("javax.swing");
\r
2 Clazz.load (["javax.swing.ListSelectionModel", "java.util.BitSet", "javax.swing.event.EventListenerList"], "javax.swing.DefaultListSelectionModel", ["java.lang.IllegalArgumentException", "javax.swing.event.ListSelectionEvent", "$.ListSelectionListener"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.selectionMode = 2;
\r
5 this.minIndex = 2147483647;
\r
7 this.anchorIndex = -1;
\r
9 this.firstAdjustedIndex = 2147483647;
\r
10 this.lastAdjustedIndex = -1;
\r
11 this.isAdjusting = false;
\r
12 this.firstChangedIndex = 2147483647;
\r
13 this.lastChangedIndex = -1;
\r
15 this.listenerList = null;
\r
16 this.leadAnchorNotificationEnabled = true;
\r
17 Clazz.instantialize (this, arguments);
\r
18 }, javax.swing, "DefaultListSelectionModel", null, [javax.swing.ListSelectionModel, Cloneable]);
\r
19 Clazz.prepareFields (c$, function () {
\r
20 this.value = new java.util.BitSet (32);
\r
21 this.listenerList = new javax.swing.event.EventListenerList ();
\r
23 Clazz.overrideMethod (c$, "getMinSelectionIndex",
\r
25 return this.isSelectionEmpty () ? -1 : this.minIndex;
\r
27 Clazz.overrideMethod (c$, "getMaxSelectionIndex",
\r
29 return this.maxIndex;
\r
31 Clazz.overrideMethod (c$, "getValueIsAdjusting",
\r
33 return this.isAdjusting;
\r
35 Clazz.overrideMethod (c$, "getSelectionMode",
\r
37 return this.selectionMode;
\r
39 Clazz.overrideMethod (c$, "setSelectionMode",
\r
40 function (selectionMode) {
\r
41 switch (selectionMode) {
\r
45 this.selectionMode = selectionMode;
\r
48 throw new IllegalArgumentException ("invalid selectionMode");
\r
51 Clazz.overrideMethod (c$, "isSelectedIndex",
\r
53 return ((index < this.minIndex) || (index > this.maxIndex)) ? false : this.value.get (index);
\r
55 Clazz.overrideMethod (c$, "isSelectionEmpty",
\r
57 return (this.minIndex > this.maxIndex);
\r
59 Clazz.overrideMethod (c$, "addListSelectionListener",
\r
61 this.listenerList.add (javax.swing.event.ListSelectionListener, l);
\r
62 }, "javax.swing.event.ListSelectionListener");
\r
63 Clazz.overrideMethod (c$, "removeListSelectionListener",
\r
65 this.listenerList.remove (javax.swing.event.ListSelectionListener, l);
\r
66 }, "javax.swing.event.ListSelectionListener");
\r
67 Clazz.defineMethod (c$, "getListSelectionListeners",
\r
69 return this.listenerList.getListeners (javax.swing.event.ListSelectionListener);
\r
71 Clazz.defineMethod (c$, "fireValueChanged",
\r
72 function (isAdjusting) {
\r
73 if (this.lastChangedIndex == -1) {
\r
75 }var oldFirstChangedIndex = this.firstChangedIndex;
\r
76 var oldLastChangedIndex = this.lastChangedIndex;
\r
77 this.firstChangedIndex = 2147483647;
\r
78 this.lastChangedIndex = -1;
\r
79 this.fireValueChanged (oldFirstChangedIndex, oldLastChangedIndex, isAdjusting);
\r
81 Clazz.defineMethod (c$, "fireValueChanged",
\r
82 function (firstIndex, lastIndex) {
\r
83 this.fireValueChanged (firstIndex, lastIndex, this.getValueIsAdjusting ());
\r
85 Clazz.defineMethod (c$, "fireValueChanged",
\r
86 function (firstIndex, lastIndex, isAdjusting) {
\r
87 var listeners = this.listenerList.getListenerList ();
\r
89 for (var i = listeners.length - 2; i >= 0; i -= 2) {
\r
90 if (listeners[i] === javax.swing.event.ListSelectionListener) {
\r
92 e = new javax.swing.event.ListSelectionEvent (this, firstIndex, lastIndex, isAdjusting);
\r
93 }(listeners[i + 1]).valueChanged (e);
\r
96 Clazz.defineMethod (c$, "fireValueChanged",
\r
98 if (this.lastAdjustedIndex == -1) {
\r
100 }if (this.getValueIsAdjusting ()) {
\r
101 this.firstChangedIndex = Math.min (this.firstChangedIndex, this.firstAdjustedIndex);
\r
102 this.lastChangedIndex = Math.max (this.lastChangedIndex, this.lastAdjustedIndex);
\r
103 }var oldFirstAdjustedIndex = this.firstAdjustedIndex;
\r
104 var oldLastAdjustedIndex = this.lastAdjustedIndex;
\r
105 this.firstAdjustedIndex = 2147483647;
\r
106 this.lastAdjustedIndex = -1;
\r
107 this.fireValueChanged (oldFirstAdjustedIndex, oldLastAdjustedIndex);
\r
109 Clazz.defineMethod (c$, "getListeners",
\r
110 function (listenerType) {
\r
111 return this.listenerList.getListeners (listenerType);
\r
113 Clazz.defineMethod (c$, "markAsDirty",
\r
115 this.firstAdjustedIndex = Math.min (this.firstAdjustedIndex, r);
\r
116 this.lastAdjustedIndex = Math.max (this.lastAdjustedIndex, r);
\r
118 Clazz.defineMethod (c$, "set",
\r
120 if (this.value.get (r)) {
\r
122 }this.value.set (r);
\r
123 this.markAsDirty (r);
\r
124 this.minIndex = Math.min (this.minIndex, r);
\r
125 this.maxIndex = Math.max (this.maxIndex, r);
\r
127 Clazz.defineMethod (c$, "clear",
\r
129 if (!this.value.get (r)) {
\r
131 }this.value.clear (r);
\r
132 this.markAsDirty (r);
\r
133 if (r == this.minIndex) {
\r
134 for (this.minIndex = this.minIndex + 1; this.minIndex <= this.maxIndex; this.minIndex++) {
\r
135 if (this.value.get (this.minIndex)) {
\r
138 }if (r == this.maxIndex) {
\r
139 for (this.maxIndex = this.maxIndex - 1; this.minIndex <= this.maxIndex; this.maxIndex--) {
\r
140 if (this.value.get (this.maxIndex)) {
\r
143 }if (this.isSelectionEmpty ()) {
\r
144 this.minIndex = 2147483647;
\r
145 this.maxIndex = -1;
\r
147 Clazz.defineMethod (c$, "setLeadAnchorNotificationEnabled",
\r
149 this.leadAnchorNotificationEnabled = flag;
\r
151 Clazz.defineMethod (c$, "isLeadAnchorNotificationEnabled",
\r
153 return this.leadAnchorNotificationEnabled;
\r
155 Clazz.defineMethod (c$, "updateLeadAnchorIndices",
\r
156 function (anchorIndex, leadIndex) {
\r
157 if (this.leadAnchorNotificationEnabled) {
\r
158 if (this.anchorIndex != anchorIndex) {
\r
159 if (this.anchorIndex != -1) {
\r
160 this.markAsDirty (this.anchorIndex);
\r
161 }this.markAsDirty (anchorIndex);
\r
162 }if (this.leadIndex != leadIndex) {
\r
163 if (this.leadIndex != -1) {
\r
164 this.markAsDirty (this.leadIndex);
\r
165 }this.markAsDirty (leadIndex);
\r
166 }}this.anchorIndex = anchorIndex;
\r
167 this.leadIndex = leadIndex;
\r
169 Clazz.defineMethod (c$, "contains",
\r
170 function (a, b, i) {
\r
171 return (i >= a) && (i <= b);
\r
173 Clazz.defineMethod (c$, "changeSelection",
\r
174 function (clearMin, clearMax, setMin, setMax, clearFirst) {
\r
175 for (var i = Math.min (setMin, clearMin); i <= Math.max (setMax, clearMax); i++) {
\r
176 var shouldClear = this.contains (clearMin, clearMax, i);
\r
177 var shouldSet = this.contains (setMin, setMax, i);
\r
178 if (shouldSet && shouldClear) {
\r
180 shouldClear = false;
\r
185 }if (shouldClear) {
\r
188 this.fireValueChanged ();
\r
189 }, "~N,~N,~N,~N,~B");
\r
190 Clazz.defineMethod (c$, "changeSelection",
\r
191 function (clearMin, clearMax, setMin, setMax) {
\r
192 this.changeSelection (clearMin, clearMax, setMin, setMax, true);
\r
194 Clazz.overrideMethod (c$, "clearSelection",
\r
196 this.removeSelectionIntervalImpl (this.minIndex, this.maxIndex, false);
\r
198 Clazz.overrideMethod (c$, "setSelectionInterval",
\r
199 function (index0, index1) {
\r
200 if (index0 == -1 || index1 == -1) {
\r
202 }if (this.getSelectionMode () == 0) {
\r
204 }this.updateLeadAnchorIndices (index0, index1);
\r
205 var clearMin = this.minIndex;
\r
206 var clearMax = this.maxIndex;
\r
207 var setMin = Math.min (index0, index1);
\r
208 var setMax = Math.max (index0, index1);
\r
209 this.changeSelection (clearMin, clearMax, setMin, setMax);
\r
211 Clazz.overrideMethod (c$, "addSelectionInterval",
\r
212 function (index0, index1) {
\r
213 if (index0 == -1 || index1 == -1) {
\r
215 }if (this.getSelectionMode () == 0) {
\r
216 this.setSelectionInterval (index0, index1);
\r
218 }this.updateLeadAnchorIndices (index0, index1);
\r
219 var clearMin = 2147483647;
\r
221 var setMin = Math.min (index0, index1);
\r
222 var setMax = Math.max (index0, index1);
\r
223 if (this.getSelectionMode () == 1 && (setMax < this.minIndex - 1 || setMin > this.maxIndex + 1)) {
\r
224 this.setSelectionInterval (index0, index1);
\r
226 }this.changeSelection (clearMin, clearMax, setMin, setMax);
\r
228 Clazz.overrideMethod (c$, "removeSelectionInterval",
\r
229 function (index0, index1) {
\r
230 this.removeSelectionIntervalImpl (index0, index1, true);
\r
232 Clazz.defineMethod (c$, "removeSelectionIntervalImpl",
\r
233 function (index0, index1, changeLeadAnchor) {
\r
234 if (index0 == -1 || index1 == -1) {
\r
236 }if (changeLeadAnchor) {
\r
237 this.updateLeadAnchorIndices (index0, index1);
\r
238 }var clearMin = Math.min (index0, index1);
\r
239 var clearMax = Math.max (index0, index1);
\r
240 var setMin = 2147483647;
\r
242 if (this.getSelectionMode () != 2 && clearMin > this.minIndex && clearMax < this.maxIndex) {
\r
243 clearMax = this.maxIndex;
\r
244 }this.changeSelection (clearMin, clearMax, setMin, setMax);
\r
246 Clazz.defineMethod (c$, "setState",
\r
247 function (index, state) {
\r
251 this.clear (index);
\r
253 Clazz.overrideMethod (c$, "insertIndexInterval",
\r
254 function (index, length, before) {
\r
255 var insMinIndex = (before) ? index : index + 1;
\r
256 var insMaxIndex = (insMinIndex + length) - 1;
\r
257 for (var i = this.maxIndex; i >= insMinIndex; i--) {
\r
258 this.setState (i + length, this.value.get (i));
\r
260 var setInsertedValues = ((this.getSelectionMode () == 0) ? false : this.value.get (index));
\r
261 for (var i = insMinIndex; i <= insMaxIndex; i++) {
\r
262 this.setState (i, setInsertedValues);
\r
264 var leadIndex = this.leadIndex;
\r
265 if (leadIndex > index || (before && leadIndex == index)) {
\r
266 leadIndex = this.leadIndex + length;
\r
267 }var anchorIndex = this.anchorIndex;
\r
268 if (anchorIndex > index || (before && anchorIndex == index)) {
\r
269 anchorIndex = this.anchorIndex + length;
\r
270 }if (leadIndex != this.leadIndex || anchorIndex != this.anchorIndex) {
\r
271 this.updateLeadAnchorIndices (anchorIndex, leadIndex);
\r
272 }this.fireValueChanged ();
\r
274 Clazz.overrideMethod (c$, "removeIndexInterval",
\r
275 function (index0, index1) {
\r
276 var rmMinIndex = Math.min (index0, index1);
\r
277 var rmMaxIndex = Math.max (index0, index1);
\r
278 var gapLength = (rmMaxIndex - rmMinIndex) + 1;
\r
279 for (var i = rmMinIndex; i <= this.maxIndex; i++) {
\r
280 this.setState (i, this.value.get (i + gapLength));
\r
282 var leadIndex = this.leadIndex;
\r
283 if (leadIndex == 0 && rmMinIndex == 0) {
\r
284 } else if (leadIndex > rmMaxIndex) {
\r
285 leadIndex = this.leadIndex - gapLength;
\r
286 } else if (leadIndex >= rmMinIndex) {
\r
287 leadIndex = rmMinIndex - 1;
\r
288 }var anchorIndex = this.anchorIndex;
\r
289 if (anchorIndex == 0 && rmMinIndex == 0) {
\r
290 } else if (anchorIndex > rmMaxIndex) {
\r
291 anchorIndex = this.anchorIndex - gapLength;
\r
292 } else if (anchorIndex >= rmMinIndex) {
\r
293 anchorIndex = rmMinIndex - 1;
\r
294 }if (leadIndex != this.leadIndex || anchorIndex != this.anchorIndex) {
\r
295 this.updateLeadAnchorIndices (anchorIndex, leadIndex);
\r
296 }this.fireValueChanged ();
\r
298 Clazz.overrideMethod (c$, "setValueIsAdjusting",
\r
299 function (isAdjusting) {
\r
300 if (isAdjusting != this.isAdjusting) {
\r
301 this.isAdjusting = isAdjusting;
\r
302 this.fireValueChanged (isAdjusting);
\r
304 Clazz.overrideMethod (c$, "toString",
\r
306 var s = ((this.getValueIsAdjusting ()) ? "~" : "=") + this.value.toString ();
\r
307 return this.getClass ().getName () + " " + Integer.toString (this.hashCode ()) + " " + s;
\r
309 Clazz.defineMethod (c$, "clone",
\r
311 var clone = Clazz.superCall (this, javax.swing.DefaultListSelectionModel, "clone", []);
\r
312 clone.value = this.value.clone ();
\r
313 clone.listenerList = new javax.swing.event.EventListenerList ();
\r
316 Clazz.overrideMethod (c$, "getAnchorSelectionIndex",
\r
318 return this.anchorIndex;
\r
320 Clazz.overrideMethod (c$, "getLeadSelectionIndex",
\r
322 return this.leadIndex;
\r
324 Clazz.overrideMethod (c$, "setAnchorSelectionIndex",
\r
325 function (anchorIndex) {
\r
326 this.updateLeadAnchorIndices (anchorIndex, this.leadIndex);
\r
327 this.fireValueChanged ();
\r
329 Clazz.defineMethod (c$, "moveLeadSelectionIndex",
\r
330 function (leadIndex) {
\r
331 if (leadIndex == -1) {
\r
332 if (this.anchorIndex != -1) {
\r
334 }}this.updateLeadAnchorIndices (this.anchorIndex, leadIndex);
\r
335 this.fireValueChanged ();
\r
337 Clazz.overrideMethod (c$, "setLeadSelectionIndex",
\r
338 function (leadIndex) {
\r
339 var anchorIndex = this.anchorIndex;
\r
340 if (leadIndex == -1) {
\r
341 if (anchorIndex == -1) {
\r
342 this.updateLeadAnchorIndices (anchorIndex, leadIndex);
\r
343 this.fireValueChanged ();
\r
345 } else if (anchorIndex == -1) {
\r
347 }if (this.leadIndex == -1) {
\r
348 this.leadIndex = leadIndex;
\r
349 }var shouldSelect = this.value.get (this.anchorIndex);
\r
350 if (this.getSelectionMode () == 0) {
\r
351 anchorIndex = leadIndex;
\r
352 shouldSelect = true;
\r
353 }var oldMin = Math.min (this.anchorIndex, this.leadIndex);
\r
354 var oldMax = Math.max (this.anchorIndex, this.leadIndex);
\r
355 var newMin = Math.min (anchorIndex, leadIndex);
\r
356 var newMax = Math.max (anchorIndex, leadIndex);
\r
357 this.updateLeadAnchorIndices (anchorIndex, leadIndex);
\r
358 if (shouldSelect) {
\r
359 this.changeSelection (oldMin, oldMax, newMin, newMax);
\r
361 this.changeSelection (newMin, newMax, oldMin, oldMax, false);
\r
363 Clazz.defineStatics (c$,
\r
365 "MAX", 2147483647);
\r