Java Code Examples for com.intellij.execution.process.ProcessHandler

The following are top voted examples for showing how to use com.intellij.execution.process.ProcessHandler. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: react-native-console   File: RunnerUtil.java   Source Code and 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
Project: reasonml-idea-plugin   File: BsToolWindowFactory.java   Source Code and License 6 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    BsConsole console = new BsConsole(project);
    panel.setContent(console.getComponent());

    ActionToolbar toolbar = console.createToolbar();
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true);
    toolWindow.getContentManager().addContent(content);

    // Start compiler
    BsCompiler bsc = BucklescriptProjectComponent.getInstance(project).getCompiler();
    if (bsc != null) {
        bsc.addListener(new BsOutputListener(project));
        ProcessHandler handler = bsc.getHandler();
        if (handler == null) {
            console.print("Bsb not found, check the event logs.", ERROR_OUTPUT);
        } else {
            console.attachToProcess(handler);
        }
        bsc.startNotify();
    }
}
 
Example 3
Project: intellij-ce-playground   File: XsltRunConfiguration.java   Source Code and License 6 votes vote down vote up
@Override
public void createAdditionalTabComponents(final AdditionalTabComponentManager manager, ProcessHandler startedProcess) {
  if (myOutputType == OutputType.CONSOLE) {
    final HighlightingOutputConsole console = new HighlightingOutputConsole(getProject(), myFileType);

      XsltCommandLineState state = startedProcess.getUserData(XsltCommandLineState.STATE);
      boolean debug = state != null && state.isDebugger();
      boolean consoleTabAdded = false;
    for (XsltRunnerExtension extension : XsltRunnerExtension.getExtensions(this, debug)) {
      if (extension.createTabs(getProject(), manager, console, startedProcess)) {
        consoleTabAdded = true;
      }
    }
    if (!consoleTabAdded) {
      manager.addAdditionalTabComponent(console, console.getTabTitle());    // TODO: verify parameter
    }

    final OutputTabAdapter listener = new OutputTabAdapter(startedProcess, console);
    if (startedProcess.isStartNotified()) {
      listener.startNotified(new ProcessEvent(startedProcess));
    }
    else {
      startedProcess.addProcessListener(listener);
    }
  }
}
 
Example 4
Project: samebug-idea-plugin   File: RunDebugWatcher.java   Source Code and License 6 votes vote down vote up
private void createListener(@NotNull RunContentDescriptor descriptor, Integer descriptorHashCode) {
    DebugSessionInfo sessionInfo = new DebugSessionInfo("run/debug");

    ProcessHandler processHandler = descriptor.getProcessHandler();
    if (processHandler != null) {
        ExecutionConsole console = descriptor.getExecutionConsole();
        if (console instanceof ConsoleView) {
            ConsoleViewImpl impl = extractConsoleImpl((ConsoleView) console);
            if (impl != null) {
                new ConsoleWatcher(myProject, impl, sessionInfo);
            }
        }
        final LogScannerFactory scannerFactory = new StackTraceMatcherFactory(myProject, sessionInfo);
        RunDebugAdapter listener = new RunDebugAdapter(scannerFactory);
        listeners.put(descriptorHashCode, listener);
        debugSessionIds.put(descriptorHashCode, sessionInfo);
        processHandler.addProcessListener(listener);

        TrackingService.trace(IdeaRawEvent.debugStart(myProject, sessionInfo));
    }
}
 
Example 5
Project: intellij-ce-playground   File: AndroidDebugRunner.java   Source Code and License 6 votes vote down vote up
private static void tryToCloseOldSessions(final Executor executor, Project project) {
  final ExecutionManager manager = ExecutionManager.getInstance(project);
  ProcessHandler[] processes = manager.getRunningProcesses();
  for (ProcessHandler process : processes) {
    final AndroidSessionInfo info = process.getUserData(ANDROID_SESSION_INFO);
    if (info != null) {
      process.addProcessListener(new ProcessAdapter() {
        @Override
        public void processTerminated(ProcessEvent event) {
          ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
            public void run() {
              manager.getContentManager().removeRunContent(executor, info.getDescriptor());
            }
          });
        }
      });
      process.detachProcess();
    }
  }
}
 
