当前位置: 首页>>代码示例>>Java>>正文


Java ProcessHandler类代码示例

本文整理汇总了Java中com.intellij.execution.process.ProcessHandler的典型用法代码示例。如果您正苦于以下问题:Java ProcessHandler类的具体用法?Java ProcessHandler怎么用?Java ProcessHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProcessHandler类属于com.intellij.execution.process包,在下文中一共展示了ProcessHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showHelperProcessRunContent

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
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;
    }
 
开发者ID:beansoftapp,项目名称:react-native-console,代码行数:26,代码来源:RunnerUtil.java

示例2: createToolWindowContent

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:27,代码来源:BsToolWindowFactory.java

示例3: createAdditionalTabComponents

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:XsltRunConfiguration.java

示例4: createListener

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
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));
    }
}
 
开发者ID:samebug,项目名称:samebug-idea-plugin,代码行数:22,代码来源:RunDebugWatcher.java

示例5: tryToCloseOldSessions

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
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();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AndroidDebugRunner.java

示例6: getCopyOfCompilerManifestFile

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
@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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:AndroidRunConfigurationBase.java

示例7: stopProcess

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
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();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:StopProcessAction.java

示例8: createDebugProcess

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PyEduDebugRunner.java

示例9: restartRunProfile

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
@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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ExecutionManagerImpl.java

示例10: actionPerformed

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
@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) {
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:EOFAction.java

示例11: disposeDebugProcess

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
@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();
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PyDebuggerTask.java

示例12: startRemoteProcess

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PyRemoteProcessStarter.java

示例13: setAutoTestEnabled

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
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);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AutoTestManager.java

示例14: startProcess

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
@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);
}
 
开发者ID:beansoftapp,项目名称:react-native-console,代码行数:12,代码来源:FreeRunConfiguration.java

示例15: startProcess

import com.intellij.execution.process.ProcessHandler; //导入依赖的package包/类
@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);
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:40,代码来源:AppleScriptScriptCommandLineState.java


注:本文中的com.intellij.execution.process.ProcessHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。