001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.history;
003
004import javax.swing.JTable;
005import javax.swing.ListSelectionModel;
006
007/**
008 * TagInfoViewer is a UI component which displays the list of tags of two
009 * version of a {@link org.openstreetmap.josm.data.osm.OsmPrimitive} in a {@link org.openstreetmap.josm.data.osm.history.History}.
010 *
011 * <ul>
012 *   <li>on the left, it displays the list of tags for the version at {@link PointInTimeType#REFERENCE_POINT_IN_TIME}</li>
013 *   <li>on the right, it displays the list of tags for the version at {@link PointInTimeType#CURRENT_POINT_IN_TIME}</li>
014 * </ul>
015 *
016 */
017public class TagInfoViewer extends HistoryViewerPanel {
018
019    @Override
020    protected JTable buildReferenceTable() {
021        JTable table = new JTable(
022                model.getTagTableModel(PointInTimeType.REFERENCE_POINT_IN_TIME),
023                new TagTableColumnModel()
024        );
025        table.setName("table.referencetagtable");
026        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
027        selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
028        return table;
029    }
030
031    @Override
032    protected JTable buildCurrentTable() {
033        JTable table = new JTable(
034                model.getTagTableModel(PointInTimeType.CURRENT_POINT_IN_TIME),
035                new TagTableColumnModel()
036        );
037        table.setName("table.currenttagtable");
038        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
039        selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
040        return table;
041    }
042
043    /**
044     * Constructs a new {@code TagInfoViewer}.
045     * @param model The history browsing model
046     */
047    public TagInfoViewer(HistoryBrowserModel model) {
048        super(model);
049    }
050}