Changeset 14012 in josm for trunk/src/org
- Timestamp:
- 2018-07-08T00:27:14+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r13925 r14012 7 7 import java.awt.event.KeyEvent; 8 8 import java.util.Collection; 9 import java.util.List; 9 10 import java.util.concurrent.CancellationException; 10 11 import java.util.concurrent.ExecutionException; … … 186 187 187 188 /** 189 * Constructs a new {@code JosmAction}. 190 * 191 * Use this super constructor to setup your action. 192 * 193 * @param name the action's text as displayed on the menu (if it is added to a menu) 194 * @param iconName the filename of the icon to use 195 * @param tooltip a longer description of the action that will be displayed in the tooltip. Please note 196 * that html is not supported for menu actions on some platforms. 197 * @param shortcuts ready-created shortcut objects 198 * @since 14012 199 */ 200 public JosmAction(String name, String iconName, String tooltip, List<Shortcut> shortcuts) { 201 this(name, iconName, tooltip, shortcuts.get(0), true, null, true); 202 for (int i = 1; i < shortcuts.size(); i++) { 203 MainApplication.registerActionShortcut(this, shortcuts.get(i)); 204 } 205 } 206 207 /** 188 208 * Installs the listeners to this action. 189 209 * <p> -
trunk/src/org/openstreetmap/josm/actions/ReorderImageryLayersAction.java
r13891 r14012 5 5 6 6 import java.awt.event.ActionEvent; 7 import java.awt.event.KeyEvent;8 7 import java.util.List; 9 8 import java.util.stream.Collectors; 10 9 import java.util.stream.Stream; 11 10 12 import org.openstreetmap.josm.gui.MainApplication;13 11 import org.openstreetmap.josm.gui.layer.ImageryLayer; 12 import org.openstreetmap.josm.tools.KeyboardUtils; 14 13 import org.openstreetmap.josm.tools.Shortcut; 15 14 … … 20 19 public class ReorderImageryLayersAction extends JosmAction { 21 20 22 private static final int VK_SQUARE = 0x10000b2;23 24 21 /** 25 22 * Constructs a new {@code ReorderImageryLayersAction}. … … 28 25 // TODO: find a suitable icon 29 26 super(tr("Reorder imagery layers"), "dialogs/layerlist", tr("Reorders non-overlay imagery layers."), 30 Shortcut.registerShortcut("imagery:reorder", tr("Reorder imagery layers"), KeyEvent.VK_DEAD_TILDE, Shortcut.DIRECT), true); 31 // On AZERTY keyboard layour the key displays the character '²' 32 MainApplication.registerActionShortcut(this, 33 Shortcut.registerShortcut("imagery:reorderbis", tr("Reorder imagery layers"), VK_SQUARE, Shortcut.DIRECT)); 27 Shortcut.registerMultiShortcuts("imagery:reorder", tr("Reorder imagery layers"), 28 KeyboardUtils.getCharactersForKey('E', 0), Shortcut.DIRECT)); 34 29 } 35 30 -
trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java
r12987 r14012 14 14 import java.awt.Toolkit; 15 15 import java.awt.event.KeyEvent; 16 import java.awt.im.InputContext; 16 17 import java.lang.reflect.Field; 17 18 import java.util.ArrayList; … … 50 51 import org.openstreetmap.josm.gui.widgets.JosmTextField; 51 52 import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator; 53 import org.openstreetmap.josm.tools.KeyboardUtils; 52 54 import org.openstreetmap.josm.tools.Logging; 53 55 import org.openstreetmap.josm.tools.Shortcut; … … 114 116 } 115 117 } 118 KeyboardUtils.getExtendedKeyCodes(InputContext.getInstance().getLocale()).entrySet() 119 .forEach(e -> list.put(e.getKey(), e.getValue().toString())); 116 120 list.put(Integer.valueOf(-1), ""); 117 121 return list; … … 333 337 int row = panel.shortcutTable.convertRowIndexToModel(lsm.getMinSelectionIndex()); 334 338 Shortcut sc = (Shortcut) panel.model.getValueAt(row, -1); 339 Object selectedKey = panel.tfKey.getSelectedItem(); 335 340 if (panel.cbDisable.isSelected()) { 336 341 sc.setAssignedModifier(-1); 337 } else if ( panel.tfKey.getSelectedItem() == null || "".equals(panel.tfKey.getSelectedItem())) {342 } else if (selectedKey == null || "".equals(selectedKey)) { 338 343 sc.setAssignedModifier(KeyEvent.VK_CANCEL); 339 344 } else { … … 345 350 ); 346 351 for (Map.Entry<Integer, String> entry : keyList.entrySet()) { 347 if (entry.getValue().equals( panel.tfKey.getSelectedItem())) {352 if (entry.getValue().equals(selectedKey)) { 348 353 sc.setAssignedKey(entry.getKey()); 349 354 } -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r13852 r14012 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Toolkit; 6 7 import java.awt.event.KeyEvent; 7 8 import java.util.ArrayList; … … 440 441 441 442 /** 443 * Register a shortcut linked to several characters. 444 * 445 * @param shortText an ID. re-use a {@code "system:*"} ID if possible, else use something unique. 446 * {@code "menu:*"} is reserved for menu mnemonics, {@code "core:*"} is reserved for 447 * actions that are part of JOSM's core. Use something like 448 * {@code <pluginname>+":"+<actionname>}. 449 * @param longText this will be displayed in the shortcut preferences dialog. Better 450 * use something the user will recognize... 451 * @param characters the characters you'd prefer 452 * @param requestedGroup the group this shortcut fits best. This will determine the 453 * modifiers your shortcut will get assigned. Use the constants defined above. 454 * @return the shortcut 455 */ 456 public static List<Shortcut> registerMultiShortcuts(String shortText, String longText, List<Character> characters, int requestedGroup) { 457 List<Shortcut> result = new ArrayList<>(); 458 int i = 1; 459 Map<Integer, Integer> regularKeyCodes = KeyboardUtils.getRegularKeyCodesMap(); 460 for (Character c : characters) { 461 Integer code = (int) c; 462 result.add(registerShortcut( 463 new StringBuilder(shortText).append(" (").append(i).append(')').toString(), longText, 464 // Add extended keyCode if not a regular one 465 regularKeyCodes.containsKey(code) ? regularKeyCodes.get(code) : c | KeyboardUtils.EXTENDED_KEYCODE_FLAG, 466 requestedGroup)); 467 i++; 468 } 469 return result; 470 } 471 472 /** 442 473 * Register a shortcut. 443 474 *
Note:
See TracChangeset
for help on using the changeset viewer.