Example 6
Project: intellij-ce-playground   File: AndroidRunConfigurationBase.java   Source Code and License 6 votes vote down vote up
@Nullable
protected static Pair<File, String> getCopyOfCompilerManifestFile(@NotNull AndroidFacet facet, @Nullable ProcessHandler processHandler) {
  final VirtualFile manifestFile = AndroidRootUtil.getCustomManifestFileForCompiler(facet);

  if (manifestFile == null) {
    return null;
  }
  File tmpDir = null;
  try {
    tmpDir = FileUtil.createTempDirectory("android_manifest_file_for_execution", "tmp");
    final File manifestCopy = new File(tmpDir, manifestFile.getName());
    FileUtil.copy(new File(manifestFile.getPath()), manifestCopy);
    //noinspection ConstantConditions
    return Pair.create(manifestCopy, PathUtil.getLocalPath(manifestFile));
  }
  catch (IOException e) {
    if (processHandler != null) {
      processHandler.notifyTextAvailable("I/O error: " + e.getMessage(), ProcessOutputTypes.STDERR);
    }
    LOG.info(e);
    if (tmpDir != null) {
      FileUtil.delete(tmpDir);
    }
    return null;
  }
}
 
Example 7
Project: intellij-ce-playground   File: StopProcessAction.java   Source Code and License 6 votes vote down vote up
public static void stopProcess(@Nullable ProcessHandler processHandler) {
  if (processHandler instanceof KillableProcess && processHandler.isProcessTerminating()) {
    // process termination was requested, but it's still alive
    // in this case 'force quit' will be performed
    ((KillableProcess)processHandler).killProcess();
    return;
  }

  if (processHandler != null) {
    if (processHandler.detachIsDefault()) {
      processHandler.detachProcess();
    }
    else {
      processHandler.destroyProcess();
    }
  }
}
 
Example 8
Project: intellij-ce-playground   File: PyEduDebugRunner.java   Source Code and License 6 votes vote down vote up
@NotNull
@Override
protected PyDebugProcess createDebugProcess(@NotNull XDebugSession session,
                                            ServerSocket serverSocket,
                                            ExecutionResult result,
                                            PythonCommandLineState pyState) {
  ExecutionConsole executionConsole = result.getExecutionConsole();
  ProcessHandler processHandler = result.getProcessHandler();
  boolean isMultiProcess = pyState.isMultiprocessDebug();
  String scriptName = getScriptName(pyState);
  if (scriptName != null) {
    VirtualFile file = VfsUtil.findFileByIoFile(new File(scriptName), true);
    if (file != null) {
      int line = getBreakpointLineNumber(file, session.getProject());
      if (line != NO_LINE) {
        return new PyEduDebugProcess(session, serverSocket,
                                     executionConsole, processHandler,
                                     isMultiProcess, scriptName, line + 1);
      }
    }
  }
  LOG.info("Failed to create PyEduDebugProcess. PyDebugProcess created instead.");
  return new PyDebugProcess(session, serverSocket, executionConsole,
                            processHandler, isMultiProcess);
}
 
