Search in sources :

Example 1 with PlaybackContext

use of com.intellij.openapi.ui.playback.PlaybackContext 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);
}
Also used : PlaybackRunner(com.intellij.openapi.ui.playback.PlaybackRunner) IdeFrame(com.intellij.openapi.wm.IdeFrame) StatusBar(com.intellij.openapi.wm.StatusBar) PlaybackContext(com.intellij.openapi.ui.playback.PlaybackContext)

Aggregations

PlaybackContext (com.intellij.openapi.ui.playback.PlaybackContext)1 PlaybackRunner (com.intellij.openapi.ui.playback.PlaybackRunner)1 IdeFrame (com.intellij.openapi.wm.IdeFrame)1 StatusBar (com.intellij.openapi.wm.StatusBar)1