Changeset 16593 in josm


Ignore:
Timestamp:
2020-06-10T23:43:36+02:00 (2 months ago)
Author:
simon04
Message:

fix #17688 - TagInfoViewer: allow to "restore selected tags" (via popup menu)

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
1 edited

Legend:

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

    r16530 r16593  
    1616import javax.swing.ListSelectionModel;
    1717
     18import org.openstreetmap.josm.actions.RestorePropertyAction;
     19import org.openstreetmap.josm.data.osm.DataSet;
     20import org.openstreetmap.josm.data.osm.OsmPrimitive;
     21import org.openstreetmap.josm.data.osm.PrimitiveId;
    1822import org.openstreetmap.josm.data.osm.Tagged;
     23import org.openstreetmap.josm.gui.MainApplication;
    1924import org.openstreetmap.josm.gui.dialogs.properties.CopyAllKeyValueAction;
    2025import org.openstreetmap.josm.gui.dialogs.properties.CopyKeyValueAction;
     
    7277
    7378        IntFunction<String> tagKeyFn = x -> (String) table.getValueAt(x, 0);
     79        IntFunction<String> tagValueFn = x -> tagTableModel.getValue(tagKeyFn.apply(x));
    7480        IntFunction<Map<String, Integer>> tagValuesFn = x -> {
    75             String key = tagTableModel.getValue((String) table.getValueAt(x, 0));
    76             if (key != null) {
    77                 return Collections.singletonMap(key, 1);
    78             }
    79             return Collections.emptyMap();
     81            String value = tagValueFn.apply(x);
     82            return value != null ? Collections.singletonMap(value, 1) : Collections.emptyMap();
    8083        };
    8184        Supplier<Collection<? extends Tagged>> objectSp = () -> Collections.singletonList(model.getPointInTime(pointInTime));
     85        Supplier<OsmPrimitive> primitiveSupplier = () -> {
     86            DataSet dataSet = MainApplication.getLayerManager().getEditDataSet();
     87            PrimitiveId primitiveId = model.getPointInTime(pointInTime);
     88            if (dataSet == null || primitiveId == null) {
     89                return null;
     90            }
     91            return dataSet.getPrimitiveById(primitiveId.getUniqueId(), primitiveId.getType());
     92        };
    8293
    8394        tagMenu.add(trackJosmAction(new CopyValueAction(table, tagKeyFn, objectSp)));
     
    8697        tagMenu.addPopupMenuListener(copyKeyValueAction);
    8798        tagMenu.add(trackJosmAction(new CopyAllKeyValueAction(table, tagKeyFn, objectSp)));
     99        tagMenu.add(new RestorePropertyAction(tagKeyFn, tagValueFn, primitiveSupplier, table.getSelectionModel()));
    88100        tagMenu.addSeparator();
    89101        tagMenu.add(trackJosmAction(new HelpTagAction(table, tagKeyFn, tagValuesFn)));
Note: See TracChangeset for help on using the changeset viewer.