Example 9
Project: intellij-ce-playground   File: ExecutionManagerImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void restartRunProfile(@NotNull Project project,
                              @NotNull Executor executor,
                              @NotNull 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 10
Project: intellij-ce-playground   File: EOFAction.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(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 11
Project: intellij-ce-playground   File: PyDebuggerTask.java   Source Code and License 6 votes vote down vote up
@Override
protected void disposeDebugProcess() throws InterruptedException {
  if (myDebugProcess != null) {
    ProcessHandler processHandler = myDebugProcess.getProcessHandler();

    myDebugProcess.stop();

    waitFor(processHandler);

    if (!processHandler.isProcessTerminated()) {
      killDebugProcess();
      if (!waitFor(processHandler)) {
        new Throwable("Cannot stop debugger process").printStackTrace();
      }
    }
  }
}
 
Example 12
Project: intellij-ce-playground   File: PyRemoteProcessStarter.java   Source Code and License 6 votes vote down vote up
public ProcessHandler startRemoteProcess(@NotNull Sdk sdk,
                                         @NotNull GeneralCommandLine commandLine,
                                         @Nullable Project project,
                                         @Nullable PyRemotePathMapper pathMapper)
  throws ExecutionException {
  PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
  if (manager != null) {
    PyRemoteProcessHandlerBase processHandler;

    try {
      processHandler = doStartRemoteProcess(sdk, commandLine, manager, project, pathMapper);
    }
    catch (ExecutionException e) {
      final Application application = ApplicationManager.getApplication();
      if (application != null && (application.isUnitTestMode() || application.isHeadlessEnvironment())) {
        throw new RuntimeException(e);
      }
      throw new ExecutionException("Can't run remote python interpreter: " + e.getMessage(), e);
    }
    ProcessTerminatedListener.attach(processHandler);
    return processHandler;
  }
  else {
    throw new PythonRemoteInterpreterManager.PyRemoteInterpreterExecutionException();
  }
}
 
Example 13
Project: intellij-ce-playground   File: AutoTestManager.java   Source Code and License 6 votes vote down vote up
public void setAutoTestEnabled(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment environment, boolean enabled) {
  Content content = descriptor.getAttachedContent();
  if (content != null) {
    if (enabled) {
      EXECUTION_ENVIRONMENT_KEY.set(content, environment);
      myDocumentWatcher.activate();
    }
    else {
      EXECUTION_ENVIRONMENT_KEY.set(content, null);
      if (!hasEnabledAutoTests()) {
        myDocumentWatcher.deactivate();
      }
      ProcessHandler processHandler = descriptor.getProcessHandler();
      if (processHandler != null) {
        clearRestarterListener(processHandler);
      }
    }
  }
}
 
Example 14
Project: react-native-console   File: FreeRunConfiguration.java   Source Code and License 5 votes vote down vote up
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
    // here just run one command: python freeline.py
    GeneralCommandLine commandLine = new GeneralCommandLine();
    ExecutionEnvironment environment = getEnvironment();
    commandLine.setWorkDirectory(environment.getProject().getBasePath());
    commandLine.setExePath("npm");
    commandLine.addParameters("list");
    return new OSProcessHandler(commandLine);
}
 
Example 15
Project: AppleScript-IDEA   File: AppleScriptScriptCommandLineState.java   Source Code and License 5 votes vote down vote up
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
  String scriptPath = runConfiguration.getScriptPath();
  String scriptParameters = runConfiguration.getScriptParameters();
  String scriptOptions = runConfiguration.getScriptOptions();

  scriptPath = scriptPath == null ? "" : scriptPath;//todo change this (and add validator to run config)
  final List<String> commandString = new ArrayList<>();
  commandString.add("/usr/bin/osascript");
  if (!StringUtil.isEmpty(scriptOptions)) {
    String[] options = scriptOptions.split(" ");
    commandString.addAll(Arrays.asList(options));
  }
  commandString.add(scriptPath);
  if (!StringUtil.isEmpty(scriptParameters)) {
    Pattern regex = Pattern.compile("\"([^\"]*)\"|(\\w+)");
    final ArrayList<String> matchedParams = new ArrayList<>();
    Matcher matcher = regex.matcher(scriptParameters);
    while (matcher.find()) {
      for (int i = 1; i <= matcher.groupCount(); i++) {
        try {
          String p = matcher.group(i);
          if (!StringUtil.isEmpty(p)) matchedParams.add(p);
        } catch (IllegalStateException | IndexOutOfBoundsException e) {
          LOG.warn("Error parsing script parameters: " + e.getMessage());
        }
      }
    }
    commandString.addAll(matchedParams);
  }

  final GeneralCommandLine commandLine = new GeneralCommandLine(commandString);
  if (runConfiguration.isShowAppleEvents()) {
    commandLine.withEnvironment("AEDebugSends", "1");
    commandLine.withEnvironment("AEDebugReceives", "1");
  }
  return new AppleScriptProcessHandler(commandLine);
}
 
Example 16
Project: reasonml-idea-plugin   File: BsCompiler.java   Source Code and License 5 votes vote down vote up
@Nullable
public ProcessHandler recreate() {
    try {
        killIt();
        m_bsb = new KillableColoredProcessHandler(m_commandLine);
        if (m_outputListener != null) {
            m_bsb.addProcessListener(m_outputListener);
        }
        return m_bsb;
    } catch (ExecutionException e) {
        Notifications.Bus.notify(new RmlNotification("Bsb", "Can't run bsb\n" + e.getMessage(), NotificationType.ERROR));
    }

    return null;
}
 
