/[classpath]/classpath/javax/swing/DefaultListSelectionModel.java
ViewVC logotype

Diff of /classpath/javax/swing/DefaultListSelectionModel.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by rabbit78, Mon Oct 17 15:16:46 2005 UTC revision 1.23 by abalkiss, Tue Oct 18 17:48:03 2005 UTC
# Line 239  public class DefaultListSelectionModel i Line 239  public class DefaultListSelectionModel i
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);
# Line 254  public class DefaultListSelectionModel i Line 256  public class DefaultListSelectionModel i
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);
# Line 265  public class DefaultListSelectionModel i Line 265  public class DefaultListSelectionModel i
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))
# Line 278  public class DefaultListSelectionModel i Line 275  public class DefaultListSelectionModel i
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

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26