Changeset 15768 in josm


Ignore:
Timestamp:
2020-01-26T15:43:40+01:00 (4 weeks ago)
Author:
simon04
Message:

Simplify TagInfoViewer.buildTable

File:
1 edited

Legend:

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

    r15581 r15768  
    44import java.awt.event.FocusEvent;
    55import java.awt.event.FocusListener;
    6 import java.util.Arrays;
    76import java.util.Collection;
    8 import java.util.HashMap;
     7import java.util.Collections;
    98import java.util.Map;
    109import java.util.function.IntFunction;
     
    1615
    1716import org.openstreetmap.josm.data.osm.Tagged;
    18 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
    1917import org.openstreetmap.josm.gui.dialogs.properties.CopyAllKeyValueAction;
    2018import org.openstreetmap.josm.gui.dialogs.properties.CopyKeyValueAction;
     
    6260    @Override
    6361    protected JTable buildReferenceTable() {
    64         return buildTable(PointInTimeType.REFERENCE_POINT_IN_TIME, "table.referencetagtable", model::getReferencePointInTime);
     62        return buildTable(PointInTimeType.REFERENCE_POINT_IN_TIME);
    6563    }
    6664
    6765    @Override
    6866    protected JTable buildCurrentTable() {
    69         return buildTable(PointInTimeType.CURRENT_POINT_IN_TIME, "table.currenttagtable", model::getCurrentPointInTime);
     67        return buildTable(PointInTimeType.CURRENT_POINT_IN_TIME);
    7068    }
    7169
    72     private JTable buildTable(PointInTimeType pointInTime, String name, Supplier<HistoryOsmPrimitive> histoSp) {
     70    private JTable buildTable(PointInTimeType pointInTime) {
    7371        TagTableModel tagTableModel = model.getTagTableModel(pointInTime);
    7472        JTable table = new JTable(tagTableModel, new TagTableColumnModel());
    75         table.setName(name);
    7673        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    7774        selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
     
    8279        IntFunction<String> tagKeyFn = x -> (String) table.getValueAt(x, 0);
    8380        IntFunction<Map<String, Integer>> tagValuesFn = x -> {
    84             Map<String, Integer> map = new HashMap<>();
    8581            String key = tagTableModel.getValue((String) table.getValueAt(x, 0));
    8682            if (key != null) {
    87                 map.put(key, 1);
     83                return Collections.singletonMap(key, 1);
    8884            }
    89             return map;
     85            return Collections.emptyMap();
    9086        };
    91         Supplier<Collection<? extends Tagged>> objectSp = () -> Arrays.asList(histoSp.get());
     87        Supplier<Collection<? extends Tagged>> objectSp = () -> Collections.singletonList(model.getPointInTime(pointInTime));
    9288
    9389        tagMenu.add(trackJosmAction(new CopyValueAction(table, tagKeyFn, objectSp)));
Note: See TracChangeset for help on using the changeset viewer.