Example 17
Project: reasonml-idea-plugin   File: BucklescriptProjectComponent.java   Source Code and License 5 votes vote down vote up
@Override
public void run(FileType fileType) {
    if (m_compiler != null && (fileType instanceof RmlFileType || fileType instanceof OclFileType)) {
        ProcessHandler recreate = m_compiler.recreate();
        if (recreate != null) {
            getBsbConsole().attachToProcess(recreate);
            m_compiler.startNotify();
        }
    }
}
 
Example 18
Project: educational-plugin   File: PyCCCommandLineState.java   Source Code and License 5 votes vote down vote up
@Override
protected ProcessHandler doCreateProcess(GeneralCommandLine commandLine) throws ExecutionException {
  ProcessHandler handler = super.doCreateProcess(commandLine);
  handler.addProcessListener(new ProcessAdapter() {
    @Override
    public void processTerminated(@NotNull ProcessEvent event) {
      ApplicationManager.getApplication().invokeLater(() -> EduUtils.deleteWindowDescriptions(myTask, myTaskDir));
    }
  });
  return handler;
}
 
Example 19
Project: Goal-Intellij-Plugin   File: GoalDebugConfiguration.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {


    final CommandLineState state = new CommandLineState(environment) {
        @NotNull
        @Override
        protected ProcessHandler startProcess() throws ExecutionException {
            GoalRuntime runtime = GoalRuntime.instance;
            System.out.println("runtime is created");

            final GeneralCommandLine line = new GeneralCommandLine();
            line.setRedirectErrorStream(true);
            line.setExePath("java");
            line.addParameters("-cp","-debug", runtime.getRuntimePath().toString(),
                    "goal.tools.Run",
                    GoalDebugConfiguration.this.runFilePath);

            System.out.println("command: " + line.getCommandLineString());


            final Process process = line.createProcess();
            return new OSProcessHandler(process, line.getCommandLineString());
        }


    };

    return state;
}
 
Example 20
Project: Goal-Intellij-Plugin   File: GoalRunConfiguration.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor,
                                @NotNull ExecutionEnvironment environment)
        throws ExecutionException {
    final CommandLineState state = new CommandLineState(environment) {
        @NotNull
        @Override
        protected ProcessHandler startProcess() throws ExecutionException {
            final GoalRuntime runtime = GoalRuntime.getInstance();

            //TODO: MAke sure that the preferences are used when running goal.
            //final Path preferences = GoalRunConfiguration.this.writePreferences();

            final GeneralCommandLine line = new GeneralCommandLine();
            line.setRedirectErrorStream(true);
            line.setExePath("java");
            line.addParameters(
                    "-cp", runtime.getRuntimePath().toString(),
                    "goal.tools.Run",
                    //preferences.toString(),
                    GoalRunConfiguration.this.runFilePath
            );
            System.out.println("command: " + line.getCommandLineString());


            final Process process = line.createProcess();

            return new OSProcessHandler(process, line.getCommandLineString());
        }
    };

    return state;
}
 
Example 21
Project: intellij-ce-playground   File: PyEduDebugProcess.java   Source Code and License 5 votes vote down vote up
public PyEduDebugProcess(@NotNull XDebugSession session,
                         @NotNull ServerSocket serverSocket,
                         @NotNull ExecutionConsole executionConsole,
                         @Nullable ProcessHandler processHandler, boolean multiProcess,
                         String scriptName,
                         int line) {
  super(session, serverSocket, executionConsole, processHandler, multiProcess);
  myScriptName = scriptName;
  myLine = line;
}
 
Example 22
Project: mule-intellij-plugins   File: ContextAwareDebugProcess.java   Source Code and License 5 votes vote down vote up
public ContextAwareDebugProcess(@NotNull XDebugSession session, ProcessHandler processHandler, Map<String, XDebugProcess> debugProcesses, String defaultContext) {
    super(session);
    this.processHandler = processHandler;
    this.debugProcesses = debugProcesses;
    this.currentContext = defaultContext;
    this.defaultContext = defaultContext;
}
 
