239 |
public void setLeadSelectionIndex(int leadIndex) |
public void setLeadSelectionIndex(int leadIndex) |
240 |
{ |
{ |
241 |
int oldLeadIndex = leadSelectionIndex; |
int oldLeadIndex = leadSelectionIndex; |
242 |
|
if (oldLeadIndex == -1) |
243 |
|
oldLeadIndex = leadIndex; |
244 |
if (setLeadCalledFromAdd == false) |
if (setLeadCalledFromAdd == false) |
245 |
oldSel = sel.clone(); |
oldSel = sel.clone(); |
246 |
leadSelectionIndex = leadIndex; |
leadSelectionIndex = leadIndex; |
247 |
|
|
248 |
if (anchorSelectionIndex == -1) |
if (anchorSelectionIndex == -1) |
249 |
return; |
return; |
250 |
|
|
251 |
int R1 = Math.min(anchorSelectionIndex, oldLeadIndex); |
int R1 = Math.min(anchorSelectionIndex, oldLeadIndex); |
252 |
int R2 = Math.max(anchorSelectionIndex, oldLeadIndex); |
int R2 = Math.max(anchorSelectionIndex, oldLeadIndex); |
253 |
int S1 = Math.min(anchorSelectionIndex, leadIndex); |
int S1 = Math.min(anchorSelectionIndex, leadIndex); |
256 |
int lo = Math.min(R1, S1); |
int lo = Math.min(R1, S1); |
257 |
int hi = Math.max(R2, S2); |
int hi = Math.max(R2, S2); |
258 |
|
|
|
BitSet oldRange = sel.get(lo, hi+1); |
|
|
|
|
259 |
if (isSelectedIndex(anchorSelectionIndex)) |
if (isSelectedIndex(anchorSelectionIndex)) |
260 |
{ |
{ |
261 |
sel.clear(R1, R2+1); |
sel.clear(R1, R2+1); |
265 |
{ |
{ |
266 |
sel.set(R1, R2+1); |
sel.set(R1, R2+1); |
267 |
sel.clear(S1, S2+1); |
sel.clear(S1, S2+1); |
268 |
} |
} |
|
|
|
|
BitSet newRange = sel.get(lo, hi+1); |
|
|
newRange.xor(oldRange); |
|
269 |
|
|
270 |
int beg = sel.nextSetBit(0), end = -1; |
int beg = sel.nextSetBit(0), end = -1; |
271 |
for(int i=beg; i >= 0; i=sel.nextSetBit(i+1)) |
for(int i=beg; i >= 0; i=sel.nextSetBit(i+1)) |
275 |
} |
} |
276 |
|
|
277 |
/** |
/** |
278 |
|
* Moves the lead selection index to <code>leadIndex</code> without |
279 |
|
* changing the selection values. |
280 |
|
* |
281 |
|
* If leadAnchorNotificationEnabled is true, send a notification covering the |
282 |
|
* old and new lead cells. |
283 |
|
* |
284 |
|
* @param leadIndex the new lead selection index |
285 |
|
* @since 1.5 |
286 |
|
*/ |
287 |
|
public void moveLeadSelectionIndex (int leadIndex) |
288 |
|
{ |
289 |
|
if (leadSelectionIndex == leadIndex) |
290 |
|
return; |
291 |
|
|
292 |
|
leadSelectionIndex = leadIndex; |
293 |
|
if (isLeadAnchorNotificationEnabled()) |
294 |
|
fireValueChanged(Math.min(leadSelectionIndex, leadIndex), |
295 |
|
Math.max(leadSelectionIndex, leadIndex)); |
296 |
|
} |
297 |
|
|
298 |
|
/** |
299 |
* Gets the value of the {@link #leadAnchorNotificationEnabled} property. |
* Gets the value of the {@link #leadAnchorNotificationEnabled} property. |
300 |
* |
* |
301 |
* @return The current property value |
* @return The current property value |