Search in sources :

Example 1 with LanguageConsoleView

use of com.intellij.execution.console.LanguageConsoleView in project intellij-community by JetBrains.

the class GroovyShellRunnerImpl method createConsoleView.

@Override
protected LanguageConsoleView createConsoleView() {
    final LanguageConsoleView res = new GroovyShellLanguageConsoleView(getProject(), getConsoleTitle());
    final GroovyFileImpl file = (GroovyFileImpl) res.getFile();
    assert file.getContext() == null;
    file.putUserData(GROOVY_SHELL_FILE, Boolean.TRUE);
    file.setContext(myShellRunner.getContext(myModule));
    return res;
}
Also used : LanguageConsoleView(com.intellij.execution.console.LanguageConsoleView) GroovyFileImpl(org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl)

Example 2 with LanguageConsoleView

use of com.intellij.execution.console.LanguageConsoleView in project intellij-community by JetBrains.

the class PyExecuteSelectionAction method startConsole.

private static void startConsole(final Project project, final Consumer<PyCodeExecutor> consumer, Module context) {
    final PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(project);
    if (toolWindow != null && toolWindow.getConsoleContentDescriptors().size() > 0) {
        toolWindow.activate(() -> {
            List<RunContentDescriptor> descs = toolWindow.getConsoleContentDescriptors();
            RunContentDescriptor descriptor = descs.get(0);
            if (descriptor != null && descriptor.getExecutionConsole() instanceof PyCodeExecutor) {
                consumer.consume((PyCodeExecutor) descriptor.getExecutionConsole());
            }
        });
    } else {
        PythonConsoleRunnerFactory consoleRunnerFactory = PythonConsoleRunnerFactory.getInstance();
        PydevConsoleRunner runner = consoleRunnerFactory.createConsoleRunner(project, null);
        runner.addConsoleListener(new PydevConsoleRunner.ConsoleListener() {

            @Override
            public void handleConsoleInitialized(LanguageConsoleView consoleView) {
                if (consoleView instanceof PyCodeExecutor) {
                    consumer.consume((PyCodeExecutor) consoleView);
                    if (toolWindow != null) {
                        toolWindow.getToolWindow().show(null);
                    }
                }
            }
        });
        runner.run();
    }
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) LanguageConsoleView(com.intellij.execution.console.LanguageConsoleView)

Example 3 with LanguageConsoleView

use of com.intellij.execution.console.LanguageConsoleView in project intellij-community by JetBrains.

the class XEvaluateInConsoleFromEditorActionHandler method getConsoleExecuteAction.

@Nullable
public static ConsoleExecuteAction getConsoleExecuteAction(@Nullable ConsoleView consoleView) {
    if (!(consoleView instanceof LanguageConsoleView)) {
        return null;
    }
    List<AnAction> actions = ActionUtil.getActions(((LanguageConsoleView) consoleView).getConsoleEditor().getComponent());
    ConsoleExecuteAction action = ContainerUtil.findInstance(actions, ConsoleExecuteAction.class);
    return action == null || !action.isEnabled() ? null : action;
}
Also used : LanguageConsoleView(com.intellij.execution.console.LanguageConsoleView) AnAction(com.intellij.openapi.actionSystem.AnAction) ConsoleExecuteAction(com.intellij.execution.console.ConsoleExecuteAction) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with LanguageConsoleView

use of com.intellij.execution.console.LanguageConsoleView in project intellij-community by JetBrains.

the class PyConsoleTask method runTestOn.

@Override
public void runTestOn(final String sdkHome) throws Exception {
    final Project project = getProject();
    final Sdk sdk = createTempSdk(sdkHome, SdkCreationType.EMPTY_SDK);
    setProcessCanTerminate(false);
    PydevConsoleRunner consoleRunner = new PydevConsoleRunnerImpl(project, sdk, PyConsoleType.PYTHON, myFixture.getTempDirPath(), Maps.newHashMap(), PyConsoleOptions.getInstance(project).getPythonConsoleSettings(), (s) -> {
    });
    before();
    myConsoleInitSemaphore = new Semaphore(0);
    consoleRunner.addConsoleListener(new PydevConsoleRunnerImpl.ConsoleListener() {

        @Override
        public void handleConsoleInitialized(LanguageConsoleView consoleView) {
            myConsoleInitSemaphore.release();
        }
    });
    consoleRunner.run();
    waitFor(myConsoleInitSemaphore);
    myCommandSemaphore = new Semaphore(1);
    myConsoleView = consoleRunner.getConsoleView();
    myProcessHandler = consoleRunner.getProcessHandler();
    myExecuteHandler = consoleRunner.getConsoleExecuteActionHandler();
    myCommunication = consoleRunner.getPydevConsoleCommunication();
    myCommunication.addCommunicationListener(new ConsoleCommunicationListener() {

        @Override
        public void commandExecuted(boolean more) {
            myCommandSemaphore.release();
        }

        @Override
        public void inputRequested() {
        }
    });
    myProcessHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            if (event.getExitCode() != 0 && !myProcessCanTerminate) {
                Assert.fail("Process terminated unexpectedly\n" + output());
            }
        }
    });
    OutputPrinter myOutputPrinter = null;
    if (shouldPrintOutput) {
        myOutputPrinter = new OutputPrinter();
        myOutputPrinter.start();
    }
    waitForOutput("PyDev console");
    try {
        testing();
        after();
    } finally {
        setProcessCanTerminate(true);
        if (myOutputPrinter != null) {
            myOutputPrinter.stop();
        }
        disposeConsole();
    }
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) LanguageConsoleView(com.intellij.execution.console.LanguageConsoleView) ProcessEvent(com.intellij.execution.process.ProcessEvent) Semaphore(java.util.concurrent.Semaphore) Project(com.intellij.openapi.project.Project) ConsoleCommunicationListener(com.jetbrains.python.console.pydev.ConsoleCommunicationListener) Sdk(com.intellij.openapi.projectRoots.Sdk)

Aggregations

LanguageConsoleView (com.intellij.execution.console.LanguageConsoleView)4 ConsoleExecuteAction (com.intellij.execution.console.ConsoleExecuteAction)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 ConsoleCommunicationListener (com.jetbrains.python.console.pydev.ConsoleCommunicationListener)1 Semaphore (java.util.concurrent.Semaphore)1 Nullable (org.jetbrains.annotations.Nullable)1 GroovyFileImpl (org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl)1