Changeset 8996 in josm


Ignore:
Timestamp:
2015-11-07T18:42:58+01:00 (9 years ago)
Author:
simon04
Message:

fix #12073 - Properties dialog: make sorting by values work w/o CCE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r8985 r8996  
    9898import org.openstreetmap.josm.gui.widgets.JosmTextField;
    9999import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
     100import org.openstreetmap.josm.tools.AlphanumComparator;
    100101import org.openstreetmap.josm.tools.GBC;
    101102import org.openstreetmap.josm.tools.ImageProvider;
     
    307308        tagTable.getColumnModel().getColumn(1).setCellRenderer(cellRenderer);
    308309        tagTable.setRowSorter(tagRowSorter);
     310
     311        tagRowSorter.setComparator(0, AlphanumComparator.getInstance());
     312        tagRowSorter.setComparator(1, new Comparator<Object>() {
     313            @Override
     314            public int compare(Object o1, Object o2) {
     315                if (o1 instanceof Map && o2 instanceof Map) {
     316                    final String v1 = ((Map) o1).size() == 1 ? (String) ((Map) o1).keySet().iterator().next() : tr("<different>");
     317                    final String v2 = ((Map) o2).size() == 1 ? (String) ((Map) o2).keySet().iterator().next() : tr("<different>");
     318                    return AlphanumComparator.getInstance().compare(v1, v2);
     319                } else {
     320                    return AlphanumComparator.getInstance().compare(String.valueOf(o1), String.valueOf(o2));
     321                }
     322            }
     323        });
    309324    }
    310325
Note: See TracChangeset for help on using the changeset viewer.