source: josm/trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListViewer.java@ 16457

Last change on this file since 16457 was 16456, checked in by simon04, 4 years ago

fix #19161 - History/RelationMemberListViewer: show reversed diff indicator

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.history;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Rectangle;
7
8import javax.swing.JTable;
9import 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 */
21public 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}
Note: See TracBrowser for help on using the repository browser.