本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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();
}
示例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);
}
示例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();
}
}
示例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;
}
示例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;
}
});
}
示例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);
}
}
}
示例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);
}
}
});
});
}
示例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);
}
};
}
示例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);
}
示例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;
}
示例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;
}
}