101 **************************************************************************/
102
103 /**
104 * Creates a default MultipleSelectionModel instance.
105 */
106 public MultipleSelectionModel() { }
107
108
109
110 /***************************************************************************
111 * *
112 * Public API *
113 * *
114 **************************************************************************/
115
116 /**
117 * <p>Returns a <b>read-only</b> ObservableList of all selected indices. The
118 * ObservableList will be updated by the selection model to always reflect
119 * changes in selection. This can be observed by adding a
120 * {@link ListChangeListener} to the returned ObservableList.
121 */
122 public abstract ObservableList<Integer> getSelectedIndices();
123
124 /**
125 * <p>Returns a <b>read-only</b> ObservableList of all selected items. The
126 * ObservableList will be updated further by the selection model to always reflect
127 * changes in selection. This can be observed by adding a
128 * {@link ListChangeListener} to the returned ObservableList.
129 */
130 public abstract ObservableList<T> getSelectedItems();
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;
|
101 **************************************************************************/
102
103 /**
104 * Creates a default MultipleSelectionModel instance.
105 */
106 public MultipleSelectionModel() { }
107
108
109
110 /***************************************************************************
111 * *
112 * Public API *
113 * *
114 **************************************************************************/
115
116 /**
117 * <p>Returns a <b>read-only</b> ObservableList of all selected indices. The
118 * ObservableList will be updated by the selection model to always reflect
119 * changes in selection. This can be observed by adding a
120 * {@link ListChangeListener} to the returned ObservableList.
121 * @return the list of selected indices
122 */
123 public abstract ObservableList<Integer> getSelectedIndices();
124
125 /**
126 * <p>Returns a <b>read-only</b> ObservableList of all selected items. The
127 * ObservableList will be updated further by the selection model to always reflect
128 * changes in selection. This can be observed by adding a
129 * {@link ListChangeListener} to the returned ObservableList.
130 * @return the list of selected items
131 */
132 public abstract ObservableList<T> getSelectedItems();
133
134 /**
135 * <p>This method allows for one or more selections to be set at the same time.
136 * It will ignore any value that is not within the valid range (i.e. greater
137 * than or equal to zero, and less than the total number of items in the
138 * underlying data model). Any duplication of indices will be ignored.
139 *
140 * <p>If there is already one or more indices selected in this model, calling
141 * this method will <b>not</b> clear these selections - to do so it is
142 * necessary to first call clearSelection.
143 *
144 * <p>The last valid value given will become the selected index / selected
145 * item.
146 * @param index the selected index
147 * @param indices the selected indices
148 */
149 public abstract void selectIndices(int index, int... indices);
150
151 /**
152 * <p>Selects all indices from the given start index to the item before the
153 * given end index. This means that the selection is inclusive of the start
154 * index, and exclusive of the end index. This method will work regardless
155 * of whether start < end or start > end: the only constant is that the
156 * index before the given end index will become the selected index.
157 *
158 * <p>If there is already one or more indices selected in this model, calling
159 * this method will <b>not</b> clear these selections - to do so it is
160 * necessary to first call clearSelection.
161 *
162 * @param start The first index to select - this index will be selected.
163 * @param end The last index of the selection - this index will not be selected.
164 */
165 public void selectRange(final int start, final int end) {
166 if (start == end) return;
167
168 final boolean asc = start < end;
169 final int low = asc ? start : end; // Math.min(start, end);
170 final int high = asc ? end : start; //Math.max(start, end);
171 final int arrayLength = high - low - 1;
172
173 int[] indices = new int[arrayLength];
174
175 int startValue = asc ? low : high;
|