From ee7b952986d5246aed3a06503a08f916e6a425e0 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 14 Feb 2012 16:45:20 +0100 Subject: [PATCH] same shortcut to enable/disable checkbox --- .../intellij/ide/actions/GotoActionBase.java | 5 +++-- .../ide/util/gotoByName/ChooseByNameBase.java | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java index ae89aed5b06c..0ff7c3f8a7b5 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java @@ -122,11 +122,11 @@ public abstract class GotoActionBase extends AnAction { return Pair.create("", 0); } - protected static void showNavigationPopup(AnActionEvent e, ChooseByNameModel model, final GotoActionCallback callback) { + protected void showNavigationPopup(AnActionEvent e, ChooseByNameModel model, final GotoActionCallback callback) { showNavigationPopup(e, model, callback, null, true); } - protected static void showNavigationPopup(AnActionEvent e, + protected void showNavigationPopup(AnActionEvent e, ChooseByNameModel model, final GotoActionCallback callback, @Nullable final String findUsagesTitle, @@ -138,6 +138,7 @@ public abstract class GotoActionBase extends AnAction { LOG.assertTrue(startedAction != null); Pair start = getInitialText(useSelectionFromEditor ? e.getData(PlatformDataKeys.EDITOR) : null); final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e), start.first, mayRequestOpenInCurrentWindow, start.second); + popup.setCheckBoxShortcut(getShortcutSet()); popup.setFindUsagesTitle(findUsagesTitle); final ChooseByNameFilter filter = callback.createFilter(popup); diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java index 4899cebe2a77..d385bd463a0f 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java @@ -139,6 +139,7 @@ public abstract class ChooseByNameBase { private boolean myClosedByShiftEnter = false; protected final int myInitialIndex; private String myFindUsagesTitle; + private ShortcutSet myCheckBoxShortcut; public boolean checkDisposed() { if (myDisposedFlag && myPostponedOkAction != null && !myPostponedOkAction.isProcessed()) { @@ -363,7 +364,9 @@ public abstract class ChooseByNameBase { myCheckBox.setSelected(myModel.loadInitialCheckBoxState()); - if (checkBoxName == null) myCheckBox.setVisible(false); + if (checkBoxName == null) { + myCheckBox.setVisible(false); + } addCard(myCheckBox, CHECK_BOX_CARD); @@ -443,6 +446,17 @@ public abstract class ChooseByNameBase { Font editorFont = new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize()); myTextField.setFont(editorFont); + if (checkBoxName != null) { + if (myCheckBox != null) { + new AnAction("change goto check box", null ,null) { + @Override + public void actionPerformed(AnActionEvent e) { + myCheckBox.setSelected(!myCheckBox.isSelected()); + } + }.registerCustomShortcutSet(myCheckBoxShortcut, myTextField); + } + } + if (isCloseByFocusLost()) { myTextField.addFocusListener(new FocusAdapter() { public void focusLost(final FocusEvent e) { @@ -596,6 +610,10 @@ public abstract class ChooseByNameBase { myCardContainer.add(wrapper, cardId); } + public void setCheckBoxShortcut(ShortcutSet shortcutSet) { + myCheckBoxShortcut = shortcutSet; + } + private static Set getShortcuts(@NotNull String actionId) { Set result = new HashSet(); Keymap keymap = KeymapManager.getInstance().getActiveKeymap();