com.intellij.execution.process.ProcessAdapter Java Examples
The following examples show how to use
com.intellij.execution.process.ProcessAdapter.
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: OpenInXcodeAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static void openWithXcode(String path) { try { final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(path); final OSProcessHandler handler = new OSProcessHandler(cmd); handler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull final ProcessEvent event) { if (event.getExitCode() != 0) { FlutterMessages.showError("Error Opening", path); } } }); handler.startNotify(); } catch (ExecutionException ex) { FlutterMessages.showError( "Error Opening", "Exception: " + ex.getMessage()); } }
Example #2
Source File: PantsSystemProjectResolver.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
private void resolveUsingPantsGoal( @NotNull final ExternalSystemTaskId id, @NotNull PantsCompileOptionsExecutor executor, final ExternalSystemTaskNotificationListener listener, @NotNull DataNode<ProjectData> projectDataNode ) { final PantsResolver dependenciesResolver = new PantsResolver(executor); dependenciesResolver.resolve( status -> listener.onStatusChange(new ExternalSystemTaskNotificationEvent(id, status)), new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { listener.onTaskOutput(id, event.getText(), outputType == ProcessOutputTypes.STDOUT); } } ); dependenciesResolver.addInfoTo(projectDataNode); }
Example #3
Source File: SkylarkDebugProcess.java From intellij with Apache License 2.0 | 6 votes |
@Override public void sessionInitialized() { waitForConnection(); ProcessHandler processHandler = getSession().getRunContentDescriptor().getProcessHandler(); processHandler.addProcessListener( new ProcessAdapter() { @Override public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) { if (transport.isConnected()) { // unset breakpoints and resume all threads prior to stopping debugger, otherwise the // interrupt signal won't be properly handled clearBreakpoints(); startStepping(null, Stepping.NONE); } } }); }
Example #4
Source File: PantsCompileOptionsExecutor.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@NotNull private static String loadProjectStructureFromScript( @NotNull String scriptPath, @NotNull Consumer<String> statusConsumer, @Nullable ProcessAdapter processAdapter ) throws IOException, ExecutionException { final GeneralCommandLine commandLine = PantsUtil.defaultCommandLine(scriptPath); commandLine.setExePath(scriptPath); statusConsumer.consume("Executing " + PathUtil.getFileName(scriptPath)); final ProcessOutput processOutput = PantsUtil.getCmdOutput(commandLine, processAdapter); if (processOutput.checkSuccess(LOG)) { return processOutput.getStdout(); } else { throw new PantsExecutionException("Failed to update the project!", scriptPath, processOutput); } }
Example #5
Source File: PantsCompileOptionsExecutor.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@NotNull private String loadProjectStructureFromTargets( @NotNull Consumer<String> statusConsumer, @Nullable ProcessAdapter processAdapter ) throws IOException, ExecutionException { final File outputFile = FileUtil.createTempFile("pants_depmap_run", ".out"); final GeneralCommandLine command = getPantsExportCommand(outputFile, statusConsumer); statusConsumer.consume("Resolving dependencies..."); PantsMetrics.markExportStart(); final ProcessOutput processOutput = getProcessOutput(command); PantsMetrics.markExportEnd(); if (processOutput.getStdout().contains("no such option")) { throw new ExternalSystemException("Pants doesn't have necessary APIs. Please upgrade your pants!"); } if (processOutput.checkSuccess(LOG)) { return FileUtil.loadFile(outputFile); } else { throw new PantsExecutionException("Failed to update the project!", command.getCommandLineString("pants"), processOutput); } }
Example #6
Source File: FlutterConsoleFilter.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void navigate(Project project) { try { final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(myPath); final OSProcessHandler handler = new OSProcessHandler(cmd); handler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull final ProcessEvent event) { if (event.getExitCode() != 0) { FlutterMessages.showError("Error Opening ", myPath); } } }); handler.startNotify(); } catch (ExecutionException e) { FlutterMessages.showError( "Error Opening External File", "Exception: " + e.getMessage()); } }
Example #7
Source File: FlutterConsole.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Starts displaying the output of a different process. */ void watchProcess(@NotNull OSProcessHandler process) { if (cancelProcessSubscription != null) { cancelProcessSubscription.run(); cancelProcessSubscription = null; } view.clear(); view.attachToProcess(process); // Print exit code. final ProcessAdapter listener = new ProcessAdapter() { @Override public void processTerminated(final ProcessEvent event) { view.print( "Process finished with exit code " + event.getExitCode(), ConsoleViewContentType.SYSTEM_OUTPUT); } }; process.addProcessListener(listener); cancelProcessSubscription = () -> process.removeProcessListener(listener); }
Example #8
Source File: FlutterBuildActionGroup.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static OSProcessHandler build(Project project, @NotNull PubRoot pubRoot, FlutterSdk sdk, BuildType buildType, String desc) { ProgressHelper progressHelper = new ProgressHelper(project); progressHelper.start(desc); OSProcessHandler processHandler = sdk.flutterBuild(pubRoot, buildType.type).startInConsole(project); if (processHandler == null) { progressHelper.done(); } else { processHandler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull ProcessEvent event) { progressHelper.done(); int exitCode = event.getExitCode(); if (exitCode != 0) { FlutterMessages.showError("Error while building " + buildType, "`flutter build` returned: " + exitCode); } } }); } return processHandler; }
Example #9
Source File: XQueryDebuggerRunner.java From intellij-xquery with Apache License 2.0 | 6 votes |
private XDebugProcessStarter getProcessStarter(final RunProfileState runProfileState, final ExecutionEnvironment executionEnvironment) throws ExecutionException { int port = getAvailablePort(); ((XQueryRunProfileState) runProfileState).setPort(port); return new XDebugProcessStarter() { @NotNull public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException { final ExecutionResult result = runProfileState.execute(executionEnvironment.getExecutor(), XQueryDebuggerRunner.this); XQueryDebugProcess.XQueryDebuggerIde debuggerIde = new XQueryDebugProcess.XQueryDebuggerIde(session, result.getProcessHandler()); final DBGpIde dbgpIde = ide().withPort(port).withDebuggerIde(debuggerIde).build(); dbgpIde.startListening(); result.getProcessHandler().addProcessListener(new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { dbgpIde.stopListening(); } }); return new XQueryDebugProcess(session, result, dbgpIde); } }; }
Example #10
Source File: BuckToGeneralTestEventsConverter.java From buck with Apache License 2.0 | 6 votes |
@Override public void onStartTesting() { mConnection = mProject.getMessageBus().connect(); mConnection.subscribe(TestResultsAvailableConsumer.BUCK_TEST_RESULTS_AVAILABLE, this); mConnection.subscribe(TestRunCompleteConsumer.BUCK_TEST_RUN_COMPLETE, this); mConnection.subscribe(TestRunStartedConsumer.BUCK_TEST_RUN_STARTED, this); mConnection.subscribe(BuckBuildStartConsumer.BUCK_BUILD_START, this); mConnection.subscribe(BuckBuildEndConsumer.BUCK_BUILD_END, this); mConnection.subscribe(CompilerErrorConsumer.COMPILER_ERROR_CONSUMER, this); myHandler.addProcessListener( new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { mConnection.disconnect(); } }); }
Example #11
Source File: XDebugSessionImpl.java From consulo with Apache License 2.0 | 6 votes |
XDebugSessionTab init(@Nonnull XDebugProcess process, @Nullable RunContentDescriptor contentToReuse) { LOG.assertTrue(myDebugProcess == null); myDebugProcess = process; if (myDebugProcess.checkCanInitBreakpoints()) { initBreakpoints(); } myDebugProcess.getProcessHandler().addProcessListener(new ProcessAdapter() { @Override public void processTerminated(final ProcessEvent event) { stopImpl(); myDebugProcess.getProcessHandler().removeProcessListener(this); } }); //todo[nik] make 'createConsole()' method return ConsoleView myConsoleView = (ConsoleView)myDebugProcess.createConsole(); if (!myShowTabOnSuspend.get()) { initSessionTab(contentToReuse); } return mySessionTab; }
Example #12
Source File: FlutterConsoleFilter.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void navigate(Project project) { try { final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(myPath); final OSProcessHandler handler = new OSProcessHandler(cmd); handler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull final ProcessEvent event) { if (event.getExitCode() != 0) { FlutterMessages.showError("Error Opening ", myPath); } } }); handler.startNotify(); } catch (ExecutionException e) { FlutterMessages.showError( "Error Opening External File", "Exception: " + e.getMessage()); } }
Example #13
Source File: FlutterConsole.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Starts displaying the output of a different process. */ void watchProcess(@NotNull OSProcessHandler process) { if (cancelProcessSubscription != null) { cancelProcessSubscription.run(); cancelProcessSubscription = null; } view.clear(); view.attachToProcess(process); // Print exit code. final ProcessAdapter listener = new ProcessAdapter() { @Override public void processTerminated(final ProcessEvent event) { view.print( "Process finished with exit code " + event.getExitCode(), ConsoleViewContentType.SYSTEM_OUTPUT); } }; process.addProcessListener(listener); cancelProcessSubscription = () -> process.removeProcessListener(listener); }
Example #14
Source File: RunContentExecutor.java From consulo with Apache License 2.0 | 6 votes |
public void run() { FileDocumentManager.getInstance().saveAllDocuments(); // Use user-provided console if exist. Create new otherwise ConsoleView view = (myUserProvidedConsole != null ? myUserProvidedConsole : createConsole(myProject)); view.attachToProcess(myProcess); if (myAfterCompletion != null) { myProcess.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { SwingUtilities.invokeLater(myAfterCompletion); } }); } myProcess.startNotify(); }
Example #15
Source File: FlutterBuildActionGroup.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static OSProcessHandler build(Project project, @NotNull PubRoot pubRoot, FlutterSdk sdk, BuildType buildType, String desc) { ProgressHelper progressHelper = new ProgressHelper(project); progressHelper.start(desc); OSProcessHandler processHandler = sdk.flutterBuild(pubRoot, buildType.type).startInConsole(project); if (processHandler == null) { progressHelper.done(); } else { processHandler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull ProcessEvent event) { progressHelper.done(); int exitCode = event.getExitCode(); if (exitCode != 0) { FlutterMessages.showError("Error while building " + buildType, "`flutter build` returned: " + exitCode); } } }); } return processHandler; }
Example #16
Source File: OpenInXcodeAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static void openWithXcode(String path) { try { final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(path); final OSProcessHandler handler = new OSProcessHandler(cmd); handler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull final ProcessEvent event) { if (event.getExitCode() != 0) { FlutterMessages.showError("Error Opening", path); } } }); handler.startNotify(); } catch (ExecutionException ex) { FlutterMessages.showError( "Error Opening", "Exception: " + ex.getMessage()); } }
Example #17
Source File: AbstractToolBeforeRunTask.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public AsyncResult<Void> execute(UIAccess uiAccess, final DataContext context, final long executionId) { AsyncResult<Void> result = AsyncResult.undefined(); uiAccess.give(() -> { boolean runToolResult = ToolAction.runTool(myToolActionId, context, null, executionId, new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { if(event.getExitCode() == 0) { result.setDone(); } else { result.setRejected(); } } }); if(!runToolResult) { result.setRejected(); } }).doWhenRejectedWithThrowable(result::rejectWithThrowable); return result; }
Example #18
Source File: CoverageDataManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void attachToProcess(@Nonnull final ProcessHandler handler, @Nonnull final RunConfigurationBase configuration, final RunnerSettings runnerSettings) { handler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(final ProcessEvent event) { processGatheredCoverage(configuration, runnerSettings); } }); }
Example #19
Source File: FlutterLog.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void listenToProcess(@NotNull ProcessHandler processHandler, @NotNull Disposable parent) { processHandler.addProcessListener(new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { onEntry(logEntryParser.parseDaemonEvent(event, outputType)); } }, parent); }
Example #20
Source File: PantsUtil.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
public static ProcessOutput getCmdOutput( @NotNull Process process, @NotNull String commandLineString, @Nullable ProcessAdapter processAdapter ) { final CapturingProcessHandler processHandler = new CapturingProcessHandler(process, Charset.defaultCharset(), commandLineString); if (processAdapter != null) { processHandler.addProcessListener(processAdapter); } return processHandler.runProcess(); }
Example #21
Source File: PantsUtil.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
public static ProcessOutput getCmdOutput( @NotNull GeneralCommandLine command, @Nullable ProcessAdapter processAdapter ) throws ExecutionException { final CapturingProcessHandler processHandler = new CapturingProcessHandler(command.createProcess(), Charset.defaultCharset(), command.getCommandLineString()); if (processAdapter != null) { processHandler.addProcessListener(processAdapter); } return processHandler.runProcess(); }
Example #22
Source File: PantsCompileOptionsExecutor.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@NotNull public String loadProjectStructure( @NotNull Consumer<String> statusConsumer, @Nullable ProcessAdapter processAdapter ) throws IOException, ExecutionException { if (PantsUtil.isExecutable(getProjectPath())) { return loadProjectStructureFromScript(getProjectPath(), statusConsumer, processAdapter); } else { return loadProjectStructureFromTargets(statusConsumer, processAdapter); } }
Example #23
Source File: PantsResolver.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
public void resolve( @NotNull Consumer<String> statusConsumer, @Nullable ProcessAdapter processAdapter ) { try { String pantsExportResult = myExecutor.loadProjectStructure(statusConsumer, processAdapter); parse(pantsExportResult); } catch (ExecutionException | IOException e) { throw new ExternalSystemException(e); } }
Example #24
Source File: LogConsoleBase.java From consulo with Apache License 2.0 | 5 votes |
public void attachStopLogConsoleTrackingListener(final ProcessHandler process) { if (process != null) { final ProcessAdapter stopListener = new ProcessAdapter() { @Override public void processTerminated(final ProcessEvent event) { process.removeProcessListener(this); stopRunning(true); } }; process.addProcessListener(stopListener); } }
Example #25
Source File: PantsIntegrationTestCase.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@NotNull protected RunResult runWithConfiguration(RunConfiguration configuration) { PantsMakeBeforeRun.replaceDefaultMakeWithPantsMake(configuration); PantsMakeBeforeRun.setRunConfigurationWorkingDirectory(configuration); PantsJUnitRunnerAndConfigurationSettings runnerAndConfigurationSettings = new PantsJUnitRunnerAndConfigurationSettings(configuration); ExecutionEnvironmentBuilder environmentBuilder = ExecutionUtil.createEnvironment(DefaultRunExecutor.getRunExecutorInstance(), runnerAndConfigurationSettings); ExecutionEnvironment environment = environmentBuilder.build(); List<String> output = new ArrayList<>(); List<String> errors = new ArrayList<>(); ProcessAdapter processAdapter = new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { if (outputType == ProcessOutputTypes.STDOUT) { output.add(event.getText()); } else if (outputType == ProcessOutputTypes.STDERR) { errors.add(event.getText()); } } }; ProgramRunnerUtil.executeConfiguration(environment, false, false); OSProcessHandler handler = (OSProcessHandler) environment.getContentToReuse().getProcessHandler(); handler.addProcessListener(processAdapter); assertTrue(handler.waitFor()); return new RunResult(handler.getExitCode(), output, errors); }
Example #26
Source File: OpenInAndroidStudioAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void openFileInStudio(@NotNull VirtualFile projectFile, @NotNull String androidStudioPath, @Nullable String sourceFile) { try { final GeneralCommandLine cmd; if (SystemInfo.isMac) { cmd = new GeneralCommandLine().withExePath("open").withParameters("-a", androidStudioPath, "--args", projectFile.getPath()); if (sourceFile != null) { cmd.addParameter(sourceFile); } } else { // TODO Open editor on sourceFile for Linux, Windows if (SystemInfo.isWindows) { androidStudioPath += "\\bin\\studio.bat"; } cmd = new GeneralCommandLine().withExePath(androidStudioPath).withParameters(projectFile.getPath()); } final OSProcessHandler handler = new OSProcessHandler(cmd); handler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull final ProcessEvent event) { if (event.getExitCode() != 0) { FlutterMessages.showError("Error Opening", projectFile.getPath()); } } }); handler.startNotify(); } catch (ExecutionException ex) { FlutterMessages.showError( "Error Opening", "Exception: " + ex.getMessage()); } }
Example #27
Source File: FlutterLog.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void listenToProcess(@NotNull ProcessHandler processHandler, @NotNull Disposable parent) { processHandler.addProcessListener(new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { onEntry(logEntryParser.parseDaemonEvent(event, outputType)); } }, parent); }
Example #28
Source File: OpenInAndroidStudioAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void openFileInStudio(@NotNull VirtualFile projectFile, @NotNull String androidStudioPath, @Nullable String sourceFile) { try { final GeneralCommandLine cmd; if (SystemInfo.isMac) { cmd = new GeneralCommandLine().withExePath("open").withParameters("-a", androidStudioPath, "--args", projectFile.getPath()); if (sourceFile != null) { cmd.addParameter(sourceFile); } } else { // TODO Open editor on sourceFile for Linux, Windows if (SystemInfo.isWindows) { androidStudioPath += "\\bin\\studio.bat"; } cmd = new GeneralCommandLine().withExePath(androidStudioPath).withParameters(projectFile.getPath()); } final OSProcessHandler handler = new OSProcessHandler(cmd); handler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull final ProcessEvent event) { if (event.getExitCode() != 0) { FlutterMessages.showError("Error Opening", projectFile.getPath()); } } }); handler.startNotify(); } catch (ExecutionException ex) { FlutterMessages.showError( "Error Opening", "Exception: " + ex.getMessage()); } }
Example #29
Source File: PromptConsoleView.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override public void attachToProcess(@NotNull ProcessHandler processHandler) { super.attachToProcess(processHandler); processHandler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull ProcessEvent event) { ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(m_promptConsole::disablePrompt)); } }); }
Example #30
Source File: PluginGeneratorUtil.java From idea-php-shopware-plugin with MIT License | 4 votes |
public static void installPlugin(@NotNull Project project, @NotNull PluginGeneratorSettings settings) { // download cli tools, if not existing locally VirtualFile cliFile = getCliToolsPharFile(project); if (cliFile == null) { showErrorNotification(project, "No CLI-Tools phar found"); return; } List<String> commands = generateCommand(settings); String[] myCommand = ArrayUtil.toStringArray(commands); final StringBuilder outputBuilder = new StringBuilder(); try { OSProcessHandler processHandler = ScriptRunnerUtil.execute(myCommand[0], project.getBaseDir().getPath(), null, Arrays.copyOfRange(myCommand, 1, myCommand.length)); processHandler.addProcessListener(new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull com.intellij.openapi.util.Key outputType) { String text = event.getText(); outputBuilder.append(text); } }); processHandler.startNotify(); for (;;){ boolean finished = processHandler.waitFor(CHECKING_TIMEOUT_IN_MILLISECONDS); if (finished) { break; } } } catch (ExecutionException e) { showErrorNotification(project, e.getMessage()); return; } String output = outputBuilder.toString(); if (output.toLowerCase().contains("exception")) { String message = SymfonyInstallerUtil.formatExceptionMessage(output); if(message == null) { message = "The unexpected happens..."; } showErrorNotification(project, message); return; } // delete cli tools FileUtil.delete(VfsUtil.virtualToIoFile(cliFile)); // move into correct plugin folder String newDir = project.getBasePath() + "/engine/Shopware/Plugins/Local/" + settings.getNamespace() + "/" + settings.getPluginName(); if (FileUtil.canWrite(newDir)) { return; } FileUtil.createDirectory(new File(newDir)); FileUtil.moveDirWithContent(new File(project.getBasePath() + "/" + settings.getPluginName()), new File(newDir)); // open bootstrap file VirtualFile fileByIoFile = VfsUtil.findFileByIoFile(new File(newDir + "/Bootstrap.php"), true); if(fileByIoFile == null) { return; } final PsiFile file = PsiManager.getInstance(project).findFile(fileByIoFile); if (file == null) { return; } IdeHelper.navigateToPsiElement(file); }