diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/ActionCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/ActionCommand.java index 1f92f6360873..38e1e071653c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/ActionCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/ActionCommand.java @@ -17,6 +17,8 @@ package com.intellij.openapi.ui.playback.commands; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.AnActionListener; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.keymap.KeymapManager; import com.intellij.openapi.ui.playback.PlaybackContext; import com.intellij.openapi.util.ActionCallback; @@ -31,11 +33,10 @@ import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; public class ActionCommand extends TypeCommand { - - public static String PREFIX = CMD_PREFIX + "action"; + public static final String PREFIX = CMD_PREFIX + "action"; public ActionCommand(String text, int line) { - super(text, line); + super(text, line, true); } protected ActionCallback _execute(final PlaybackContext context) { @@ -81,7 +82,7 @@ public class ActionCommand extends TypeCommand { @Override public void beforeActionPerformed(final AnAction action, DataContext dataContext, AnActionEvent event) { - SwingUtilities.invokeLater(() -> { + ApplicationManager.getApplication().invokeLater(() -> { if (context.isDisposed()) { am.removeAnActionListener(listener.get()); return; @@ -92,13 +93,13 @@ public class ActionCommand extends TypeCommand { am.removeAnActionListener(listener.get()); result.setDone(); } - }); + }, ModalityState.any()); } }); am.addAnActionListener(listener.get()); context.runPooledThread(() -> type(context.getRobot(), finalStroke)); - }); + }, ModalityState.current()); return result; } @@ -109,8 +110,8 @@ public class ActionCommand extends TypeCommand { final ActionCallback result = new ActionCallback(); context.getRobot().delay(Registry.intValue("actionSystem.playback.delay")); - SwingUtilities.invokeLater( - () -> am.tryToExecute(targetAction, input, null, null, false).doWhenProcessed(result.createSetDoneRunnable())); + ApplicationManager.getApplication().invokeLater( + () -> am.tryToExecute(targetAction, input, null, null, false).doWhenProcessed(result.createSetDoneRunnable()), ModalityState.any()); return result; } diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AlphaNumericTypeCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AlphaNumericTypeCommand.java index ebaab9fa065b..4d7edfeefcfb 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AlphaNumericTypeCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AlphaNumericTypeCommand.java @@ -16,6 +16,7 @@ package com.intellij.openapi.ui.playback.commands; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.ui.TypingTarget; import com.intellij.openapi.ui.playback.PlaybackContext; import com.intellij.openapi.util.ActionCallback; @@ -29,7 +30,7 @@ import java.awt.event.KeyEvent; public class AlphaNumericTypeCommand extends TypeCommand { public AlphaNumericTypeCommand(String text, int line) { - super(text, line); + super(text, line, true); } public ActionCallback _execute(PlaybackContext context) { @@ -46,7 +47,7 @@ public class AlphaNumericTypeCommand extends TypeCommand { } else { typeByRobot(context.getRobot(), text).notify(result); } - }); + }, ModalityState.current()); return result; } diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyCodeTypeCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyCodeTypeCommand.java index 18b26c6a3c02..60e70e47fefd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyCodeTypeCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyCodeTypeCommand.java @@ -16,6 +16,7 @@ package com.intellij.openapi.ui.playback.commands; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.ui.TypingTarget; import com.intellij.openapi.ui.playback.PlaybackContext; import com.intellij.openapi.util.ActionCallback; @@ -67,7 +68,7 @@ public class KeyCodeTypeCommand extends AlphaNumericTypeCommand { } else { typeCodes(context, context.getRobot(), codes).notify(result); } - }); + }, ModalityState.current()); return result; } @@ -82,6 +83,7 @@ public class KeyCodeTypeCommand extends AlphaNumericTypeCommand { String[] splits = eachPair.split(MODIFIER_DELIMITER); Integer code = Integer.valueOf(splits[0]); Integer modifier = Integer.valueOf(splits[1]); + //noinspection MagicConstant type(robot, code.intValue(), modifier.intValue()); } catch (NumberFormatException e) { diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyShortcutCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyShortcutCommand.java index 840bbc3ed219..c53d9f90a15f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyShortcutCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyShortcutCommand.java @@ -24,7 +24,7 @@ public class KeyShortcutCommand extends TypeCommand { public static final String POSTFIX = "]"; public KeyShortcutCommand(String text, int line) { - super(text, line); + super(text, line, false); } public ActionCallback _execute(PlaybackContext context) { diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/TypeCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/TypeCommand.java index 4753d4552884..34aeb1ab615b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/TypeCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/TypeCommand.java @@ -27,9 +27,9 @@ public abstract class TypeCommand extends AbstractCommand { private static final KeyStrokeMap ourMap = new KeyStrokeMap(); - public TypeCommand(String text, int line) { - super(text, line); - } + public TypeCommand(String text, int line, boolean executeInAwt) { + super(text, line, executeInAwt); + } protected void type(Robot robot, int code, @JdkConstants.InputEventMask int modifiers) { type(robot, KeyStroke.getKeyStroke(code, modifiers));