Fix Shift+Tab shortcut in RegExp form (IDEA-202189)

An AnAction must not be reused for multiple shortcuts, or all but the
last shortcut will be ignored.
This commit is contained in:
Roland Illig
2018-11-19 11:54:57 +01:00
committed by Bas Leijdekkers
parent 16af417449
commit d6e2c54b1c
@@ -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();