Search in sources :

Example 26 with Executor

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

the class AbstractTerminalRunner method initConsoleUI.

private void initConsoleUI(final T process) {
    final Executor defaultExecutor = DefaultRunExecutor.getRunExecutorInstance();
    final DefaultActionGroup toolbarActions = new DefaultActionGroup();
    final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(actionToolbar.getComponent(), BorderLayout.WEST);
    actionToolbar.setTargetComponent(panel);
    ProcessHandler processHandler = createProcessHandler(process);
    final RunContentDescriptor contentDescriptor = new RunContentDescriptor(null, processHandler, panel, getTerminalConnectionName(process));
    contentDescriptor.setAutoFocusContent(true);
    toolbarActions.add(createCloseAction(defaultExecutor, contentDescriptor));
    final JBTerminalSystemSettingsProvider provider = new JBTerminalSystemSettingsProvider();
    TerminalWidget widget = new JBTabbedTerminalWidget(myProject, provider, new Predicate<Pair<TerminalWidget, String>>() {

        @Override
        public boolean apply(Pair<TerminalWidget, String> widget) {
            openSessionInDirectory(widget.getFirst(), widget.getSecond());
            return true;
        }
    }, contentDescriptor);
    createAndStartSession(widget, createTtyConnector(process));
    panel.add(widget.getComponent(), BorderLayout.CENTER);
    showConsole(defaultExecutor, contentDescriptor, widget.getComponent());
    processHandler.startNotify();
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) Executor(com.intellij.execution.Executor) ProcessHandler(com.intellij.execution.process.ProcessHandler) TerminalWidget(com.jediterm.terminal.ui.TerminalWidget) Pair(com.intellij.openapi.util.Pair)

Example 27 with Executor

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

the class GradleRerunFailedTestsAction method getRunProfile.

@Nullable
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
    ExternalSystemRunConfiguration configuration = (ExternalSystemRunConfiguration) myConsoleProperties.getConfiguration();
    final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject());
    return new MyRunProfile(configuration) {

        @NotNull
        @Override
        public Module[] getModules() {
            return Module.EMPTY_ARRAY;
        }

        @Nullable
        @Override
        public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
            ExternalSystemRunConfiguration runProfile = ((ExternalSystemRunConfiguration) getPeer()).clone();
            Project project = runProfile.getProject();
            Set<String> scriptParameters = ContainerUtil.newLinkedHashSet();
            Set<String> tasksToRun = ContainerUtil.newLinkedHashSet();
            boolean useResolvedTasks = true;
            for (AbstractTestProxy test : failedTests) {
                if (test instanceof GradleSMTestProxy) {
                    String testName = test.getName();
                    String className = ((GradleSMTestProxy) test).getClassName();
                    scriptParameters.add(TestMethodGradleConfigurationProducer.createTestFilter(className, testName));
                    if (!useResolvedTasks)
                        continue;
                    if (className == null) {
                        useResolvedTasks = false;
                        continue;
                    }
                    final PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.projectScope(project));
                    if (psiClass == null) {
                        useResolvedTasks = false;
                        continue;
                    }
                    final PsiFile psiFile = psiClass.getContainingFile();
                    if (psiFile == null) {
                        useResolvedTasks = false;
                        continue;
                    }
                    final Module moduleForFile = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(psiFile.getVirtualFile());
                    if (moduleForFile == null) {
                        useResolvedTasks = false;
                        continue;
                    }
                    ContainerUtil.addAllNotNull(tasksToRun, GradleTestRunConfigurationProducer.getTasksToRun(moduleForFile));
                }
            }
            runProfile.getSettings().setScriptParameters(StringUtil.join(scriptParameters, " "));
            if (useResolvedTasks && !tasksToRun.isEmpty()) {
                runProfile.getSettings().setTaskNames(ContainerUtil.newArrayList(tasksToRun));
            }
            return runProfile.getState(executor, environment);
        }
    };
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) GradleSMTestProxy(org.jetbrains.plugins.gradle.execution.test.runner.GradleSMTestProxy) PsiClass(com.intellij.psi.PsiClass) ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) AbstractTestProxy(com.intellij.execution.testframework.AbstractTestProxy) NotNull(org.jetbrains.annotations.NotNull) Project(com.intellij.openapi.project.Project) Executor(com.intellij.execution.Executor) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 28 with Executor

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

the class RerunFailedTestsAction method getRunProfile.

