- Timestamp:
- 2016-10-26T21:23:33+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r10851 r11173 284 284 Main.getLayerManager().addActiveLayerChangeListener(this); 285 285 286 boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null;286 boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0).isPresent(); 287 287 if (unregisterTab) { 288 288 for (JComponent c: allDialogButtons) { -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r11071 r11173 277 277 }); 278 278 279 if (Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null) { 280 setFocusTraversalKeysEnabled(false); 281 } 279 setFocusTraversalKeysEnabled(!Shortcut.findShortcut(KeyEvent.VK_TAB, 0).isPresent()); 282 280 283 281 for (JComponent c : getMapNavigationComponents(this)) { … … 297 295 zoomSlider.setSize(size); 298 296 zoomSlider.setLocation(3, 0); 299 zoomSlider.setFocusTraversalKeysEnabled( Shortcut.findShortcut(KeyEvent.VK_TAB, 0) == null);297 zoomSlider.setFocusTraversalKeysEnabled(!Shortcut.findShortcut(KeyEvent.VK_TAB, 0).isPresent()); 300 298 301 299 MapScaler scaler = new MapScaler(forMapView); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r10755 r11173 799 799 final int commandDownMask = GuiHelper.getMenuShortcutKeyMaskEx(); 800 800 List<String> lines = new ArrayList<>(); 801 Shortcut sc = Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask); 802 if (sc != null) { 803 lines.add(sc.getKeyText() + ' ' + tr("to apply first suggestion")); 804 } 801 Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask).ifPresent(sc -> 802 lines.add(sc.getKeyText() + ' ' + tr("to apply first suggestion")) 803 ); 805 804 lines.add(KeyEvent.getKeyModifiersText(KeyEvent.SHIFT_MASK)+'+'+KeyEvent.getKeyText(KeyEvent.VK_ENTER) + ' ' 806 805 +tr("to add without closing the dialog")); 807 sc = Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask | KeyEvent.SHIFT_DOWN_MASK); 808 if (sc != null) { 809 lines.add(sc.getKeyText() + ' ' + tr("to add first suggestion without closing the dialog")); 810 } 806 Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask | KeyEvent.SHIFT_DOWN_MASK).ifPresent(sc -> 807 lines.add(sc.getKeyText() + ' ' + tr("to add first suggestion without closing the dialog")) 808 ); 811 809 final JLabel helpLabel = new JLabel("<html>" + Utils.join("<br>", lines) + "</html>"); 812 810 helpLabel.setFont(helpLabel.getFont().deriveFont(Font.PLAIN)); -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r10662 r11173 1039 1039 control.removeAll(); 1040 1040 buttonActions.clear(); 1041 boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null;1041 boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0).isPresent(); 1042 1042 1043 1043 for (ActionDefinition action : getDefinedActions()) { -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r11172 r11173 293 293 * @param requestedKey the requested key 294 294 * @param modifier the modifier 295 * @return the registered shortcut or {@code null} 296 */ 297 public static Shortcut findShortcut(int requestedKey, int modifier) { 298 return findShortcutByKeyOrShortText(requestedKey, modifier, null) 299 .orElse(null); 295 * @return an {@link Optional} registered shortcut, never {@code null} 296 */ 297 public static Optional<Shortcut> findShortcut(int requestedKey, int modifier) { 298 return findShortcutByKeyOrShortText(requestedKey, modifier, null); 300 299 } 301 300 … … 368 367 Main.pref.getAllPrefixCollectionKeys("shortcut.entry.").stream() 369 368 .map(Shortcut::new) 370 .filter(sc -> findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()) == null)369 .filter(sc -> !findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()).isPresent()) 371 370 .sorted(Comparator.comparing(sc -> sc.isAssignedUser() ? 1 : sc.isAssignedDefault() ? 2 : 3)) 372 371 .forEachOrdered(shortcuts::add); … … 458 457 // Try to reassign Meta to Ctrl 459 458 int newmodifier = findNewOsxModifier(requestedGroup); 460 if ( findShortcut(requestedKey, newmodifier) == null) {459 if (!findShortcut(requestedKey, newmodifier).isPresent()) { 461 460 Main.info("Reassigning OSX shortcut '" + shortText + "' from Meta to Ctrl because of conflict with " + conflict); 462 461 return reassignShortcut(shortText, longText, requestedKey, conflict, requestedGroup, requestedKey, newmodifier); … … 466 465 for (int k : keys) { 467 466 int newmodifier = getGroupModifier(m); 468 if ( findShortcut(k, newmodifier) == null) {467 if (!findShortcut(k, newmodifier).isPresent()) { 469 468 Main.info("Reassigning shortcut '" + shortText + "' from " + modifier + " to " + newmodifier + 470 469 " because of conflict with " + conflict);
Note:
See TracChangeset
for help on using the changeset viewer.