Java Code Examples for com.intellij.execution.ui.RunContentDescriptor#getProcessHandler()
The following examples show how to use
com.intellij.execution.ui.RunContentDescriptor#getProcessHandler() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterAppManager.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Return the active (front most in the UI) Flutter app. * <p> * This could return null even if there is a running Flutter app, if the front-most * running process (focused in the Run or Debug view) is not a Flutter app instance. */ @Nullable public FlutterApp getActiveApp() { RunContentManager mgr = getRunContentManager(); if (mgr == null) { return null; } final RunContentDescriptor descriptor = mgr.getSelectedContent(); if (descriptor == null) { return null; } final ProcessHandler process = descriptor.getProcessHandler(); if (process == null) { return null; } final FlutterApp app = FlutterApp.fromProcess(process); return app != null && app.isConnected() ? app : null; }
Example 2
Source File: EOFAction.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { RunContentDescriptor descriptor = StopAction.getRecentlyStartedContentDescriptor(e.getDataContext()); ProcessHandler activeProcessHandler = descriptor != null ? descriptor.getProcessHandler() : null; if (activeProcessHandler == null || activeProcessHandler.isProcessTerminated()) return; try { OutputStream input = activeProcessHandler.getProcessInput(); if (input != null) { ConsoleView console = e.getData(LangDataKeys.CONSOLE_VIEW); if (console != null) { console.print("^D\n", ConsoleViewContentType.SYSTEM_OUTPUT); } input.close(); } } catch (IOException ignored) { } }
Example 3
Source File: FlutterApp.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@NotNull public static List<FlutterApp> allFromProjectProcess(@NotNull Project project) { final List<FlutterApp> allRunningApps = new ArrayList<>(); final List<RunContentDescriptor> runningProcesses = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors(); for (RunContentDescriptor descriptor : runningProcesses) { final ProcessHandler process = descriptor.getProcessHandler(); if (process != null) { final FlutterApp app = FlutterApp.fromProcess(process); if (app != null) { allRunningApps.add(app); } } } return allRunningApps; }
Example 4
Source File: LaunchState.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the currently running app for the given RunConfig, if any. */ @Nullable public static ProcessHandler getRunningAppProcess(RunConfig config) { final Project project = config.getProject(); final List<RunContentDescriptor> runningProcesses = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors(); for (RunContentDescriptor descriptor : runningProcesses) { final ProcessHandler process = descriptor.getProcessHandler(); if (process != null && !process.isProcessTerminated() && process.getUserData(FLUTTER_RUN_CONFIG_KEY) == config) { return process; } } return null; }
Example 5
Source File: FlutterAppManager.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Return the active (front most in the UI) Flutter app. * <p> * This could return null even if there is a running Flutter app, if the front-most * running process (focused in the Run or Debug view) is not a Flutter app instance. */ @Nullable public FlutterApp getActiveApp() { RunContentManager mgr = getRunContentManager(); if (mgr == null) { return null; } final RunContentDescriptor descriptor = mgr.getSelectedContent(); if (descriptor == null) { return null; } final ProcessHandler process = descriptor.getProcessHandler(); if (process == null) { return null; } final FlutterApp app = FlutterApp.fromProcess(process); return app != null && app.isConnected() ? app : null; }
Example 6
Source File: FlutterAppManager.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Return the list of all running Flutter apps. */ public List<FlutterApp> getApps() { final List<FlutterApp> apps = new ArrayList<>(); RunContentManager mgr = getRunContentManager(); if (mgr == null) { return apps; } final List<RunContentDescriptor> runningProcesses = mgr.getAllDescriptors(); for (RunContentDescriptor descriptor : runningProcesses) { final ProcessHandler process = descriptor.getProcessHandler(); if (process != null) { final FlutterApp app = FlutterApp.fromProcess(process); if (app != null && app.isConnected()) { apps.add(app); } } } return apps; }
Example 7
Source File: ExecutionManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void restartRunProfile(@Nonnull Project project, @Nonnull Executor executor, @Nonnull ExecutionTarget target, @Nullable RunnerAndConfigurationSettings configuration, @Nullable ProcessHandler processHandler) { ExecutionEnvironmentBuilder builder = createEnvironmentBuilder(project, executor, configuration); if (processHandler != null) { for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) { if (descriptor.getProcessHandler() == processHandler) { builder.contentToReuse(descriptor); break; } } } restartRunProfile(builder.target(target).build()); }
Example 8
Source File: FlutterApp.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@NotNull public static List<FlutterApp> allFromProjectProcess(@NotNull Project project) { final List<FlutterApp> allRunningApps = new ArrayList<>(); final List<RunContentDescriptor> runningProcesses = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors(); for (RunContentDescriptor descriptor : runningProcesses) { final ProcessHandler process = descriptor.getProcessHandler(); if (process != null) { final FlutterApp app = FlutterApp.fromProcess(process); if (app != null) { allRunningApps.add(app); } } } return allRunningApps; }
Example 9
Source File: LaunchState.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the currently running app for the given RunConfig, if any. */ @Nullable public static ProcessHandler getRunningAppProcess(RunConfig config) { final Project project = config.getProject(); final List<RunContentDescriptor> runningProcesses = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors(); for (RunContentDescriptor descriptor : runningProcesses) { final ProcessHandler process = descriptor.getProcessHandler(); if (process != null && !process.isProcessTerminated() && process.getUserData(FLUTTER_RUN_CONFIG_KEY) == config) { return process; } } return null; }
Example 10
Source File: RunDashboardContributor.java From consulo with Apache License 2.0 | 6 votes |
/** * Returns node's status. Subclasses may override this method to provide custom statuses. * @param node dashboard node * @return node's status. Returned status is used for grouping nodes by status. */ public DashboardRunConfigurationStatus getStatus(DashboardRunConfigurationNode node) { RunContentDescriptor descriptor = node.getDescriptor(); if (descriptor == null) { return DashboardRunConfigurationStatus.STOPPED; } ProcessHandler processHandler = descriptor.getProcessHandler(); if (processHandler == null) { return DashboardRunConfigurationStatus.STOPPED; } Integer exitCode = processHandler.getExitCode(); if (exitCode == null) { return DashboardRunConfigurationStatus.STARTED; } Boolean terminationRequested = processHandler.getUserData(ProcessHandler.TERMINATION_REQUESTED); if (exitCode == 0 || (terminationRequested != null && terminationRequested)) { return DashboardRunConfigurationStatus.STOPPED; } return DashboardRunConfigurationStatus.FAILED; }
Example 11
Source File: ExecutionManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public ProcessHandler[] getRunningProcesses() { if (myContentManager == null) return EMPTY_PROCESS_HANDLERS; List<ProcessHandler> handlers = null; for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) { ProcessHandler processHandler = descriptor.getProcessHandler(); if (processHandler != null) { if (handlers == null) { handlers = new SmartList<>(); } handlers.add(processHandler); } } return handlers == null ? EMPTY_PROCESS_HANDLERS : handlers.toArray(new ProcessHandler[handlers.size()]); }
Example 12
Source File: AppCommandLineState.java From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 | 6 votes |
/** * Closes old session only for debug mode * * @param project * @param parameters */ private void closeOldSession(final Project project, EmbeddedLinuxJVMRunConfigurationRunnerParameters parameters) { final String configurationName = AppCommandLineState.getRunConfigurationName(parameters.getPort()); final Collection<RunContentDescriptor> descriptors = ExecutionHelper.findRunningConsoleByTitle(project, configurationName::equals); if (descriptors.size() > 0) { final RunContentDescriptor descriptor = descriptors.iterator().next(); final ProcessHandler processHandler = descriptor.getProcessHandler(); final Content content = descriptor.getAttachedContent(); if (processHandler != null && content != null) { final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance(); if (processHandler.isProcessTerminated()) { ExecutionManager.getInstance(project).getContentManager() .removeRunContent(executor, descriptor); } else { content.getManager().setSelectedContent(content); ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(executor.getToolWindowId()); window.activate(null, false, true); } } } }
Example 13
Source File: AbstractAutoTestManager.java From consulo with Apache License 2.0 | 6 votes |
public void setAutoTestEnabled(@Nonnull RunContentDescriptor descriptor, @Nonnull ExecutionEnvironment environment, boolean enabled) { Content content = descriptor.getAttachedContent(); if (content != null) { if (enabled) { myEnabledRunProfiles.add(environment.getRunProfile()); myWatcher.activate(); } else { myEnabledRunProfiles.remove(environment.getRunProfile()); if (!hasEnabledAutoTests()) { myWatcher.deactivate(); } ProcessHandler processHandler = descriptor.getProcessHandler(); if (processHandler != null) { clearRestarterListener(processHandler); } } } }
Example 14
Source File: EOFAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void update(@Nonnull AnActionEvent e) { RunContentDescriptor descriptor = StopAction.getRecentlyStartedContentDescriptor(e.getDataContext()); ProcessHandler handler = descriptor != null ? descriptor.getProcessHandler() : null; e.getPresentation().setEnabledAndVisible(e.getData(LangDataKeys.CONSOLE_VIEW) != null && e.getData(CommonDataKeys.EDITOR) != null && handler != null && !handler.isProcessTerminated()); }
Example 15
Source File: FakeRerunAction.java From consulo with Apache License 2.0 | 5 votes |
protected boolean isEnabled(AnActionEvent event) { RunContentDescriptor descriptor = getDescriptor(event); ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler(); ExecutionEnvironment environment = getEnvironment(event); return environment != null && !ExecutorRegistry.getInstance().isStarting(environment) && !(processHandler != null && processHandler.isProcessTerminating()); }
Example 16
Source File: BlazeCoverageProgramRunner.java From intellij with Apache License 2.0 | 5 votes |
@Nullable @Override protected RunContentDescriptor doExecute(RunProfileState profile, ExecutionEnvironment env) throws ExecutionException { BlazeInfo blazeInfo = getBlazeInfo(env.getProject()); if (blazeInfo == null) { throw new ExecutionException( "Can't run with coverage: no sync data found. Please sync your project and retry."); } RunContentDescriptor result = super.doExecute(profile, env); if (result == null) { return null; } EventLoggingService.getInstance().logEvent(getClass(), "run-with-coverage"); // remove any old copy of the coverage data // retrieve coverage data and copy locally BlazeCommandRunConfiguration blazeConfig = (BlazeCommandRunConfiguration) env.getRunProfile(); BlazeCoverageEnabledConfiguration config = (BlazeCoverageEnabledConfiguration) CoverageEnabledConfiguration.getOrCreate(blazeConfig); String coverageFilePath = config.getCoverageFilePath(); File blazeOutputFile = CoverageUtils.getOutputFile(blazeInfo); ProcessHandler handler = result.getProcessHandler(); if (handler != null) { ProcessHandler wrappedHandler = new ProcessHandlerWrapper( handler, exitCode -> copyCoverageOutput(blazeOutputFile, coverageFilePath, exitCode)); CoverageHelper.attachToProcess(blazeConfig, wrappedHandler, env.getRunnerSettings()); } return result; }
Example 17
Source File: ExecutionUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void restartIfActive(@Nonnull RunContentDescriptor descriptor) { ProcessHandler processHandler = descriptor.getProcessHandler(); if (processHandler != null && processHandler.isStartNotified() && !processHandler.isProcessTerminating() && !processHandler.isProcessTerminated()) { restart(descriptor); } }
Example 18
Source File: StopAction.java From consulo with Apache License 2.0 | 4 votes |
@Override public void update(final AnActionEvent e) { boolean enable = false; Icon icon = getTemplatePresentation().getIcon(); String description = getTemplatePresentation().getDescription(); Presentation presentation = e.getPresentation(); if (isPlaceGlobal(e)) { List<RunContentDescriptor> stoppableDescriptors = getActiveStoppableDescriptors(e.getDataContext()); List<Pair<TaskInfo, ProgressIndicator>> cancellableProcesses = getCancellableProcesses(e.getProject()); int todoSize = stoppableDescriptors.size() + cancellableProcesses.size(); if (todoSize > 1) { presentation.setText(getTemplatePresentation().getText() + "..."); } else if (todoSize == 1) { if (stoppableDescriptors.size() == 1) { presentation .setText(ExecutionBundle.message("stop.configuration.action.name", StringUtil.escapeMnemonics(stoppableDescriptors.get(0).getDisplayName()))); } else { TaskInfo taskInfo = cancellableProcesses.get(0).first; presentation.setText(taskInfo.getCancelText() + " " + taskInfo.getTitle()); } } else { presentation.setText(getTemplatePresentation().getText()); } enable = todoSize > 0; if (todoSize > 1) { icon = IconUtil.addText(icon, String.valueOf(todoSize)); } } else { RunContentDescriptor contentDescriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR); ProcessHandler processHandler = contentDescriptor == null ? null : contentDescriptor.getProcessHandler(); if (processHandler != null && !processHandler.isProcessTerminated()) { if (!processHandler.isProcessTerminating()) { enable = true; } else if (processHandler instanceof KillableProcess && ((KillableProcess)processHandler).canKillProcess()) { enable = true; icon = AllIcons.Debugger.KillProcess; description = "Kill process"; } } RunProfile runProfile = e.getData(LangDataKeys.RUN_PROFILE); if (runProfile == null && contentDescriptor == null) { presentation.setText(getTemplatePresentation().getText()); } else { presentation.setText(ExecutionBundle.message("stop.configuration.action.name", StringUtil .escapeMnemonics(runProfile == null ? contentDescriptor.getDisplayName() : runProfile.getName()))); } } presentation.setEnabled(enable); presentation.setIcon(icon); presentation.setDescription(description); }
Example 19
Source File: ExecutionManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
public static boolean isProcessRunning(@Nullable RunContentDescriptor descriptor) { ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler(); return processHandler != null && !processHandler.isProcessTerminated(); }
Example 20
Source File: StopAction.java From consulo with Apache License 2.0 | 4 votes |
private static boolean canBeStopped(@Nullable RunContentDescriptor descriptor) { @Nullable ProcessHandler processHandler = descriptor != null ? descriptor.getProcessHandler() : null; return processHandler != null && !processHandler.isProcessTerminated() && (!processHandler.isProcessTerminating() || processHandler instanceof KillableProcess && ((KillableProcess)processHandler).canKillProcess()); }