Changeset 11207 in josm


Ignore:
Timestamp:
2016-11-01T20:14:16+01:00 (18 months ago)
Author:
simon04
Message:

fix #13808 see #12030 - Custom system shortcuts are broken

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r11173 r11207  
    77import java.util.ArrayList;
    88import java.util.Arrays;
    9 import java.util.Collection;
    109import java.util.Comparator;
    1110import java.util.HashMap;
     
    272271
    273272    // here we store our shortcuts
    274     private static Collection<Shortcut> shortcuts = new CopyOnWriteArrayList<Shortcut>() {
     273    private static ShortcutCollection shortcuts = new ShortcutCollection();
     274
     275    private static class ShortcutCollection extends CopyOnWriteArrayList<Shortcut> {
    275276        @Override
    276277        public boolean add(Shortcut shortcut) {
     
    281282            }
    282283            return super.add(shortcut);
     284        }
     285
     286        public void replace(Shortcut newShortcut) {
     287            final Optional<Shortcut> existing = findShortcutByKeyOrShortText(-1, NONE, newShortcut.shortText);
     288            if (existing.isPresent()) {
     289                replaceAll(sc -> existing.get() == sc ? newShortcut : sc);
     290            } else {
     291                add(newShortcut);
     292            }
    283293        }
    284294    };
     
    369379                .filter(sc -> !findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()).isPresent())
    370380                .sorted(Comparator.comparing(sc -> sc.isAssignedUser() ? 1 : sc.isAssignedDefault() ? 2 : 3))
    371                 .forEachOrdered(shortcuts::add);
     381                .forEachOrdered(shortcuts::replace);
    372382    }
    373383
Note: See TracChangeset for help on using the changeset viewer.