com.intellij.execution.process.ProcessEvent Java Examples
The following examples show how to use
com.intellij.execution.process.ProcessEvent.
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: DuneOutputListener.java From reasonml-idea-plugin with MIT License | 6 votes |
@Override public void processTerminated(@NotNull ProcessEvent event) { m_compilerLifecycle.terminate(); if (!m_bsbInfo.isEmpty()) { ServiceManager.getService(m_project, ErrorsManager.class).addAllInfo(m_bsbInfo); } reset(); m_bsbInfo.clear(); ApplicationManager.getApplication().invokeLater(() -> { // When a build is done, we need to refresh editors to be notified of the latest modifications DaemonCodeAnalyzer.getInstance(m_project).restart(); EditorFactory.getInstance().refreshAllEditors(); InferredTypesService.queryForSelectedTextEditor(m_project); }); }
Example #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
Source File: BsOutputListener.java From reasonml-idea-plugin with MIT License | 6 votes |
@Override public void processTerminated(@NotNull ProcessEvent event) { m_compiler.terminate(); //if (m_lineProcessor.hasInfo() && !m_project.isDisposed()) { // ErrorsManager errorsService = ServiceManager.getService(m_project, ErrorsManager.class); // errorsService.addAllInfo(m_lineProcessor.getInfo()); //} //m_lineProcessor.reset(); //m_lineProcessor.m_bsbInfo.clear(); //ApplicationManager.getApplication().invokeLater(() -> { // if (!m_project.isDisposed()) { // When build is done, we need to refresh editors to be notified of the latest modifications //DaemonCodeAnalyzer.getInstance(m_project).restart(); //EditorFactory.getInstance().refreshAllEditors(); //InferredTypesService.queryForSelectedTextEditor(m_project); //} //}); }
Example #14
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 #15
Source File: ExecutionManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void processTerminated(ProcessEvent event) { if (myProject.isDisposed()) return; if (!myTerminateNotified.compareAndSet(false, true)) return; ApplicationManager.getApplication().invokeLater(() -> { RunnerLayoutUi ui = myDescriptor.getRunnerLayoutUi(); if (ui != null && !ui.isDisposed()) { ui.updateActionsNow(); } }, ModalityState.any()); myProject.getMessageBus().syncPublisher(EXECUTION_TOPIC).processTerminated(myExecutorId, myEnvironment, myProcessHandler, event.getExitCode()); SaveAndSyncHandler saveAndSyncHandler = SaveAndSyncHandler.getInstance(); if (saveAndSyncHandler != null) { saveAndSyncHandler.scheduleRefresh(); } }
Example #16
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 #17
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 #18
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 #19
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 #20
Source File: ProcessFinishedListener.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override public void processTerminated(@NotNull ProcessEvent event) { long end = System.currentTimeMillis(); Object source = event.getSource(); if (source instanceof ProcessHandler) { ((ProcessHandler) source).notifyTextAvailable("Process finished in " + formatBuildTime(end - m_start) + "\n\n", ProcessOutputTypes.SYSTEM); } }
Example #21
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 #22
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 #23
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 #24
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 #25
Source File: FlutterLogEntryParser.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable FlutterLogEntry parseDaemonEvent(@NotNull ProcessEvent event, @Nullable Key outputType) { // TODO(pq): process outputType final String text = event.getText(); if (text.isEmpty()) return null; return parseDaemonEvent(text); }
Example #26
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 #27
Source File: FastBuildRunProfileState.java From intellij with Apache License 2.0 | 5 votes |
@Override public void processTerminated(@NotNull ProcessEvent event) { timer.stop(); EventLoggingService.getInstance() .logCommand( FastBuildRunProfileState.class, Command.builder() .setExecutable(commandLine.getExePath()) .setArguments(commandLine.getParametersList().getList()) .setWorkingDirectory(commandLine.getWorkDirectory().getPath()) .setExitCode(event.getExitCode()) .setDuration(timer.elapsed()) .build()); }
Example #28
Source File: InstallSdkAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override void onTextAvailable(ProcessEvent event, Key outputType) { final String details = event.getText(); // Filter out long messages and ones w/ leading whitespace. // Conveniently, these are also the unfriendly ones. For example: // 6 57.9M 6 3838k 0 0 2978k 0 0:00:19 0:00:01 0:00:18 2978k // TODO(pq): consider a more robust approach to filtering. if (!details.startsWith(" ") && details.length() < 70) { setProgressText(details); } }
Example #29
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 #30
Source File: LineProcessingProcessAdapter.java From intellij with Apache License 2.0 | 5 votes |
@Override public void onTextAvailable(ProcessEvent event, Key outputType) { String text = event.getText(); if (text != null) { try { myOutputStream.write(text.getBytes(Charsets.UTF_8)); } catch (IOException e) { // Ignore -- cannot happen } } }