Ignore:
Timestamp:
2019-01-12T14:30:57+01:00 (5 weeks ago)
Author:
simon04
Message:

HistoryViewer: fix code duplication

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java

    r14483 r14675  
    5555    @Override
    5656    protected JTable buildReferenceTable() {
    57         final DiffTableModel tableModel = model.getNodeListTableModel(PointInTimeType.REFERENCE_POINT_IN_TIME);
     57        return buildTable(PointInTimeType.REFERENCE_POINT_IN_TIME, "table.referencenodelisttable");
     58    }
     59
     60    @Override
     61    protected JTable buildCurrentTable() {
     62        return buildTable(PointInTimeType.CURRENT_POINT_IN_TIME, "table.currentnodelisttable");
     63    }
     64
     65    private JTable buildTable(PointInTimeType pointInTimeType, String name) {
     66        final DiffTableModel tableModel = model.getNodeListTableModel(pointInTimeType);
    5867        final NodeListTableColumnModel columnModel = new NodeListTableColumnModel();
    5968        final JTable table = new JTable(tableModel, columnModel);
    6069        tableModel.addTableModelListener(new ReversedChangeListener(table, columnModel));
    61         table.setName("table.referencenodelisttable");
    62         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    63         selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
    64         table.addMouseListener(new InternalPopupMenuLauncher());
    65         table.addMouseListener(new DoubleClickAdapter(table));
    66         return table;
    67     }
    68 
    69     @Override
    70     protected JTable buildCurrentTable() {
    71         final DiffTableModel tableModel = model.getNodeListTableModel(PointInTimeType.CURRENT_POINT_IN_TIME);
    72         final NodeListTableColumnModel columnModel = new NodeListTableColumnModel();
    73         final JTable table = new JTable(tableModel, columnModel);
    74         tableModel.addTableModelListener(new ReversedChangeListener(table, columnModel));
    75         table.setName("table.currentnodelisttable");
     70        table.setName(name);
    7671        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    7772        selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
Note: See TracChangeset for help on using the changeset viewer.