Changeset 19444 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2025-10-15T16:18:24+02:00 (6 days ago)
Author:
GerdP
Message:

fix #24507: automatic tag corrections not always sorted alphabetically

  • sort tags by key and List of roles by relation (similar to the properties dialog)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/corrector/TagCorrector.java

    r17733 r19444  
    1414import java.util.Map.Entry;
    1515import java.util.Set;
     16import java.util.stream.Collectors;
    1617
    1718import javax.swing.JLabel;
     
    3233import org.openstreetmap.josm.gui.correction.TagCorrectionTable;
    3334import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
     35import org.openstreetmap.josm.tools.AlphanumComparator;
    3436import org.openstreetmap.josm.tools.GBC;
    3537import org.openstreetmap.josm.tools.ImageProvider;
     
    9597
    9698            for (Entry<OsmPrimitive, List<TagCorrection>> entry : tagCorrectionsMap.entrySet()) {
     99                if (entry.getValue().isEmpty())
     100                    continue;
     101
    97102                final OsmPrimitive primitive = entry.getKey();
    98                 final List<TagCorrection> tagCorrections = entry.getValue();
    99 
    100                 if (tagCorrections.isEmpty()) {
    101                     continue;
    102                 }
     103                final List<TagCorrection> tagCorrections = entry.getValue().stream()
     104                        .sorted((o1, o2) -> AlphanumComparator.getInstance().compare(o1.oldKey, o2.oldKey))
     105                        .collect(Collectors.toList());
    103106
    104107                final JLabel propertiesLabel = new JLabel(tr("Tags of "));
     
    112115                p.add(primitiveLabel, GBC.eol());
    113116
    114                 final TagCorrectionTable table = new TagCorrectionTable(
    115                         tagCorrections);
     117                final TagCorrectionTable table = new TagCorrectionTable(tagCorrections);
    116118                final JScrollPane scrollPane = new JScrollPane(table);
    117119                p.add(scrollPane, GBC.eop().fill(GBC.BOTH));
     
    121123
    122124            for (Entry<OsmPrimitive, List<RoleCorrection>> entry : roleCorrectionMap.entrySet()) {
     125                if (entry.getValue().isEmpty())
     126                    continue;
     127
    123128                final OsmPrimitive primitive = entry.getKey();
    124                 final List<RoleCorrection> roleCorrections = entry.getValue();
    125 
    126                 if (roleCorrections.isEmpty()) {
    127                     continue;
    128                 }
     129                final List<RoleCorrection> roleCorrections = entry.getValue().stream()
     130                        .sorted((o1, o2) -> DefaultNameFormatter.getInstance().getRelationComparator()
     131                                .compare(o1.relation, o2.relation))
     132                        .collect(Collectors.toList());
    129133
    130134                final JLabel rolesLabel = new JLabel(tr("Roles in relations referring to"));
Note: See TracChangeset for help on using the changeset viewer.