Changeset 9263 in josm for trunk/src/org


Ignore:
Timestamp:
2016-01-02T17:26:58+01:00 (9 years ago)
Author:
stoecker
Message:

better parsing of shortcuts, use different names for different purposes, proper name for the action

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r9262 r9263  
    706706                final Tag t = tags.get(i);
    707707                // Create action for reusing the tag, with keyboard shortcut
    708                 final String actionShortcutKey = "properties:recent:" + count;
    709                 final String actionShortcutShiftKey = "properties:recent:shift:" + count;
    710708                /* POSSIBLE SHORTCUTS: 1,2,3,4,5,6,7,8,9,0=10 */
    711709                final Shortcut sc = count > 10 ? null : Shortcut.registerShortcut(
    712                         actionShortcutKey, tr("Choose recent tag {0}", count), KeyEvent.VK_0 + (count % 10), Shortcut.CTRL);
    713                 final JosmAction action = new JosmAction(actionShortcutKey, null, tr("Use this tag again"), sc, false) {
     710                        "properties:recent:" + count, tr("Choose recent tag {0}", count), KeyEvent.VK_0 + (count % 10), Shortcut.CTRL);
     711                final JosmAction action = new JosmAction(tr("Choose recent tag {0}", count), null, tr("Use this tag again"), sc, false) {
    714712                    @Override
    715713                    public void actionPerformed(ActionEvent e) {
     
    723721                /* POSSIBLE SHORTCUTS: 1,2,3,4,5,6,7,8,9,0=10 */
    724722                final Shortcut scShift = count > 10 ? null : Shortcut.registerShortcut(
    725                         actionShortcutShiftKey, tr("Apply recent tag {0}", count), KeyEvent.VK_0 + (count % 10), Shortcut.CTRL_SHIFT);
    726                 final JosmAction actionShift = new JosmAction(actionShortcutShiftKey, null, tr("Use this tag again"), scShift, false) {
     723                        "properties:recent:apply:" + count, tr("Apply recent tag {0}", count), KeyEvent.VK_0 + (count % 10), Shortcut.CTRL_SHIFT);
     724                final JosmAction actionShift = new JosmAction(tr("Apply recent tag {0}", count), null, tr("Use this tag again"), scShift, false) {
    727725                    @Override
    728726                    public void actionPerformed(ActionEvent e) {
     
    766764                if (action.isEnabled() && sc != null && scShift != null) {
    767765                    // Register action
    768                     mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), actionShortcutKey);
    769                     mainPanel.getActionMap().put(actionShortcutKey, action);
    770                     mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scShift.getKeyStroke(), actionShortcutShiftKey);
    771                     mainPanel.getActionMap().put(actionShortcutShiftKey, actionShift);
     766                    mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), "choose"+count);
     767                    mainPanel.getActionMap().put("choose"+count, action);
     768                    mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scShift.getKeyStroke(), "apply"+count);
     769                    mainPanel.getActionMap().put("apply"+count, actionShift);
    772770                }
    773771                if (action.isEnabled()) {
Note: See TracChangeset for help on using the changeset viewer.