Last change
on this file since 4498 was 3083, checked in by bastiK, 14 years ago |
added svn:eol-style=native to source files
|
-
Property svn:eol-style
set to
native
|
File size:
1.2 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.history;
|
---|
3 |
|
---|
4 | import java.util.ArrayList;
|
---|
5 |
|
---|
6 | import javax.swing.DefaultListSelectionModel;
|
---|
7 | import javax.swing.ListSelectionModel;
|
---|
8 | import javax.swing.event.ListSelectionEvent;
|
---|
9 | import javax.swing.event.ListSelectionListener;
|
---|
10 |
|
---|
11 | public 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.