[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commit-cp] classpath ChangeLog javax/swing/DefaultListSele...
From: |
David Gilbert |
Subject: |
[commit-cp] classpath ChangeLog javax/swing/DefaultListSele... |
Date: |
Wed, 21 Jun 2006 21:01:32 +0000 |
CVSROOT: /sources/classpath
Module name: classpath
Changes by: David Gilbert <trebligd> 06/06/21 21:01:32
Modified files:
. : ChangeLog
javax/swing : DefaultListSelectionModel.java
Log message:
2006-06-21 David Gilbert <address@hidden>
* javax/swing/DefaultListSelectionModel.java
(getSelectionMode): Updated API docs,
(setAnchorSelectionIndex): Added ListSelectionEvent generation,
(addSelectionInterval): If mode is SINGLE_SELECTION, just call
setSelectionInterval(),
(setSelectionInterval): Reimplemented SINGLE_SELECTION and
SINGLE_INTERVAL_SELECTION cases.
----------------------------------------------------------------------
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7905&r2=1.7906
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/swing/DefaultListSelectionModel.java?cvsroot=classpath&r1=1.31&r2=1.32
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7905
retrieving revision 1.7906
diff -u -b -r1.7905 -r1.7906
--- ChangeLog 21 Jun 2006 17:04:41 -0000 1.7905
+++ ChangeLog 21 Jun 2006 21:01:30 -0000 1.7906
@@ -1,3 +1,13 @@
+2006-06-21 David Gilbert <address@hidden>
+
+ * javax/swing/DefaultListSelectionModel.java
+ (getSelectionMode): Updated API docs,
+ (setAnchorSelectionIndex): Added ListSelectionEvent generation,
+ (addSelectionInterval): If mode is SINGLE_SELECTION, just call
+ setSelectionInterval(),
+ (setSelectionInterval): Reimplemented SINGLE_SELECTION and
+ SINGLE_INTERVAL_SELECTION cases.
+
2006-06-21 Roman Kennke <address@hidden>
* javax/swing/text/AbstractDocument.java
Index: javax/swing/DefaultListSelectionModel.java
===================================================================
RCS file:
/sources/classpath/classpath/javax/swing/DefaultListSelectionModel.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- javax/swing/DefaultListSelectionModel.java 26 Apr 2006 15:29:34 -0000
1.31
+++ javax/swing/DefaultListSelectionModel.java 21 Jun 2006 21:01:32 -0000
1.32
@@ -150,9 +150,14 @@
boolean setLeadCalledFromAdd = false;
/**
- * Gets the value of the address@hidden #selectionMode} property.
+ * Returns the selection mode, which is one of address@hidden
#SINGLE_SELECTION},
+ * address@hidden #SINGLE_INTERVAL_SELECTION} and
+ * address@hidden #MULTIPLE_INTERVAL_SELECTION}. The default value is
+ * address@hidden #MULTIPLE_INTERVAL_SELECTION}.
*
- * @return The current value of the property
+ * @return The selection mode.
+ *
+ * @see #setSelectionMode(int)
*/
public int getSelectionMode()
{
@@ -187,13 +192,19 @@
/**
* Sets the value of the address@hidden #anchorSelectionIndex} property.
*
- * @param anchorIndex The new property value
+ * @param index The new property value
*
* @see #getAnchorSelectionIndex
*/
- public void setAnchorSelectionIndex(int anchorIndex)
+ public void setAnchorSelectionIndex(int index)
+ {
+ if (anchorSelectionIndex != index)
{
- anchorSelectionIndex = anchorIndex;
+ int old = anchorSelectionIndex;
+ anchorSelectionIndex = index;
+ if (leadAnchorNotificationEnabled)
+ fireValueChanged(index, old);
+ }
}
/**
@@ -459,12 +470,14 @@
if (index0 == -1 || index1 == -1)
return;
+ if (selectionMode == SINGLE_SELECTION)
+ setSelectionInterval(index0, index1);
+ else
+ {
int lo = Math.min(index0, index1);
int hi = Math.max(index0, index1);
oldSel = sel.clone();
- if (selectionMode == SINGLE_SELECTION)
- setSelectionInterval(index0, index1);
// COMPAT: Like Sun (but not like IBM), we allow calls to
// addSelectionInterval when selectionMode is
@@ -504,6 +517,7 @@
fireDifference(sel, (BitSet) oldSel);
}
}
+ }
/**
@@ -588,28 +602,83 @@
* the current selection mode is <code>SINGLE_SELECTION</code> only the
* index <code>index2</code> is selected.
*
- * @param index0 The low end of the new selection
- * @param index1 The high end of the new selection
+ * @param anchor the anchor selection index.
+ * @param lead the lead selection index.
*/
- public void setSelectionInterval(int index0, int index1)
+ public void setSelectionInterval(int anchor, int lead)
{
- if (index0 == -1 || index1 == -1)
+ if (anchor == -1 || lead == -1)
return;
+ if (selectionMode == SINGLE_SELECTION)
+ {
+ int lo = lead;
+ int hi = lead;
+ int selected = sel.nextSetBit(0);
+ if (selected == lead)
+ return; // the selection is not changing
+ if (selected >= 0)
+ {
+ lo = Math.min(lo, selected);
+ hi = Math.max(hi, selected);
+ }
+ if (anchorSelectionIndex >= 0)
+ {
+ lo = Math.min(lo, anchorSelectionIndex);
+ hi = Math.max(hi, anchorSelectionIndex);
+ }
+ sel.clear();
+ sel.set(lead);
+ leadSelectionIndex = lead;
+ anchorSelectionIndex = lead;
+ fireValueChanged(lo, hi);
+ }
+ else if (selectionMode == SINGLE_INTERVAL_SELECTION)
+ {
+ // determine the current interval
+ int first = sel.nextSetBit(0);
+ int last = first;
+ if (first >= 0)
+ last += (sel.cardinality() - 1);
+
+ // update the selection
+ int lo = Math.min(anchor, lead);
+ int hi = Math.max(anchor, lead);
+ if (lo == first && hi == last)
+ return; // selected interval is not being changed
+ sel.clear();
+ sel.set(lo, hi + 1);
+ // include the old selection in the event range
+ if (first >= 0)
+ lo = Math.min(lo, first);
+ if (last >= 0)
+ hi = Math.max(hi, last);
+ if (anchorSelectionIndex >= 0)
+ {
+ lo = Math.min(lo, anchorSelectionIndex);
+ hi = Math.max(hi, anchorSelectionIndex);
+ }
+ anchorSelectionIndex = anchor;
+ leadSelectionIndex = lead;
+ fireValueChanged(lo, hi);
+ }
+ else
+ {
BitSet oldSel = (BitSet) sel.clone();
sel.clear();
if (selectionMode == SINGLE_SELECTION)
- index0 = index1;
+ anchor = lead;
- int lo = Math.min(index0, index1);
- int hi = Math.max(index0, index1);
+ int lo = Math.min(anchor, lead);
+ int hi = Math.max(anchor, lead);
sel.set(lo, hi+1);
// update the anchorSelectionIndex and leadSelectionIndex variables
- setAnchorSelectionIndex(index0);
- leadSelectionIndex=index1;
+ setAnchorSelectionIndex(anchor);
+ leadSelectionIndex = lead;
fireDifference(sel, oldSel);
}
+ }
/**
* Inserts a number of indices either before or after a particular
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [commit-cp] classpath ChangeLog javax/swing/DefaultListSele...,
David Gilbert <=