001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.history; 003 004import java.awt.Rectangle; 005 006import javax.swing.JTable; 007import javax.swing.ListSelectionModel; 008 009/** 010 * RelationMemberListViewer is a UI component which displays the list of relation members of two 011 * version of a {@link org.openstreetmap.josm.data.osm.Relation} in a {@link org.openstreetmap.josm.data.osm.history.History}. 012 * 013 * <ul> 014 * <li>on the left, it displays the list of relation members for the version at {@link PointInTimeType#REFERENCE_POINT_IN_TIME}</li> 015 * <li>on the right, it displays the list of relation members for the version at {@link PointInTimeType#CURRENT_POINT_IN_TIME}</li> 016 * </ul> 017 * @since 1709 018 */ 019public class RelationMemberListViewer extends HistoryViewerPanel { 020 021 @Override 022 protected JTable buildTable(PointInTimeType pointInTimeType) { 023 JTable table = new JTable( 024 model.getRelationMemberTableModel(pointInTimeType), 025 new RelationMemberTableColumnModel()); 026 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 027 selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel()); 028 table.getModel().addTableModelListener(e -> { 029 Rectangle rect = table.getCellRect(((DiffTableModel) e.getSource()).getFirstChange(), 0, true); 030 table.scrollRectToVisible(rect); 031 }); 032 return table; 033 } 034 035 /** 036 * Constructs a new {@code RelationMemberListViewer}. 037 * @param model The history browsing model 038 */ 039 public RelationMemberListViewer(HistoryBrowserModel model) { 040 super(model); 041 } 042}