Changeset 13683 in josm


Ignore:
Timestamp:
2018-04-26T20:52:17+02:00 (18 months ago)
Author:
Don-vip
Message:

fix #16228 - NPE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r12933 r13683  
    853853    private void registerCopyPasteAction(AbstractAction action, Object actionName, KeyStroke shortcut,
    854854            JRootPane rootPane, JTable... tables) {
    855         int mods = shortcut.getModifiers();
    856         int code = shortcut.getKeyCode();
    857         if (code != KeyEvent.VK_INSERT && (mods == 0 || mods == InputEvent.SHIFT_DOWN_MASK)) {
    858             Logging.info(tr("Sorry, shortcut \"{0}\" can not be enabled in Relation editor dialog"), shortcut);
    859             return;
     855        if (shortcut == null) {
     856            Logging.warn("No shortcut provided for the Paste action in Relation editor dialog");
     857        } else {
     858            int mods = shortcut.getModifiers();
     859            int code = shortcut.getKeyCode();
     860            if (code != KeyEvent.VK_INSERT && (mods == 0 || mods == InputEvent.SHIFT_DOWN_MASK)) {
     861                Logging.info(tr("Sorry, shortcut \"{0}\" can not be enabled in Relation editor dialog"), shortcut);
     862                return;
     863            }
    860864        }
    861865        rootPane.getActionMap().put(actionName, action);
    862         rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortcut, actionName);
    863         // Assign also to JTables because they have their own Copy&Paste implementation
    864         // (which is disabled in this case but eats key shortcuts anyway)
    865         for (JTable table : tables) {
    866             table.getInputMap(JComponent.WHEN_FOCUSED).put(shortcut, actionName);
    867             table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(shortcut, actionName);
    868             table.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortcut, actionName);
     866        if (shortcut != null) {
     867            rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortcut, actionName);
     868            // Assign also to JTables because they have their own Copy&Paste implementation
     869            // (which is disabled in this case but eats key shortcuts anyway)
     870            for (JTable table : tables) {
     871                table.getInputMap(JComponent.WHEN_FOCUSED).put(shortcut, actionName);
     872                table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(shortcut, actionName);
     873                table.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortcut, actionName);
     874            }
    869875        }
    870876        if (action instanceof FlavorListener) {
Note: See TracChangeset for help on using the changeset viewer.