Ignore:
Timestamp:
2015-12-05T15:38:14+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #12153 - Changing sorting order in Tags/Memberships window and clicking in one tag, edits the wrong tag

File:
1 edited

Legend:

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

    r9084 r9086  
    5353import javax.swing.JPanel;
    5454import javax.swing.JPopupMenu;
     55import javax.swing.JTable;
    5556import javax.swing.KeyStroke;
    5657import javax.swing.ListCellRenderer;
     
    8687 */
    8788class TagEditHelper {
     89    private final JTable tagTable;
    8890    private final DefaultTableModel tagData;
    8991    private final Map<String, Map<String, Integer>> valueCount;
     
    116118    };
    117119
    118     TagEditHelper(DefaultTableModel propertyData, Map<String, Map<String, Integer>> valueCount) {
     120    TagEditHelper(JTable tagTable, DefaultTableModel propertyData, Map<String, Map<String, Integer>> valueCount) {
     121        this.tagTable = tagTable;
    119122        this.tagData = propertyData;
    120123        this.valueCount = valueCount;
     124    }
     125
     126    public final String getDataKey(int viewRow) {
     127        return tagData.getValueAt(tagTable.convertRowIndexToModel(viewRow), 0).toString();
     128    }
     129
     130    @SuppressWarnings("unchecked")
     131    public final Map<String, Integer> getDataValues(int viewRow) {
     132        return (Map<String, Integer>) tagData.getValueAt(tagTable.convertRowIndexToModel(viewRow), 1);
    121133    }
    122134
     
    152164        if (sel == null || sel.isEmpty()) return;
    153165
    154         String key = tagData.getValueAt(row, 0).toString();
     166        String key = getDataKey(row);
    155167        objKey = key;
    156168
    157         @SuppressWarnings("unchecked")
    158         final EditTagDialog editDialog = new EditTagDialog(key,
    159                 (Map<String, Integer>) tagData.getValueAt(row, 1), focusOnKey);
     169        final EditTagDialog editDialog = new EditTagDialog(key, getDataValues(row), focusOnKey);
    160170        editDialog.showDialog();
    161171        if (editDialog.getValue() != 1) return;
     
    567577                }
    568578                for (int i = 0; i < tagData.getRowCount(); ++i) {
    569                     if (item.getValue().equals(tagData.getValueAt(i, 0))) {
     579                    if (item.getValue().equals(getDataKey(i))) {
    570580                        if (itemToSelect == item) {
    571581                            itemToSelect = null;
     
    831841            // performing this action leads to autocomplete to the next key (see #7671 comments)
    832842            for (int j = 0; j < tagData.getRowCount(); ++j) {
    833                 if (t.getKey().equals(tagData.getValueAt(j, 0))) {
     843                if (t.getKey().equals(getDataKey(j))) {
    834844                    action.setEnabled(false);
    835845                    break;
Note: See TracChangeset for help on using the changeset viewer.