Java Code Examples for com.intellij.execution.process.ProcessTerminatedListener#attach()

The following examples show how to use com.intellij.execution.process.ProcessTerminatedListener#attach() . 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: RunnerUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static final ConsoleView showHelperProcessRunContent(String header, OSProcessHandler runHandler, Project project, Executor defaultExecutor) {
        ProcessTerminatedListener.attach(runHandler);

        ConsoleViewImpl consoleView = new ConsoleViewImpl(project, true);
        DefaultActionGroup toolbarActions = new DefaultActionGroup();

        JPanel panel = new JPanel((LayoutManager) new BorderLayout());
        panel.add((Component) consoleView.getComponent(), "Center");
        ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("unknown", (ActionGroup) toolbarActions, false);
        toolbar.setTargetComponent(consoleView.getComponent());
        panel.add((Component) toolbar.getComponent(), "West");

        RunContentDescriptor runDescriptor = new RunContentDescriptor((ExecutionConsole) consoleView,
                (ProcessHandler) runHandler, (JComponent) panel, header, AllIcons.RunConfigurations.Application);
        AnAction[]
                consoleActions = consoleView.createConsoleActions();
        toolbarActions.addAll((AnAction[]) Arrays.copyOf(consoleActions, consoleActions.length));
        toolbarActions.add((AnAction) new StopProcessAction("Stop process", "Stop process", (ProcessHandler) runHandler));
        toolbarActions.add((AnAction) new CloseAction(defaultExecutor, runDescriptor, project));

        consoleView.attachToProcess((ProcessHandler) runHandler);
//        ExecutionManager.getInstance(environment.getProject()).getContentManager().showRunContent(environment.getExecutor(), runDescriptor);
        showConsole(project, defaultExecutor, runDescriptor);
        return (ConsoleView) consoleView;
    }
 
Example 2
Source File: FreeRunConfiguration.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private ExecutionResult buildExecutionResult() throws ExecutionException {
    GeneralCommandLine commandLine = createDefaultCommandLine();
    ProcessHandler processHandler = createProcessHandler(commandLine);
    ProcessTerminatedListener.attach(processHandler);
    ConsoleView console = new TerminalExecutionConsole(getProject(), processHandler);

    console.print(
        "Welcome to React Native Console, now please click one button on top toolbar to start.\n",
        ConsoleViewContentType.SYSTEM_OUTPUT);
    console.attachToProcess(processHandler);

    console.print(
        "Give a Star or Suggestion:\n",
        ConsoleViewContentType.NORMAL_OUTPUT);


    processHandler.destroyProcess();
    return new DefaultExecutionResult(console, processHandler);
}
 
Example 3
Source File: RNConsoleImpl.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void processCommandline(GeneralCommandLine commandLine) throws ExecutionException {
        if(myProcessHandler != null) {
            myProcessHandler.destroyProcess();
//            ExecutionManagerImpl.stopProcess(myProcessHandler); // New Android Studio doesn't have this method anymore
            clear();
            myProcessHandler = null;
        }

        if(commandLine.getWorkDirectory() != null) {
            print(
                "cd \"" + commandLine.getWorkDirectory().getAbsolutePath() + "\"\n" ,
                ConsoleViewContentType.SYSTEM_OUTPUT);
        }


        final OSProcessHandler processHandler = new OSProcessHandler(commandLine);
        myProcessHandler = processHandler;
        myStopProcessAction.setProcessHandler(processHandler);

        ProcessTerminatedListener.attach(processHandler);

        processConsole(processHandler);

//        ApplicationManager.getApplication().invokeLater(new Runnable() {
//            @Override
//            public void run() {
//                processConsole(processHandler);
//            }
//        });
    }
 
