Changeset 11207 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-11-01T20:14:16+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r11173 r11207 7 7 import java.util.ArrayList; 8 8 import java.util.Arrays; 9 import java.util.Collection;10 9 import java.util.Comparator; 11 10 import java.util.HashMap; … … 272 271 273 272 // 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> { 275 276 @Override 276 277 public boolean add(Shortcut shortcut) { … … 281 282 } 282 283 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 } 283 293 } 284 294 }; … … 369 379 .filter(sc -> !findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()).isPresent()) 370 380 .sorted(Comparator.comparing(sc -> sc.isAssignedUser() ? 1 : sc.isAssignedDefault() ? 2 : 3)) 371 .forEachOrdered(shortcuts:: add);381 .forEachOrdered(shortcuts::replace); 372 382 } 373 383
Note:
See TracChangeset
for help on using the changeset viewer.