Changeset 11485 in josm for trunk/src/org


Ignore:
Timestamp:
2017-01-21T09:59:53+01:00 (8 years ago)
Author:
wiktorn
Message:

Fix NPE in RelationEditor

Handle uncommon situation that user has no keystroke assigned to copy/paste action which resulted in NullPointerException.

File:
1 edited

Legend:

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

    r10646 r11485  
    272272        // CHECKSTYLE.ON: LineLength
    273273
    274         registerCopyPasteAction(new PasteMembersAction(memberTable, getLayer(), this) {
    275             @Override
    276             public void actionPerformed(ActionEvent e) {
    277                 super.actionPerformed(e);
    278                 tfRole.requestFocusInWindow();
    279             }
    280         }, "PASTE_MEMBERS", Shortcut.getPasteKeyStroke(), getRootPane(), memberTable, selectionTable);
    281 
    282         registerCopyPasteAction(new CopyMembersAction(memberTableModel, getLayer(), this),
    283                 "COPY_MEMBERS", Shortcut.getCopyKeyStroke(), getRootPane(), memberTable, selectionTable);
    284 
     274        KeyStroke key = Shortcut.getPasteKeyStroke();
     275        if (key != null) {
     276            // handle uncommon situation, that user has no keystroke assigned to paste
     277            registerCopyPasteAction(new PasteMembersAction(memberTable, getLayer(), this) {
     278                @Override
     279                public void actionPerformed(ActionEvent e) {
     280                    super.actionPerformed(e);
     281                    tfRole.requestFocusInWindow();
     282                }
     283            }, "PASTE_MEMBERS", key, getRootPane(), memberTable, selectionTable);
     284        }
     285        key = Shortcut.getCopyKeyStroke();
     286        if (key != null) {
     287            // handle uncommon situation, that user has no keystroke assigned to paste
     288            registerCopyPasteAction(new CopyMembersAction(memberTableModel, getLayer(), this),
     289                    "COPY_MEMBERS", key, getRootPane(), memberTable, selectionTable);
     290        }
    285291        tagEditorPanel.setNextFocusComponent(memberTable);
    286292        selectionTable.setFocusable(false);
Note: See TracChangeset for help on using the changeset viewer.