Example 23
Project: intellij-ce-playground   File: AndroidProcessText.java   Source Code and License 5 votes vote down vote up
public void printTo(@NotNull ProcessHandler processHandler) {
  synchronized (myFragments) {
    for (MyFragment fragment : myFragments) {
      processHandler.notifyTextAvailable(fragment.getText(), fragment.getOutputType());
    }
  }
}
 
Example 24
Project: lua-for-idea   File: LuaCommandLineState.java   Source Code and License 5 votes vote down vote up
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
    GeneralCommandLine commandLine = generateCommandLine();

    OSProcessHandler osProcessHandler =
            new LuaProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
    ProcessTerminatedListener.attach(osProcessHandler, runConfiguration.getProject());

    return osProcessHandler;
}
 
Example 25
Project: intellij-ce-playground   File: LogConsoleBase.java   Source Code and License 5 votes vote down vote up
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 26
Project: intellij-ce-playground   File: FakeRerunAction.java   Source Code and License 5 votes vote down vote up
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 27
Project: intellij-ce-playground   File: StopAction.java   Source Code and License 5 votes vote down vote up
@Nullable
private static Pair<List<HandlerItem>, HandlerItem> getItemsList(List<Pair<TaskInfo, ProgressIndicator>> tasks,
                                                                 List<RunContentDescriptor> descriptors,
                                                                 RunContentDescriptor toSelect) {
  if (tasks.isEmpty() && descriptors.isEmpty()) {
    return null;
  }

  List<HandlerItem> items = new ArrayList<HandlerItem>(tasks.size() + descriptors.size());
  HandlerItem selected = null;
  for (final RunContentDescriptor descriptor : descriptors) {
    final ProcessHandler handler = descriptor.getProcessHandler();
    if (handler != null) {
      HandlerItem item = new HandlerItem(descriptor.getDisplayName(), descriptor.getIcon(), false) {
        @Override
        void stop() {
          stopProcess(descriptor);
        }
      };
      items.add(item);
      if (descriptor == toSelect) {
        selected = item;
      }
    }
  }

  boolean hasSeparator = true;
  for (final Pair<TaskInfo, ProgressIndicator> eachPair : tasks) {
    items.add(new HandlerItem(eachPair.first.getTitle(), AllIcons.Process.Step_passive, hasSeparator) {
      @Override
      void stop() {
        eachPair.second.cancel();
      }
    });
    hasSeparator = false;
  }
  return Pair.create(items, selected);
}
 
Example 28
Project: intellij-ce-playground   File: SMTestRunnerConnectionUtil.java   Source Code and License 5 votes vote down vote up
/** @deprecated use {@link #initConsoleView(SMTRunnerConsoleView, String)} (to be removed in IDEA 16) */
@SuppressWarnings({"unused", "deprecation"})
public static void initConsoleView(@NotNull final SMTRunnerConsoleView consoleView,
                                   @NotNull final String testFrameworkName,
                                   @Nullable final TestLocationProvider locator,
                                   final boolean idBasedTreeConstruction,
                                   @Nullable final TestProxyFilterProvider filterProvider) {
  consoleView.addAttachToProcessListener(new AttachToProcessListener() {
    @Override
    public void onAttachToProcess(@NotNull ProcessHandler processHandler) {
      TestConsoleProperties properties = consoleView.getProperties();

      SMTestLocator testLocator = new CompositeTestLocationProvider(locator);

      TestProxyPrinterProvider printerProvider = null;
      if (filterProvider != null) {
        printerProvider = new TestProxyPrinterProvider(consoleView, filterProvider);
      }

      SMTestRunnerResultsForm resultsForm = consoleView.getResultsViewer();
      attachEventsProcessors(properties,
                             resultsForm,
                             resultsForm.getStatisticsPane(),
                             processHandler,
                             testFrameworkName,
                             testLocator,
                             idBasedTreeConstruction,
                             printerProvider);
    }
  });
  consoleView.setHelpId("reference.runToolWindow.testResultsTab");
  consoleView.initUI();
}
 
