1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.history;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.Rectangle;
|
---|
7 |
|
---|
8 | import javax.swing.JTable;
|
---|
9 | import javax.swing.ListSelectionModel;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * RelationMemberListViewer is a UI component which displays the list of relation members of two
|
---|
13 | * version of a {@link org.openstreetmap.josm.data.osm.Relation} in a {@link org.openstreetmap.josm.data.osm.history.History}.
|
---|
14 | *
|
---|
15 | * <ul>
|
---|
16 | * <li>on the left, it displays the list of relation members for the version at {@link PointInTimeType#REFERENCE_POINT_IN_TIME}</li>
|
---|
17 | * <li>on the right, it displays the list of relation members for the version at {@link PointInTimeType#CURRENT_POINT_IN_TIME}</li>
|
---|
18 | * </ul>
|
---|
19 | * @since 1709
|
---|
20 | */
|
---|
21 | public class RelationMemberListViewer extends HistoryViewerPanel {
|
---|
22 |
|
---|
23 | @Override
|
---|
24 | protected JTable buildTable(PointInTimeType pointInTimeType) {
|
---|
25 | DiffTableModel tableModel = model.getRelationMemberTableModel(pointInTimeType);
|
---|
26 | RelationMemberTableColumnModel columnModel = new RelationMemberTableColumnModel();
|
---|
27 | JTable table = new JTable(tableModel, columnModel);
|
---|
28 | tableModel.addTableModelListener(new ReversedChangeListener(
|
---|
29 | table, columnModel, tr("The members of this relation are in reverse order")));
|
---|
30 | table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
---|
31 | selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
|
---|
32 | table.getModel().addTableModelListener(e -> {
|
---|
33 | Rectangle rect = table.getCellRect(((DiffTableModel) e.getSource()).getFirstChange(), 0, true);
|
---|
34 | table.scrollRectToVisible(rect);
|
---|
35 | });
|
---|
36 | return table;
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Constructs a new {@code RelationMemberListViewer}.
|
---|
41 | * @param model The history browsing model
|
---|
42 | */
|
---|
43 | public RelationMemberListViewer(HistoryBrowserModel model) {
|
---|
44 | super(model);
|
---|
45 | }
|
---|
46 | }
|
---|