- Timestamp:
- 2016-08-01T23:06:53+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r10680 r10700 4 4 import java.util.ArrayList; 5 5 import java.util.Arrays; 6 import java.util.BitSet; 6 7 import java.util.Collection; 7 8 import java.util.Collections; … … 267 268 getSelectionModel().setValueIsAdjusting(true); 268 269 getSelectionModel().clearSelection(); 270 BitSet selected = new BitSet(); 269 271 for (int row : selectedRows) { 270 272 row--; 271 getSelectionModel().addSelectionInterval(row, row); 272 } 273 selected.set(row); 274 } 275 addToSelectedMembers(selected); 273 276 getSelectionModel().setValueIsAdjusting(false); 274 277 fireMakeMemberVisible(selectedRows[0] - 1); … … 290 293 getSelectionModel().setValueIsAdjusting(true); 291 294 getSelectionModel().clearSelection(); 295 BitSet selected = new BitSet(); 292 296 for (int row : selectedRows) { 293 297 row++; 294 getSelectionModel().addSelectionInterval(row, row); 295 } 298 selected.set(row); 299 } 300 addToSelectedMembers(selected); 296 301 getSelectionModel().setValueIsAdjusting(false); 297 302 fireMakeMemberVisible(selectedRows[0] + 1); … … 530 535 } 531 536 fireTableDataChanged(); 537 BitSet selected = new BitSet(); 532 538 for (int row : idx) { 533 getSelectionModel().addSelectionInterval(row, row); 534 } 539 selected.set(row); 540 } 541 addToSelectedMembers(selected); 535 542 } 536 543 … … 616 623 getSelectionModel().setValueIsAdjusting(true); 617 624 getSelectionModel().clearSelection(); 625 BitSet selected = new BitSet(); 618 626 for (int row : selectedIndices) { 619 getSelectionModel().addSelectionInterval(row, row); 620 } 627 selected.set(row); 628 } 629 addToSelectedMembers(selected); 621 630 getSelectionModel().setValueIsAdjusting(false); 622 631 // make the first selected member visible … … 628 637 629 638 /** 630 * Replies true if the index-th relation members referrs 639 * Add one or more members indices to the selection. 640 * Detect groups of consecutive indices. 641 * Only one costly call of addSelectionInterval is performed for each group 642 643 * @param selectedIndices selected indices as a bitset 644 * @return number of groups 645 */ 646 private int addToSelectedMembers(BitSet selectedIndices) { 647 if (selectedIndices == null || selectedIndices.isEmpty()) { 648 return 0; 649 } 650 // select the members 651 // 652 int start = selectedIndices.nextSetBit(0); 653 int end; 654 int steps = 0; 655 int last = selectedIndices.length(); 656 while (start >= 0) { 657 end = selectedIndices.nextClearBit(start); 658 steps++; 659 getSelectionModel().addSelectionInterval(start, end-1); 660 start = selectedIndices.nextSetBit(end); 661 if (start < 0 || end == last) 662 break; 663 } 664 return steps; 665 } 666 667 /** 668 * Replies true if the index-th relation members refers 631 669 * to an editable relation, i.e. a relation which is not 632 670 * incomplete. 633 671 * 634 672 * @param index the index 635 * @return true, if the index-th relation members refer rs673 * @return true, if the index-th relation members refers 636 674 * to an editable relation, i.e. a relation which is not 637 675 * incomplete … … 694 732 getSelectionModel().setValueIsAdjusting(true); 695 733 getSelectionModel().clearSelection(); 734 BitSet selected = new BitSet(); 696 735 for (int i = 0; i < members.size(); i++) { 697 736 RelationMember m = members.get(i); 698 737 if (primitives.contains(m.getMember())) { 699 this.getSelectionModel().addSelectionInterval(i, i); 700 } 701 } 738 selected.set(i); 739 } 740 } 741 addToSelectedMembers(selected); 702 742 getSelectionModel().setValueIsAdjusting(false); 703 743 if (!getSelectedIndices().isEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.