Changeset 1050 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2008-10-23T11:25:14+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ShortCut.java
r1023 r1050 29 29 */ 30 30 public class ShortCut { 31 public static final int SHIFT = KeyEvent.SHIFT_DOWN_MASK; 32 public static final int CTRL = KeyEvent.CTRL_DOWN_MASK; 33 public static final int SHIFT_CTRL = KeyEvent.SHIFT_DOWN_MASK|KeyEvent.CTRL_DOWN_MASK; 31 34 private String shortText; // the unique ID of the shortcut 32 35 private String longText; // a human readable description that will be shown in the preferences … … 306 309 int i = 0; 307 310 for (ShortCut sc : ShortCuts.values()) { 308 if (!sc.getAutomatic() && !sc.getReset() ) {311 if (!sc.getAutomatic() && !sc.getReset() && sc.getAssignedUser()) { 309 312 Main.pref.put("shortcut.shortcut."+i, sc.asPrefString()); 310 313 i++; … … 316 319 // this is used to register a shortcut that was read from the preferences 317 320 private static void registerShortCut(ShortCut sc) { 318 if (sc.getAssignedDefault()) { // a 100% default shortcut will go though unchanged -- unless the groups have been reconfigured 319 registerShortCut(sc.getShortText(), sc.getLongText(), sc.getRequestedKey(), sc.getRequestedGroup(), sc); 320 } else if (sc.getAssignedUser()) { // put a user configured shortcut in as-is -- unless there's a conflict 321 ShortCut potentialShortCut = findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()); 322 if (potentialShortCut == null) { 323 ShortCuts.put(sc.getShortText(), sc); 324 } else { 325 registerShortCut(sc.getShortText(), sc.getLongText(), sc.getRequestedKey(), sc.getRequestedGroup(), sc); 326 } 327 } else { // this shortcut was auto-moved before, re-register and warn if it changes 328 registerShortCut(sc.getShortText(), sc.getLongText(), sc.getRequestedKey(), sc.getRequestedGroup(), sc); 329 } 321 registerShortCut(sc.getShortText(), sc.getLongText(), sc.getRequestedKey(), sc.getRequestedGroup(), sc.getAssignedModifier(), sc); 330 322 } 331 323 … … 367 359 * constants defined above. 368 360 */ 361 public static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup, int modifier) { 362 return registerShortCut(shortText, longText, requestedKey, requestedGroup, modifier, null); 363 } 369 364 public static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup) { 370 return registerShortCut(shortText, longText, requestedKey, requestedGroup, null); 365 return registerShortCut(shortText, longText, requestedKey, requestedGroup, null, null); 366 } 367 368 private static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup, 369 ShortCut originalShortCut) { 370 return registerShortCut(shortText, longText, requestedKey, requestedGroup, null, originalShortCut); 371 371 } 372 372 … … 376 376 // read from the preferences file). New shortcuts will never warn, even when they land on some funny 377 377 // random fallback key like Ctrl+Alt+Shift+Z for "File Open..." <g> 378 private static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup, ShortCut originalShortCut) { 378 private static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup, Integer modifier, 379 ShortCut originalShortCut) { 379 380 doInit(); 380 381 if (ShortCuts.containsKey(shortText)) { // a re-register? maybe a sc already read from the preferences? … … 384 385 } 385 386 Integer defaultModifier = Groups.get(requestedGroup + GROUPS_DEFAULT); 386 if (defaultModifier == null) { // garbage in, no shortcurt out 387 if(modifier != null) { 388 defaultModifier = modifier; 389 } 390 else if (defaultModifier == null) { // garbage in, no shortcurt out 387 391 defaultModifier = Groups.get(GROUP_NONE + GROUPS_DEFAULT); 388 392 }
Note:
See TracChangeset
for help on using the changeset viewer.