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

Last change on this file since 2556 was 2512, checked in by stoecker, 14 years ago

i18n updated, fixed files to reduce problems when applying patches, fix #4017

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 public void valueChanged(ListSelectionEvent e) {
29 DefaultListSelectionModel referenceModel = (DefaultListSelectionModel)e.getSource();
30 int i = referenceModel.getMinSelectionIndex();
31 for (ListSelectionModel model : participants) {
32 if (model == e.getSource()) {
33 continue;
34 }
35 model.setSelectionInterval(i,i);
36 }
37 }
38}
Note: See TracBrowser for help on using the repository browser.