| | 26 | then |
| | 27 | {{{ |
| | 28 | #!java |
| | 29 | /** |
| | 30 | * Insert length indices beginning before/after index. If the value |
| | 31 | * at index is itself selected and the selection mode is not |
| | 32 | * SINGLE_SELECTION, set all of the newly inserted items as selected. |
| | 33 | * Otherwise leave them unselected. This method is typically |
| | 34 | * called to sync the selection model with a corresponding change |
| | 35 | * in the data model. |
| | 36 | */ |
| | 37 | public void insertIndexInterval(int index, int length, boolean before) |
| | 38 | { |
| | 39 | /* The first new index will appear at insMinIndex and the last |
| | 40 | * one will appear at insMaxIndex |
| | 41 | */ |
| | 42 | int insMinIndex = (before) ? index : index + 1; |
| | 43 | int insMaxIndex = (insMinIndex + length) - 1; |
| | 44 | |
| | 45 | /* Right shift the entire bitset by length, beginning with |
| | 46 | * index-1 if before is true, index+1 if it's false (i.e. with |
| | 47 | * insMinIndex). |
| | 48 | */ |
| | 49 | for(int i = maxIndex; i >= insMinIndex; i--) { |
| | 50 | setState(i + length, value.get(i)); // <- selection changes here |
| | 51 | } |
| | 52 | }}} |