Changeset 16609 in josm for trunk/src/org/openstreetmap/josm/gui/history/SelectionSynchronizer.java
- Timestamp:
- 2020-06-11T22:48:46+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/SelectionSynchronizer.java
r16601 r16609 4 4 import java.util.Arrays; 5 5 import java.util.HashSet; 6 import java.util.Objects; 6 7 import java.util.Set; 8 import java.util.function.BiFunction; 9 import java.util.stream.IntStream; 7 10 8 import javax.swing.DefaultListSelectionModel;9 11 import javax.swing.ListSelectionModel; 10 12 import javax.swing.event.ListSelectionEvent; … … 23 25 private final Set<ListSelectionModel> participants; 24 26 private boolean preventRecursion; 27 private BiFunction<Integer, ListSelectionModel, IntStream> selectionIndexMapper = (i, model) -> IntStream.of(i); 25 28 26 29 /** … … 47 50 } 48 51 52 void setSelectionIndexMapper(BiFunction<Integer, ListSelectionModel, IntStream> selectionIndexMapper) { 53 this.selectionIndexMapper = Objects.requireNonNull(selectionIndexMapper); 54 } 55 49 56 @Override 50 57 public void valueChanged(ListSelectionEvent e) { … … 53 60 } 54 61 preventRecursion = true; 55 DefaultListSelectionModel referenceModel = (DefaultListSelectionModel) e.getSource();62 ListSelectionModel referenceModel = (ListSelectionModel) e.getSource(); 56 63 int[] selectedIndices = TableHelper.getSelectedIndices(referenceModel); 57 64 for (ListSelectionModel model : participants) { 58 if (model == e.getSource()) {65 if (model == referenceModel) { 59 66 continue; 60 67 } 61 TableHelper.setSelectedIndices(model, Arrays.stream(selectedIndices)); 68 TableHelper.setSelectedIndices(model, 69 Arrays.stream(selectedIndices).flatMap(i -> selectionIndexMapper.apply(i, referenceModel))); 62 70 } 63 71 preventRecursion = false;
Note:
See TracChangeset
for help on using the changeset viewer.