source: josm/trunk/src/org/openstreetmap/josm/gui/history/SelectionSynchronizer.java@ 6084

Last change on this file since 6084 was 6084, checked in by bastiK, 11 years ago

see #8902 - add missing @Override annotations (patch by shinigami)

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.history;
3
4import java.util.ArrayList;
5
6import javax.swing.DefaultListSelectionModel;
7import javax.swing.ListSelectionModel;
8import javax.swing.event.ListSelectionEvent;
9import javax.swing.event.ListSelectionListener;
10
11public class SelectionSynchronizer implements ListSelectionListener {
12
13 private ArrayList<ListSelectionModel> participants;
14
15 public SelectionSynchronizer() {
16 participants = new ArrayList<ListSelectionModel>();
17 }
18
19 public void participateInSynchronizedSelection(ListSelectionModel model) {
20 if (model == null)
21 return;
22 if (participants.contains(model))
23 return;
24 participants.add(model);
25 model.addListSelectionListener(this);
26 }
27
28 @Override
29 public void valueChanged(ListSelectionEvent e) {
30 DefaultListSelectionModel referenceModel = (DefaultListSelectionModel)e.getSource();
31 int i = referenceModel.getMinSelectionIndex();
32 for (ListSelectionModel model : participants) {
33 if (model == e.getSource()) {
34 continue;
35 }
36 model.setSelectionInterval(i,i);
37 }
38 }
39}
Note: See TracBrowser for help on using the repository browser.