當前位置: 首頁>>代碼示例>>Java>>正文


Java OSProcessHandler類代碼示例

本文整理匯總了Java中com.intellij.execution.process.OSProcessHandler的典型用法代碼示例。如果您正苦於以下問題:Java OSProcessHandler類的具體用法?Java OSProcessHandler怎麽用?Java OSProcessHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OSProcessHandler類屬於com.intellij.execution.process包,在下文中一共展示了OSProcessHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showHelperProcessRunContent

import com.intellij.execution.process.OSProcessHandler; //導入依賴的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: startProcess

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
  final OSProcessHandler handler = JavaCommandLineStateUtil.startProcess(createCommandLine());
  ProcessTerminatedListener.attach(handler, myProject, JavadocBundle.message("javadoc.generate.exited"));
  handler.addProcessListener(new ProcessAdapter() {
    public void processTerminated(ProcessEvent event) {
      if (myConfiguration.OPEN_IN_BROWSER) {
        File url = new File(myConfiguration.OUTPUT_DIRECTORY, INDEX_HTML);
        if (url.exists() && event.getExitCode() == 0) {
          BrowserUtil.browse(url);
        }
      }
    }
  });
  return handler;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:JavadocGeneratorRunProfile.java

示例3: shutdownProcess

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
private void shutdownProcess() {
  final OSProcessHandler processHandler = myProcessHandler;
  if (processHandler != null) {
    if (!processHandler.isProcessTerminated()) {
      boolean forceQuite = true;
      try {
        writeLine(EXIT_COMMAND);
        forceQuite = !processHandler.waitFor(500);
        if (forceQuite) {
          LOG.warn("File watcher is still alive. Doing a force quit.");
        }
      }
      catch (IOException ignore) { }
      if (forceQuite) {
        processHandler.destroyProcess();
      }
    }

    myProcessHandler = null;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:NativeFileWatcherImpl.java

示例4: OCamlTopLevelConsoleView

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
public OCamlTopLevelConsoleView(@NotNull final Project project, @NotNull final ContentManager contentManager, final Sdk topLevelSdk) throws ExecutionException {
    super(project, contentManager);
    myConsoleNumber = ++ourLastConsoleNumber;

    final GeneralCommandLine cmd = createCommandLine(topLevelSdk);
    myConsoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
    myProcessHandler = new OSProcessHandler(cmd.createProcess(), cmd.getCommandLineString());
    myConsoleView.attachToProcess(myProcessHandler);
    ProcessTerminatedListener.attach(myProcessHandler);

    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    final DefaultActionGroup group = new DefaultActionGroup();
    group.add(getOCamlToolWindowOpenCloseAction(true, false));
    group.addAll(myConsoleView.createConsoleActions());
    group.add(getOCamlToolWindowSettingsAction());
    group.add(getOCamlToolWindowOpenCloseAction(false, true));
    final JComponent toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false).getComponent();
    toolbar.setMaximumSize(new Dimension(toolbar.getPreferredSize().width, Integer.MAX_VALUE));

    add(toolbar);
    add(myConsoleView.getComponent());

    myConsoleView.getComponent().requestFocus();
    myProcessHandler.startNotify();
}
 
開發者ID:traff,項目名稱:intellij-ocaml,代碼行數:27,代碼來源:OCamlTopLevelConsoleView.java

示例5: attachToProcess

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
@Override
public void attachToProcess(@NotNull final RunConfigurationBase configuration, @NotNull final ProcessHandler handler, @Nullable RunnerSettings runnerSettings) {
    super.attachToProcess(configuration, handler, runnerSettings);
    if (!(runnerSettings instanceof DynatraceRunnerSettings)) {
        return;
    }
    if (!(handler instanceof OSProcessHandler)) {
        return;
    }

    DynatraceConfigurableStorage executionSettings = DynatraceConfigurableStorage.getOrCreateStorage(configuration);
    handler.putCopyableUserData(PROFILE_KEY, executionSettings.getSystemProfile());

    OSProcessHandler procHandler = (OSProcessHandler) handler;
    handler.addProcessListener(new DynatraceProcessListener(executionSettings.getSystemProfile(), configuration.getProject()));

    if(!(configuration instanceof JavaTestConfigurationBase)) {
        return;
    }

    Matcher matcher = TRID_EXTRACTOR.matcher(procHandler.getCommandLine());
    if (!matcher.find()) {
        return;
    }
    handler.putCopyableUserData(TRID_KEY, matcher.group(1));
}
 
開發者ID:Dynatrace,項目名稱:Dynatrace-AppMon-IntelliJ-IDEA-Integration-Plugin,代碼行數:27,代碼來源:DynatraceRunConfigurationExtension.java

示例6: testJUnitTests

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
public void testJUnitTests() throws Throwable {
  doImport("intellij-integration/tests/java/org/pantsbuild/testprojects");

  assertFirstSourcePartyModules("intellij-integration_tests_java_org_pantsbuild_testprojects_testprojects");

  PantsExecuteTaskResult result = pantsCompileModule("intellij-integration_tests_java_org_pantsbuild_testprojects_testprojects");
  assertPantsCompileExecutesAndSucceeds(result);
  assertTrue(result.output.isPresent());
  assertTrue(result.output.get().contains("compile intellij-integration/tests/java/org/pantsbuild/testprojects:testprojects"));
  assertSuccessfulTest(
    "intellij-integration_tests_java_org_pantsbuild_testprojects_testprojects", "org.pantsbuild.testprojects.JUnitIntegrationTest");
  final OSProcessHandler processHandler = runJUnitTest(
    "intellij-integration_tests_java_org_pantsbuild_testprojects_testprojects",
    "org.pantsbuild.testprojects.JUnitIntegrationTest",
    "-DPANTS_FAIL_TEST=true"
  );
  assertTrue("Tests should fail!", processHandler.getProcess().exitValue() != 0);
}
 
開發者ID:pantsbuild,項目名稱:intellij-pants-plugin,代碼行數:19,代碼來源:OSSPantsTestExamplesIntegrationTest.java

示例7: actionPerformed

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
@Override
public void actionPerformed(@NotNull final AnActionEvent event) {
  final VirtualFile project = getXCodeProject(event);

  if(project == null) {
    return;
  }

  final GeneralCommandLine commandLine =
      new GeneralCommandLine("open", FileUtil.toSystemDependentName(project.getPath()));

  try {
    final ProcessHandler processHandler =
        new OSProcessHandler(commandLine);
    processHandler.startNotify();
    processHandler.waitFor();
  } catch(ExecutionException e) {
    e.printStackTrace();
  }
}
 
開發者ID:defrac,項目名稱:defrac-plugin-intellij,代碼行數:21,代碼來源:SwitchToXCodeAction.java

示例8: startProcess

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
  final OSProcessHandler handler = JavaCommandLineStateUtil.startProcess(createCommandLine());
  ProcessTerminatedListener.attach(handler, myProject, JavadocBundle.message("javadoc.generate.exited"));
  handler.addProcessListener(new ProcessAdapter() {
    public void processTerminated(ProcessEvent event) {
      if (OPEN_IN_BROWSER) {
        File url = new File(OUTPUT_DIRECTORY, INDEX_HTML);
        if (url.exists() && event.getExitCode() == 0) {
          BrowserUtil.browse(url);
        }
      }
    }
  });
  return handler;
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:17,代碼來源:JavadocConfiguration.java

示例9: findRunningConsoleByCmdLine

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
/** @deprecated use lookup by user data (to remove in IDEA 13) */
public static Collection<RunContentDescriptor> findRunningConsoleByCmdLine(final Project project,
                                                                           @NotNull final NotNullFunction<String, Boolean> cmdLineMatcher) {
  return findRunningConsole(project, new NotNullFunction<RunContentDescriptor, Boolean>() {
    @NotNull
    @Override
    public Boolean fun(RunContentDescriptor selectedContent) {
      final ProcessHandler processHandler = selectedContent.getProcessHandler();
      if (processHandler instanceof OSProcessHandler && !processHandler.isProcessTerminated()) {
        final String commandLine = ((OSProcessHandler)processHandler).getCommandLine();
        return cmdLineMatcher.fun(commandLine);
      }
      return false;
    }
  });
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:17,代碼來源:ExecutionHelper.java

示例10: start

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
public void start() {
  synchronized (myLock) {
    checkNotStarted();

    try {
      myProcess = myCommandLine.createProcess();
      if (LOG.isDebugEnabled()) {
        LOG.debug(myCommandLine.toString());
      }
      myHandler = new OSProcessHandler(myProcess, myCommandLine.getCommandLineString());
      startHandlingStreams();
    } catch (Throwable t) {
      myListeners.getMulticaster().startFailed(t);
    }
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:17,代碼來源:SvnCommand.java

示例11: schedulePostExecutionActions

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
private void schedulePostExecutionActions(final OSProcessHandler result, final String title) {
  final ProgressManager manager = ProgressManager.getInstance();
  ApplicationManager.getApplication()
      .invokeLater(
          () -> {
            manager.run(
                new Task.Backgroundable(mProject, title, true) {
                  public void run(@NotNull final ProgressIndicator indicator) {
                    try {
                      result.waitFor();
                    } finally {
                      indicator.cancel();
                    }
                    if (!BuckToolWindowFactory.isRunToolWindowVisible(mProject)) {
                      BuckToolWindowFactory.showRunToolWindow(mProject);
                    }
                  }
                });
          });
}
 
開發者ID:facebook,項目名稱:buck,代碼行數:21,代碼來源:TestExecutionState.java

示例12: createScriptExecutable

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
private ExecutableObject createScriptExecutable()
{
	return new ColoredCommandLineExecutableObject(new String[]{
			myCatalinaScriptFile.getAbsolutePath(),
			myScriptCommand
	}, null)
	{
		@Override
		public OSProcessHandler createProcessHandler(String workingDirectory, Map<String, String> envVariables) throws ExecutionException
		{
			List<String> customJavaOptions = getCustomJavaOptions();
			if(!customJavaOptions.isEmpty())
			{
				envVariables = new HashMap<>(envVariables);
				String javaOptions = StringUtil.notNullize(envVariables.get(JAVA_VM_ENV_VARIABLE)) + " " + StringUtil.join(customJavaOptions, " ");
				envVariables.put(JAVA_VM_ENV_VARIABLE, javaOptions);
			}
			return super.createProcessHandler(workingDirectory, envVariables);
		}
	};
}
 
開發者ID:consulo,項目名稱:consulo-javaee,代碼行數:22,代碼來源:TomcatStartupPolicy.java

示例13: createProcessHandler

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
@Override
public OSProcessHandler createProcessHandler(String workingDirectory, Map<String, String> envVariables) throws ExecutionException
{
	GeneralCommandLine commandLine = createCommandLine(myParameters, envVariables);
	if(workingDirectory == null && myParameters.length > 0)
	{
		File parentFile = new File(myParameters[0]).getParentFile();
		if(parentFile != null)
		{
			workingDirectory = parentFile.getAbsolutePath();
		}
	}
	commandLine.withWorkDirectory(workingDirectory);
	commandLine.withEnvironment(CLASSPATH_VAR_NAME, "");
	commandLine.withEnvironment(envVariables);
	return createProcessHandler(commandLine);
}
 
開發者ID:consulo,項目名稱:consulo-javaee,代碼行數:18,代碼來源:ColoredCommandLineExecutableObject.java

示例14: createProcessHandler

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
public OSProcessHandler createProcessHandler(String workingDirectory, Map<String,String> envVariables) throws ExecutionException {
  final File executableFile;
  try {
    executableFile = createNewExecutableFile();
    FileOutputStream outputStream = new FileOutputStream(executableFile);
    try {
      FileUtil.copy(new ByteArrayInputStream(getScript().getBytes()), outputStream);
    }
    finally {
      outputStream.close();
    }
  }
  catch (IOException e) {
    throw new ExecutionException(J2EEBundle.message("message.text.error.while.creating.temp.file", e.getLocalizedMessage()));
  }
  final File toDelete = myDirectoryForScript == null ? executableFile.getParentFile() : executableFile;
  toDelete.deleteOnExit();

  OSProcessHandler result = createExecutable(executableFile).createProcessHandler(workingDirectory, envVariables);
  result.addProcessListener(new ProcessAdapter() {
    public void processTerminated(ProcessEvent event) {
      FileUtil.delete(toDelete);
    }
  });
  return result;
}
 
開發者ID:consulo,項目名稱:consulo-javaee,代碼行數:27,代碼來源:ScriptExecutableObject.java

示例15: shutdownProcess

import com.intellij.execution.process.OSProcessHandler; //導入依賴的package包/類
private void shutdownProcess() {
  final OSProcessHandler processHandler = myProcessHandler;
  if (processHandler != null) {
    if (!processHandler.isProcessTerminated()) {
      boolean killProcess = true;
      try {
        writeLine(EXIT_COMMAND);
        killProcess = !processHandler.waitFor(500);
        if (killProcess) {
          LOG.warn("File watcher is still alive. Doing a force quit.");
        }
      }
      catch (IOException ignore) {
      }
      if (killProcess) {
        processHandler.destroyProcess();
      }
    }

    myProcessHandler = null;
  }
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:23,代碼來源:NativeFileWatcherImpl.java


注:本文中的com.intellij.execution.process.OSProcessHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。