Ticket #24507: 24507.patch

File 24507.patch, 2.2 KB (added by GerdP, 5 weeks ago)

sort List for JTable by tag key

  • src/org/openstreetmap/josm/actions/corrector/TagCorrector.java

     
    1313import java.util.Map;
    1414import java.util.Map.Entry;
    1515import java.util.Set;
     16import java.util.stream.Collectors;
    1617
    1718import javax.swing.JLabel;
    1819import javax.swing.JPanel;
     
    3132import org.openstreetmap.josm.gui.correction.RoleCorrectionTable;
    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;
    3638import org.openstreetmap.josm.tools.UserCancelException;
     
    9496            p.add(label2, GBC.eop().anchor(GBC.CENTER).fill(GBC.HORIZONTAL));
    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();
     103                final List<TagCorrection> tagCorrections = entry.getValue().stream()
     104                        .sorted((o1, o2) -> AlphanumComparator.getInstance().compare(o1.oldKey, o2.oldKey))
     105                        .collect(Collectors.toList());
    99106
    100                 if (tagCorrections.isEmpty()) {
    101                     continue;
    102                 }
    103 
    104107                final JLabel propertiesLabel = new JLabel(tr("Tags of "));
    105108                p.add(propertiesLabel, GBC.std());
    106109
     
    111114                );
    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));
    118120