131
132 /**
133 * <p>This method allows for one or more selections to be set at the same time.
134 * It will ignore any value that is not within the valid range (i.e. greater
135 * than or equal to zero, and less than the total number of items in the
136 * underlying data model). Any duplication of indices will be ignored.
137 *
138 * <p>If there is already one or more indices selected in this model, calling
139 * this method will <b>not</b> clear these selections - to do so it is
140 * necessary to first call clearSelection.
141 *
142 * <p>The last valid value given will become the selected index / selected
143 * item.
144 */
145 public abstract void selectIndices(int index, int... indices);
146
147 /**
148 * <p>Selects all indices from the given start index to the item before the
149 * given end index. This means that the selection is inclusive of the start
150 * index, and exclusive of the end index. This method will work regardless
151 * of whether start < end or start > end: the only constant is that the
152 * index before the given end index will become the selected index.
153 *
154 * <p>If there is already one or more indices selected in this model, calling
155 * this method will <b>not</b> clear these selections - to do so it is
156 * necessary to first call clearSelection.
157 *
158 * @param start The first index to select - this index will be selected.
159 * @param end The last index of the selection - this index will not be selected.
160 */
161 public void selectRange(final int start, final int end) {
162 if (start == end) return;
163
164 final boolean asc = start < end;
165 final int low = asc ? start : end; // Math.min(start, end);
166 final int high = asc ? end : start; //Math.max(start, end);
167 final int arrayLength = high - low - 1;
168
169 int[] indices = new int[arrayLength];
170
171 int startValue = asc ? low : high;
|
131
132 /**
133 * <p>This method allows for one or more selections to be set at the same time.
134 * It will ignore any value that is not within the valid range (i.e. greater
135 * than or equal to zero, and less than the total number of items in the
136 * underlying data model). Any duplication of indices will be ignored.
137 *
138 * <p>If there is already one or more indices selected in this model, calling
139 * this method will <b>not</b> clear these selections - to do so it is
140 * necessary to first call clearSelection.
141 *
142 * <p>The last valid value given will become the selected index / selected
143 * item.
144 */
145 public abstract void selectIndices(int index, int... indices);
146
147 /**
148 * <p>Selects all indices from the given start index to the item before the
149 * given end index. This means that the selection is inclusive of the start
150 * index, and exclusive of the end index. This method will work regardless
151 * of whether start < end or start > end: the only constant is that the
152 * index before the given end index will become the selected index.
153 *
154 * <p>If there is already one or more indices selected in this model, calling
155 * this method will <b>not</b> clear these selections - to do so it is
156 * necessary to first call clearSelection.
157 *
158 * @param start The first index to select - this index will be selected.
159 * @param end The last index of the selection - this index will not be selected.
160 */
161 public void selectRange(final int start, final int end) {
162 if (start == end) return;
163
164 final boolean asc = start < end;
165 final int low = asc ? start : end; // Math.min(start, end);
166 final int high = asc ? end : start; //Math.max(start, end);
167 final int arrayLength = high - low - 1;
168
169 int[] indices = new int[arrayLength];
170
171 int startValue = asc ? low : high;
|