@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
    final TestNGConfiguration configuration = (TestNGConfiguration) myConsoleProperties.getConfiguration();
    final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject());
    return new MyRunProfile(configuration) {

        @Override
        @NotNull
        public Module[] getModules() {
            return configuration.getModules();
        }

        @Override
        public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) {
            return new TestNGRunnableState(env, configuration) {

                @Override
                public SearchingForTestsTask createSearchingForTestsTask() {
                    return new SearchingForTestsTask(myServerSocket, getConfiguration(), myTempFile) {

                        @Override
                        protected void fillTestObjects(final Map<PsiClass, Map<PsiMethod, List<String>>> classes) throws CantRunException {
                            final HashMap<PsiClass, Map<PsiMethod, List<String>>> fullClassList = ContainerUtil.newHashMap();
                            super.fillTestObjects(fullClassList);
                            for (final PsiClass aClass : fullClassList.keySet()) {
                                if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {

                                    @Override
                                    public Boolean compute() {
                                        return TestNGUtil.hasTest(aClass);
                                    }
                                })) {
                                    classes.put(aClass, fullClassList.get(aClass));
                                }
                            }
                            final GlobalSearchScope scope = getConfiguration().getConfigurationModule().getSearchScope();
                            final Project project = getConfiguration().getProject();
                            for (final AbstractTestProxy proxy : failedTests) {
                                ApplicationManager.getApplication().runReadAction(() -> includeFailedTestWithDependencies(classes, scope, project, proxy));
                            }
                        }
                    };
                }
            };
        }
    };
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) PsiMethod(com.intellij.psi.PsiMethod) TestNGConfiguration(com.theoryinpractice.testng.configuration.TestNGConfiguration) PsiClass(com.intellij.psi.PsiClass) AbstractTestProxy(com.intellij.execution.testframework.AbstractTestProxy) NotNull(org.jetbrains.annotations.NotNull) Project(com.intellij.openapi.project.Project) Executor(com.intellij.execution.Executor) TestNGRunnableState(com.theoryinpractice.testng.configuration.TestNGRunnableState) SearchingForTestsTask(com.theoryinpractice.testng.configuration.SearchingForTestsTask) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Module(com.intellij.openapi.module.Module) Computable(com.intellij.openapi.util.Computable)

Example 29 with Executor

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

the class PyCharmEduInitialConfigurator method patchProjectAreaExtensions.

private static void patchProjectAreaExtensions(@NotNull final Project project) {
    Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
    unregisterAction(debugExecutor.getId(), ExecutorRegistryImpl.RUNNERS_GROUP);
    unregisterAction(debugExecutor.getContextActionId(), ExecutorRegistryImpl.RUN_CONTEXT_GROUP);
    ExtensionsArea projectArea = Extensions.getArea(project);
    for (SelectInTarget target : Extensions.getExtensions(SelectInTarget.EP_NAME, project)) {
        if (ToolWindowId.FAVORITES_VIEW.equals(target.getToolWindowId()) || ToolWindowId.STRUCTURE_VIEW.equals(target.getToolWindowId())) {
            projectArea.getExtensionPoint(SelectInTarget.EP_NAME).unregisterExtension(target);
        }
    }
    for (AbstractProjectViewPane pane : Extensions.getExtensions(AbstractProjectViewPane.EP_NAME, project)) {
        if (pane.getId().equals(ScopeViewPane.ID)) {
            Disposer.dispose(pane);
            projectArea.getExtensionPoint(AbstractProjectViewPane.EP_NAME).unregisterExtension(pane);
        }
    }
}
Also used : ExtensionsArea(com.intellij.openapi.extensions.ExtensionsArea) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) SelectInTarget(com.intellij.ide.SelectInTarget) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane)

Example 30 with Executor

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

the class PyDataViewToolWindowFactory method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    PyDataView.getInstance(project).init(toolWindow);
    final MessageBusConnection connection = project.getMessageBus().connect(project);
    connection.subscribe(XDebuggerManager.TOPIC, new ChangeContentXDebuggerManagerListener(project));
    connection.subscribe(RunContentManager.TOPIC, new RunContentWithExecutorListener() {

        @Override
        public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
            if (!(executor instanceof DefaultDebugExecutor)) {
                return;
            }
            if (descriptor == null) {
                return;
            }
            ProcessHandler handler = descriptor.getProcessHandler();
            if (handler == null) {
                return;
            }
            PyDataView.getInstance(project).updateTabs(handler);
        }

        @Override
        public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
        }
    });
    addPythonConsoleListener(project);
    ((ToolWindowEx) toolWindow).setAdditionalGearActions(new DefaultActionGroup(new ColoredByDefaultAction()));
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) RunContentWithExecutorListener(com.intellij.execution.ui.RunContentWithExecutorListener) ProcessHandler(com.intellij.execution.process.ProcessHandler) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Aggregations

Executor (com.intellij.execution.Executor)34 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)15 NotNull (org.jetbrains.annotations.NotNull)14 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)9 ProcessHandler (com.intellij.execution.process.ProcessHandler)9 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)9 Project (com.intellij.openapi.project.Project)9 ProgramRunner (com.intellij.execution.runners.ProgramRunner)8 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)7 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)4 ConsoleView (com.intellij.execution.ui.ConsoleView)4 CloseAction (com.intellij.execution.ui.actions.CloseAction)4 Module (com.intellij.openapi.module.Module)4 File (java.io.File)4 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)3 ExecutionException (com.intellij.execution.ExecutionException)3 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)3 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)3 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)3 AbstractTestProxy (com.intellij.execution.testframework.AbstractTestProxy)3