diff --git a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java index 8d8718f45e83..cd4a1f39dc64 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java @@ -123,23 +123,10 @@ public class CheckRegExpForm { IdeFocusManager.getGlobalInstance().requestFocus(mySampleText, true); - final AnAction sampleTextFocusAction = new AnAction() { - @Override - public void actionPerformed(@NotNull AnActionEvent e) { - IdeFocusManager.findInstance().requestFocus(myRegExp.getFocusTarget(), true); - } - }; - sampleTextFocusAction.registerCustomShortcutSet(CustomShortcutSet.fromString("shift TAB"), mySampleText); - sampleTextFocusAction.registerCustomShortcutSet(CustomShortcutSet.fromString("TAB"), mySampleText); - - final AnAction regExpFocusAction = new AnAction() { - @Override - public void actionPerformed(@NotNull AnActionEvent e) { - IdeFocusManager.findInstance().requestFocus(mySampleText.getFocusTarget(), true); - } - }; - regExpFocusAction.registerCustomShortcutSet(CustomShortcutSet.fromString("shift TAB"), myRegExp); - regExpFocusAction.registerCustomShortcutSet(CustomShortcutSet.fromString("TAB"), myRegExp); + registerFocusShortcut(myRegExp, "shift TAB", mySampleText); + registerFocusShortcut(myRegExp, "TAB", mySampleText); + registerFocusShortcut(mySampleText, "shift TAB", myRegExp); + registerFocusShortcut(mySampleText, "TAB", myRegExp); updater = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, disposable); DocumentListener documentListener = new DocumentListener() { @@ -155,6 +142,16 @@ public class CheckRegExpForm { mySampleText.selectAll(); } + private void registerFocusShortcut(JComponent source, String shortcut, EditorTextField target) { + AnAction action = new AnAction() { + @Override + public void actionPerformed(@NotNull AnActionEvent e) { + IdeFocusManager.findInstance().requestFocus(target.getFocusTarget(), true); + } + }; + action.registerCustomShortcutSet(CustomShortcutSet.fromString(shortcut), source); + } + public void update() { final TransactionId transactionId = TransactionGuard.getInstance().getContextTransaction(); updater.cancelAllRequests();