Changeset 9259 in josm for trunk


Ignore:
Timestamp:
2016-01-02T14:52:39+01:00 (8 years ago)
Author:
simon04
Message:

Do not register more than 10 shortcuts for "Use this tag again"

This was possible due to r5704.

File:
1 edited

Legend:

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

    r9086 r9259  
    705705            for (int i = tags.size()-1; i >= 0 && count <= tagsToShow; i--, count++) {
    706706                final Tag t = tags.get(i);
    707                 // Create action for reusing the tag, with keyboard shortcut Ctrl+(1-5)
    708                 String actionShortcutKey = "properties:recent:"+count;
    709                 String actionShortcutShiftKey = "properties:recent:shift:"+count;
    710                 // CHECKSTYLE.OFF: LineLength
    711                 Shortcut sc = Shortcut.registerShortcut(actionShortcutKey, tr("Choose recent tag {0}", count), KeyEvent.VK_0+count, Shortcut.CTRL);
    712                 // CHECKSTYLE.ON: LineLength
     707                // Create action for reusing the tag, with keyboard shortcut
     708                final String actionShortcutKey = "properties:recent:" + count;
     709                final String actionShortcutShiftKey = "properties:recent:shift:" + count;
     710                final Shortcut sc = count > 10 ? null : Shortcut.registerShortcut(
     711                        actionShortcutKey, tr("Choose recent tag {0}", count), KeyEvent.VK_0 + count, Shortcut.CTRL);
    713712                final JosmAction action = new JosmAction(actionShortcutKey, null, tr("Use this tag again"), sc, false) {
    714713                    @Override
     
    721720                    }
    722721                };
    723                 Shortcut scShift = Shortcut.registerShortcut(actionShortcutShiftKey, tr("Apply recent tag {0}", count),
    724                         KeyEvent.VK_0+count, Shortcut.CTRL_SHIFT);
     722                final Shortcut scShift = count > 10 ? null : Shortcut.registerShortcut(
     723                        actionShortcutShiftKey, tr("Apply recent tag {0}", count), KeyEvent.VK_0 + count, Shortcut.CTRL_SHIFT);
    725724                final JosmAction actionShift = new JosmAction(actionShortcutShiftKey, null, tr("Use this tag again"), scShift, false) {
    726725                    @Override
     
    763762                        "/td></tr></table></html>");
    764763                tagLabel.setFont(tagLabel.getFont().deriveFont(Font.PLAIN));
    765                 if (action.isEnabled()) {
     764                if (action.isEnabled() && sc != null && scShift != null) {
    766765                    // Register action
    767766                    mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), actionShortcutKey);
     
    769768                    mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scShift.getKeyStroke(), actionShortcutShiftKey);
    770769                    mainPanel.getActionMap().put(actionShortcutShiftKey, actionShift);
     770                }
     771                if (action.isEnabled()) {
    771772                    // Make the tag label clickable and set tooltip to the action description (this displays also the keyboard shortcut)
    772773                    tagLabel.setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION));
Note: See TracChangeset for help on using the changeset viewer.