From 22ad327271fbf0953803463ab132ba8253c1b496 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Wed, 31 Aug 2016 19:21:44 +0300 Subject: [PATCH] IDEA-145132 [follow-up] Esc while editing push target closes the push dialog Fix it globally. --- .../dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java | 8 -------- .../src/com/intellij/util/ui/tree/TreeUtil.java | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java index 788f1e30e57a..5c78d6aced04 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java @@ -62,7 +62,6 @@ public class PushLog extends JPanel implements DataProvider { private static final String CONTEXT_MENU = "Vcs.Push.ContextMenu"; private static final String START_EDITING = "startEditing"; - private static final String CANCEL_EDITING = "cancelEditing"; private final ChangesBrowser myChangesBrowser; private final CheckboxTree myTree; private final MyTreeCellRenderer myTreeCellRenderer; @@ -214,13 +213,6 @@ public class PushLog extends JPanel implements DataProvider { } }); myTree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), START_EDITING); - myTree.getActionMap().put(CANCEL_EDITING, new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - myTree.cancelEditing(); - } - }); - myTree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), CANCEL_EDITING); //override default tree behaviour. myTree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), ""); MyShowCommitInfoAction showCommitInfoAction = new MyShowCommitInfoAction(); diff --git a/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java b/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java index 870d2f160413..e8bc8a685cc3 100644 --- a/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java +++ b/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java @@ -693,6 +693,12 @@ public final class TreeUtil { moveDown(tree); } }); + tree.getActionMap().put("cancelEditing", new AbstractAction() { + @Override + public void actionPerformed(final ActionEvent e) { + tree.cancelEditing(); + } + }); copyAction(tree, "selectLast", "selectLastChangeLead"); copyAction(tree, "selectFirst", "selectFirstChangeLead"); @@ -703,6 +709,7 @@ public final class TreeUtil { UIUtil.maybeInstall(inputMap, "selectPrevious", KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)); UIUtil.maybeInstall(inputMap, "selectLast", KeyStroke.getKeyStroke(KeyEvent.VK_END, 0)); UIUtil.maybeInstall(inputMap, "selectFirst", KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0)); + UIUtil.maybeInstall(tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT), "cancelEditing", KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); } private static void copyAction(@NotNull final JTree tree, String original, String copyTo) {