Example 29
Project: intellij-ce-playground   File: SMTestRunnerConnectionUtil.java   Source Code and License 5 votes vote down vote up
/** @deprecated use {@link #createAndAttachConsole(String, ProcessHandler, TestConsoleProperties)} (to be removed in IDEA 16) */
@SuppressWarnings({"unused", "deprecation"})
public static ConsoleView createAndAttachConsole(@NotNull String testFrameworkName,
                                                 @NotNull ProcessHandler processHandler,
                                                 @NotNull CommandLineState commandLineState,
                                                 @NotNull ModuleRunConfiguration config,
                                                 @NotNull Executor executor) throws ExecutionException {
  TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(config, testFrameworkName, executor);
  return createAndAttachConsole(testFrameworkName, processHandler, consoleProperties, commandLineState.getEnvironment());
}
 
Example 30
Project: intellij-ce-playground   File: ImportedTestConsoleProperties.java   Source Code and License 5 votes vote down vote up
public ImportedTestConsoleProperties(@Nullable SMTRunnerConsoleProperties properties,
                                     File file,
                                     ProcessHandler handler,
                                     Project project, RunProfile runConfiguration,
                                     String frameworkName,
                                     Executor executor) {
  super(project, runConfiguration, frameworkName, executor);
  myProperties = properties;
  myFile = file;
  myHandler = handler;
}
 
Example 31
Project: intellij-ce-playground   File: DefaultExternalSystemExecutionConsoleManager.java   Source Code and License 5 votes vote down vote up
@NotNull
@Override
public ExecutionConsole attachExecutionConsole(@NotNull ExternalSystemTask task,
                                               @NotNull Project project,
                                               @NotNull ExternalSystemRunConfiguration configuration,
                                               @NotNull Executor executor,
                                               @NotNull ExecutionEnvironment env,
                                               @NotNull ProcessHandler processHandler) throws ExecutionException {
  myProcessHandler = processHandler;
  ConsoleView executionConsole = new TextConsoleBuilderImpl(project).getConsole();
  executionConsole.attachToProcess(processHandler);
  return executionConsole;
}
 
Example 32
Project: intellij-ce-playground   File: SnapShooterConfigurationExtension.java   Source Code and License 5 votes vote down vote up
public void attachToProcess(@NotNull final RunConfigurationBase configuration, @NotNull final ProcessHandler handler, RunnerSettings runnerSettings) {
  SnapShooterConfigurationSettings settings = configuration.getUserData(SnapShooterConfigurationSettings.SNAP_SHOOTER_KEY);
  if (settings != null) {
    final Runnable runnable = settings.getNotifyRunnable();
    if (runnable != null) {
      settings.setNotifyRunnable(null);
      handler.addProcessListener(new ProcessAdapter() {
        public void startNotified(final ProcessEvent event) {
          runnable.run();
        }
      });
    }
  }
}
 
Example 33
Project: intellij-ce-playground   File: PythonCommandLineState.java   Source Code and License 5 votes vote down vote up
protected void addTracebackFilter(Project project, ConsoleView consoleView, ProcessHandler processHandler) {
  if (PySdkUtil.isRemote(myConfig.getSdk())) {
    assert processHandler instanceof RemoteProcessControl;
    consoleView
      .addMessageFilter(new PyRemoteTracebackFilter(project, myConfig.getWorkingDirectory(), (RemoteProcessControl)processHandler));
  }
  else {
    consoleView.addMessageFilter(new PythonTracebackFilter(project, myConfig.getWorkingDirectorySafe()));
  }
  consoleView.addMessageFilter(createUrlFilter(processHandler)); // Url filter is always nice to have
}
 
Example 34
Project: intellij-ce-playground   File: ConsoleViewImpl.java   Source Code and License 5 votes vote down vote up
public ConsoleViewImpl(@NotNull final Project project,
                       @NotNull GlobalSearchScope searchScope,
                       boolean viewer,
                       boolean usePredefinedMessageFilter) {
  this(project, searchScope, viewer,
       new ConsoleState.NotStartedStated() {
         @Override
         public ConsoleState attachTo(ConsoleViewImpl console, ProcessHandler processHandler) {
           return new ConsoleViewRunningState(console, processHandler, this, true, true);
         }
       },
       usePredefinedMessageFilter);
}
 
Example 35
Project: intellij-ce-playground   File: BuildAndRestartConsoleAction.java   Source Code and License 5 votes vote down vote up
private boolean isEnabled() {
  if (myModule == null || myModule.isDisposed()) return false;

  final ProcessHandler processHandler = myContentDescriptor.getProcessHandler();
  if (processHandler == null || processHandler.isProcessTerminated()) return false;

  return true;
}
 
