Changeset 14675 in josm


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

HistoryViewer: fix code duplication

Location:
trunk/src/org/openstreetmap/josm/gui/history
Files:
2 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());
  • trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListViewer.java

    r14463 r14675  
    3737    @Override
    3838    protected JTable buildReferenceTable() {
    39         JTable table = new JTable(
    40                 model.getRelationMemberTableModel(PointInTimeType.REFERENCE_POINT_IN_TIME),
    41                 new RelationMemberTableColumnModel()
    42                 );
    43         table.setName("table.referencememberlisttable");
    44         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    45         selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
    46         table.getModel().addTableModelListener(new MemberModelChanged(table));
    47         return table;
     39        return buildTable(PointInTimeType.REFERENCE_POINT_IN_TIME, "table.referencememberlisttable");
    4840    }
    4941
    5042    @Override
    5143    protected JTable buildCurrentTable() {
     44        return buildTable(PointInTimeType.CURRENT_POINT_IN_TIME, "table.currentmemberlisttable");
     45    }
     46
     47    private JTable buildTable(PointInTimeType pointInTimeType, String name) {
    5248        JTable table = new JTable(
    53                 model.getRelationMemberTableModel(PointInTimeType.CURRENT_POINT_IN_TIME),
    54                 new RelationMemberTableColumnModel()
    55                 );
    56         table.setName("table.currentmemberlisttable");
     49                model.getRelationMemberTableModel(pointInTimeType),
     50                new RelationMemberTableColumnModel());
     51        table.setName(name);
    5752        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    5853        selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
Note: See TracChangeset for help on using the changeset viewer.