78 */ 79 protected boolean leadAnchorNotificationEnabled = true; 80 81 /** {@inheritDoc} */ 82 public int getMinSelectionIndex() { return isSelectionEmpty() ? -1 : minIndex; } 83 84 /** {@inheritDoc} */ 85 public int getMaxSelectionIndex() { return maxIndex; } 86 87 /** {@inheritDoc} */ 88 public boolean getValueIsAdjusting() { return isAdjusting; } 89 90 /** {@inheritDoc} */ 91 public int getSelectionMode() { return selectionMode; } 92 93 /** 94 * {@inheritDoc} 95 * @throws IllegalArgumentException {@inheritDoc} 96 */ 97 public void setSelectionMode(int selectionMode) { 98 switch (selectionMode) { 99 case SINGLE_SELECTION: 100 case SINGLE_INTERVAL_SELECTION: 101 case MULTIPLE_INTERVAL_SELECTION: 102 this.selectionMode = selectionMode; 103 break; 104 default: 105 throw new IllegalArgumentException("invalid selectionMode"); 106 } 107 } 108 109 /** {@inheritDoc} */ 110 public boolean isSelectedIndex(int index) { 111 return ((index < minIndex) || (index > maxIndex)) ? false : value.get(index); 112 } 113 114 /** {@inheritDoc} */ 115 public boolean isSelectionEmpty() { 116 return (minIndex > maxIndex); 117 } 118 119 /** {@inheritDoc} */ 120 public void addListSelectionListener(ListSelectionListener l) { 121 listenerList.add(ListSelectionListener.class, l); 122 } 123 124 /** {@inheritDoc} */ 125 public void removeListSelectionListener(ListSelectionListener l) { | 78 */ 79 protected boolean leadAnchorNotificationEnabled = true; 80 81 /** {@inheritDoc} */ 82 public int getMinSelectionIndex() { return isSelectionEmpty() ? -1 : minIndex; } 83 84 /** {@inheritDoc} */ 85 public int getMaxSelectionIndex() { return maxIndex; } 86 87 /** {@inheritDoc} */ 88 public boolean getValueIsAdjusting() { return isAdjusting; } 89 90 /** {@inheritDoc} */ 91 public int getSelectionMode() { return selectionMode; } 92 93 /** 94 * {@inheritDoc} 95 * @throws IllegalArgumentException {@inheritDoc} 96 */ 97 public void setSelectionMode(int selectionMode) { 98 int oldMode = this.selectionMode; 99 switch (selectionMode) { 100 case SINGLE_SELECTION: 101 case SINGLE_INTERVAL_SELECTION: 102 case MULTIPLE_INTERVAL_SELECTION: 103 this.selectionMode = selectionMode; 104 break; 105 default: 106 throw new IllegalArgumentException("invalid selectionMode"); 107 } 108 109 /* 110 This code will only be executed when selection needs to be updated on changing selection mode. 111 It will happen only if selection mode is changed from MULTIPLE_INTERVAL to SINGLE_INTERVAL or SINGLE 112 or from SINGLE_INTERVAL to SINGLE 113 */ 114 if (oldMode > this.selectionMode) { 115 if (this.selectionMode == SINGLE_SELECTION) { 116 setSelectionInterval(minIndex, minIndex); 117 } else if (this.selectionMode == SINGLE_INTERVAL_SELECTION) { 118 int selectionEndindex = minIndex; 119 while (value.get(selectionEndindex+1)) { 120 selectionEndindex++; 121 } 122 setSelectionInterval(minIndex, selectionEndindex); 123 } 124 } 125 } 126 127 /** {@inheritDoc} */ 128 public boolean isSelectedIndex(int index) { 129 return ((index < minIndex) || (index > maxIndex)) ? false : value.get(index); 130 } 131 132 /** {@inheritDoc} */ 133 public boolean isSelectionEmpty() { 134 return (minIndex > maxIndex); 135 } 136 137 /** {@inheritDoc} */ 138 public void addListSelectionListener(ListSelectionListener l) { 139 listenerList.add(ListSelectionListener.class, l); 140 } 141 142 /** {@inheritDoc} */ 143 public void removeListSelectionListener(ListSelectionListener l) { |