Example 4
Source File: RNTerminalExecutionConsoleImpl.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void processCommandline(GeneralCommandLine commandLine) throws ExecutionException {
        if(myProcessHandler != null) {
            myProcessHandler.destroyProcess();
//            ExecutionManagerImpl.stopProcess(myProcessHandler); // New Android Studio doesn't have this method anymore
            clear();
            myProcessHandler = null;
        }

        if(commandLine.getWorkDirectory() != null) {
            print(
                "Work directory: " + commandLine.getWorkDirectory().getAbsolutePath() + "\n" ,
                ConsoleViewContentType.SYSTEM_OUTPUT);
        }


        final OSProcessHandler processHandler = new OSProcessHandler(commandLine);
        myProcessHandler = processHandler;
        myStopProcessAction.setProcessHandler(processHandler);

        ProcessTerminatedListener.attach(processHandler);

        processConsole(processHandler);

//        ApplicationManager.getApplication().invokeLater(new Runnable() {
//            @Override
//            public void run() {
//                processConsole(processHandler);
//            }
//        });
    }
 
Example 5
Source File: RNUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void processCommandline(final Project project, GeneralCommandLine commandLine) throws ExecutionException {
        final OSProcessHandler processHandler = new OSProcessHandler(commandLine);
        ProcessTerminatedListener.attach(processHandler);
//        processHandler.startNotify();// Don't call this, the command content will not be shown

        ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
            public void run() {
                processConsole(project, processHandler);
            }
        });
    }
 
Example 6
Source File: FreelineUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void processCommandline(final Project project, GeneralCommandLine commandLine) throws ExecutionException {
    final OSProcessHandler processHandler = new OSProcessHandler(commandLine);
    ProcessTerminatedListener.attach(processHandler);
    processHandler.startNotify();

    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            processConsole(project, processHandler);
        }
    });
}
 
Example 7
Source File: BashCommandLineState.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
    String workingDir = BashRunConfigUtil.findWorkingDir(runConfig);
    GeneralCommandLine cmd = BashRunConfigUtil.createCommandLine(workingDir, runConfig);
    if (!cmd.getEnvironment().containsKey("TERM")) {
        cmd.getEnvironment().put("TERM", "xterm-256color");
    }

    OSProcessHandler processHandler = new KillableColoredProcessHandler(cmd);
    ProcessTerminatedListener.attach(processHandler, getEnvironment().getProject());

    //fixme handle path macros
    return processHandler;
}
 
Example 8
Source File: DemoRunConfiguration.java    From intellij-sdk-docs with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) {
  return new CommandLineState(executionEnvironment) {
    @NotNull
    @Override
    protected ProcessHandler startProcess() throws ExecutionException {
      GeneralCommandLine commandLine = new GeneralCommandLine(getOptions().getScriptName());
      OSProcessHandler processHandler = ProcessHandlerFactory.getInstance().createColoredProcessHandler(commandLine);
      ProcessTerminatedListener.attach(processHandler);
      return processHandler;
    }
  };
}
 
Example 9
Source File: GaugeRunProcessHandler.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
public static GaugeRunProcessHandler runCommandLine(final GeneralCommandLine commandLine, GaugeDebugInfo debugInfo, Project project) throws ExecutionException {
    LOG.info(String.format("Running Gauge tests with command : %s", commandLine.getCommandLineString()));
    final GaugeRunProcessHandler gaugeRunProcess = new GaugeRunProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
    ProcessTerminatedListener.attach(gaugeRunProcess);
    if (debugInfo.shouldDebug()) {
        launchDebugger(project, debugInfo);
    }
    return gaugeRunProcess;
}
 
Example 10
Source File: MongoCommandLineState.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
    GeneralCommandLine commandLine = generateCommandLine();
    final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine);
    ProcessTerminatedListener.attach(processHandler);
    return processHandler;
}
 
Example 11
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
    ProcessHandlerFactory factory = ProcessHandlerFactory.getInstance();
    OSProcessHandler processHandler = factory.createProcessHandler(createCommandLine());
    ProcessTerminatedListener.attach(processHandler);
    return processHandler;
}