use of com.intellij.openapi.ui.playback.PlaybackRunner in project intellij-community by JetBrains.
the class PlaybackDebugger method startWhenFrameActive.
private void startWhenFrameActive() {
myLog.setText(null);
addInfo("Waiting for IDE frame activation", -1, MESSAGE_COLOR, 0);
myRunner = new PlaybackRunner(myCodeEditor.getText(), this, false, true, false);
VirtualFile file = pathToFile();
if (file != null) {
VirtualFile scriptDir = file.getParent();
if (scriptDir != null) {
myRunner.setScriptDir(new File(scriptDir.getPresentableUrl()));
}
}
new Thread("playback debugger") {
@Override
public void run() {
new WaitFor(60000) {
@Override
protected boolean condition() {
return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() instanceof IdeFrame || myRunner == null;
}
};
if (myRunner == null) {
message(null, "Script stopped", -1, Type.message, true);
return;
}
message(null, "Starting script...", -1, Type.message, true);
TimeoutUtil.sleep(1000);
if (myRunner == null) {
message(null, "Script stopped", -1, Type.message, true);
return;
}
final PlaybackRunner runner = myRunner;
myRunner.run().doWhenProcessed(() -> {
if (runner == myRunner) {
SwingUtilities.invokeLater(() -> myRunner = null);
}
});
}
}.start();
}
use of com.intellij.openapi.ui.playback.PlaybackRunner in project intellij-community by JetBrains.
the class ActionMacroManager method playbackMacro.
private void playbackMacro(ActionMacro macro) {
final IdeFrame frame = WindowManager.getInstance().getIdeFrame(null);
assert frame != null;
StringBuffer script = new StringBuffer();
ActionMacro.ActionDescriptor[] actions = macro.getActions();
for (ActionMacro.ActionDescriptor each : actions) {
each.generateTo(script);
}
final PlaybackRunner runner = new PlaybackRunner(script.toString(), new PlaybackRunner.StatusCallback.Edt() {
@Override
public void messageEdt(PlaybackContext context, String text, Type type) {
if (type == Type.message || type == Type.error) {
StatusBar statusBar = frame.getStatusBar();
if (statusBar != null) {
if (context != null) {
text = "Line " + context.getCurrentLine() + ": " + text;
}
statusBar.setInfo(text);
}
}
}
}, Registry.is("actionSystem.playback.useDirectActionCall"), true, Registry.is("actionSystem.playback.useTypingTargets"));
myIsPlaying = true;
runner.run().doWhenDone(() -> {
StatusBar statusBar = frame.getStatusBar();
statusBar.setInfo("Script execution finished");
}).doWhenProcessed(() -> myIsPlaying = false);
}
Aggregations