Example 36
Project: intellij-ce-playground   File: LogFilesManager.java   Source Code and License 5 votes vote down vote up
public void addLogConsoles(@NotNull RunConfigurationBase runConfiguration, @Nullable ProcessHandler startedProcess) {
  for (LogFileOptions logFileOptions : runConfiguration.getAllLogFiles()) {
    if (logFileOptions.isEnabled()) {
      myLogFiles.add(new LogFile(logFileOptions, runConfiguration, startedProcess));
    }
  }
  myUpdateAlarm.request();
  runConfiguration.createAdditionalTabComponents(myManager, startedProcess);
}
 
Example 37
Project: intellij-ce-playground   File: AndroidEnableAdbServiceAction.java   Source Code and License 5 votes vote down vote up
private static boolean askForClosingDebugSessions(@NotNull Project project) {
  final List<Pair<ProcessHandler, RunContentDescriptor>> pairs = new ArrayList<Pair<ProcessHandler, RunContentDescriptor>>();

  for (Project p : ProjectManager.getInstance().getOpenProjects()) {
    final ProcessHandler[] processes = ExecutionManager.getInstance(p).getRunningProcesses();

    for (ProcessHandler process : processes) {
      if (!process.isProcessTerminated()) {
        final AndroidSessionInfo info = process.getUserData(AndroidDebugRunner.ANDROID_SESSION_INFO);
        if (info != null) {
          pairs.add(Pair.create(process, info.getDescriptor()));
        }
      }
    }
  }

  if (pairs.size() == 0) {
    return true;
  }

  final StringBuilder s = new StringBuilder();

  for (Pair<ProcessHandler, RunContentDescriptor> pair : pairs) {
    if (s.length() > 0) {
      s.append('\n');
    }
    s.append(pair.getSecond().getDisplayName());
  }

  final int r = Messages.showYesNoDialog(project, AndroidBundle.message("android.debug.sessions.will.be.closed", s),
                                         AndroidBundle.message("android.disable.adb.service.title"), Messages.getQuestionIcon());
  return r == Messages.YES;
}
 
Example 38
Project: intellij-ce-playground   File: AndroidRunningState.java   Source Code and License 5 votes vote down vote up
private boolean checkDdms() {
  AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
  if (myDebugMode && bridge != null && AdbService.canDdmsBeCorrupted(bridge)) {
    message(AndroidBundle.message("ddms.corrupted.error"), STDERR);
    JComponent component = myConsole == null ? null : myConsole.getComponent();
    if (component != null) {
      final ExecutionEnvironment environment = LangDataKeys.EXECUTION_ENVIRONMENT.getData(DataManager.getInstance().getDataContext(component));
      if (environment == null) {
        return false;
      }

      myConsole.printHyperlink(AndroidBundle.message("restart.adb.fix.text"), new HyperlinkInfo() {
        @Override
        public void navigate(Project project) {
          AdbService.getInstance().restartDdmlib(project);

          final ProcessHandler processHandler = getProcessHandler();
          if (!processHandler.isProcessTerminated()) {
            processHandler.destroyProcess();
          }
          ExecutionUtil.restart(environment);
        }
      });
      myConsole.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
    }
    return false;
  }
  return true;
}
 
Example 39
Project: intellij-ce-playground   File: RunContentDescriptor.java   Source Code and License 5 votes vote down vote up
public RunContentDescriptor(@Nullable ExecutionConsole executionConsole,
                            @Nullable ProcessHandler processHandler,
                            @NotNull JComponent component,
                            String displayName,
                            @Nullable Icon icon) {
  this(executionConsole, processHandler, component, displayName, icon, null, null);
}
 
Example 40
Project: intellij-ce-playground   File: RunConfigurationExtensionsManager.java   Source Code and License 5 votes vote down vote up
public void attachExtensionsToProcess(@NotNull final U configuration,
                                      @NotNull final ProcessHandler handler,
                                      RunnerSettings runnerSettings) {
  // only for enabled extensions
  for (T extension : getEnabledExtensions(configuration, runnerSettings)) {
    extension.attachToProcess(configuration, handler, runnerSettings);
  }
}