本文整理汇总了Java中com.intellij.execution.process.OSProcessHandler.addProcessListener方法的典型用法代码示例。如果您正苦于以下问题:Java OSProcessHandler.addProcessListener方法的具体用法?Java OSProcessHandler.addProcessListener怎么用?Java OSProcessHandler.addProcessListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.process.OSProcessHandler
的用法示例。
在下文中一共展示了OSProcessHandler.addProcessListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例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 (OPEN_IN_BROWSER) {
File url = new File(OUTPUT_DIRECTORY, INDEX_HTML);
if (url.exists() && event.getExitCode() == 0) {
BrowserUtil.browse(url);
}
}
}
});
return handler;
}
示例3: 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;
}
示例4: 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;
}
示例5: startProcess
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
/**
* {@link ProcessListenerLivingDoc#startNotified(ProcessEvent)} is the listener method for <code>osProcessHandler.startNotify()</code>
*/
@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
OSProcessHandler osProcessHandler = super.startProcess();
osProcessHandler.addProcessListener(new ProcessListenerLivingDoc(runConfiguration));
osProcessHandler.startNotify(); // start capturing the process output
return osProcessHandler;
}
示例6: execute
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
public void execute(AnActionEvent event, DataContext dataContext, long executionId, @Nullable final ProcessListener processListener) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
FileDocumentManager.getInstance().saveAllDocuments();
try {
if (isUseConsole()) {
ExecutionEnvironment environment = ExecutionEnvironmentBuilder.create(project,
DefaultRunExecutor.getRunExecutorInstance(),
new ToolRunProfile(this, dataContext)).build();
environment.setExecutionId(executionId);
environment.getRunner().execute(environment, new ProgramRunner.Callback() {
@Override
public void processStarted(RunContentDescriptor descriptor) {
ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null && processListener != null) {
processHandler.addProcessListener(processListener);
}
}
});
}
else {
GeneralCommandLine commandLine = createCommandLine(dataContext);
if (commandLine == null) {
return;
}
OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
handler.addProcessListener(new ToolProcessAdapter(project, synchronizeAfterExecution(), getName()));
if (processListener != null) {
handler.addProcessListener(processListener);
}
handler.startNotify();
}
}
catch (ExecutionException ex) {
ExecutionErrorDialog.show(ex, ToolsBundle.message("tools.process.start.error"), project);
}
}
示例7: startProcess
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler osProcessHandler = createJavaParameters().createOSProcessHandler();
osProcessHandler.putUserData(STATE, this);
osProcessHandler.addProcessListener(new MyProcessAdapter());
final List<XsltRunnerExtension> extensions = XsltRunnerExtension.getExtensions(myXsltRunConfiguration, myIsDebugger);
for (XsltRunnerExtension extension : extensions) {
osProcessHandler.addProcessListener(extension.createProcessListener(myXsltRunConfiguration.getProject(), myExtensionData));
}
return osProcessHandler;
}
示例8: startProcess
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
validateIfProjectIsPrebuilt();
final OSProcessHandler osProcessHandler = super.startProcess();
osProcessHandler.addProcessListener(new EquinoxRestartProcessListener(appModule, environment, executor));
if (configurationValues.isAutoDiagnostic()) {
osProcessHandler.addProcessListener(new EquinoxDiagnosisProcessListener(appModule, configurationValues));
}
return osProcessHandler;
}
示例9: getState
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
return new JavaCommandLineState(env) {
private AppletHtmlFile myHtmlURL = null;
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters params = new JavaParameters();
myHtmlURL = getHtmlURL();
if (myHtmlURL != null) {
final int classPathType = myHtmlURL.isHttp() ? JavaParameters.JDK_ONLY : JavaParameters.JDK_AND_CLASSES;
final RunConfigurationModule runConfigurationModule = getConfigurationModule();
JavaParametersUtil.configureModule(runConfigurationModule, params, classPathType, ALTERNATIVE_JRE_PATH_ENABLED ? ALTERNATIVE_JRE_PATH : null);
final String policyFileParameter = getPolicyFileParameter();
if (policyFileParameter != null) {
params.getVMParametersList().add(policyFileParameter);
}
params.getVMParametersList().addParametersString(VM_PARAMETERS);
params.setMainClass("sun.applet.AppletViewer");
params.getProgramParametersList().add(myHtmlURL.getUrl());
}
return params;
}
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler handler = super.startProcess();
final AppletHtmlFile htmlUrl = myHtmlURL;
if (htmlUrl != null) {
handler.addProcessListener(new ProcessAdapter() {
public void processTerminated(ProcessEvent event) {
htmlUrl.deleteFile();
}
});
}
return handler;
}
};
}
示例10: startProcess
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler osProcessHandler = createJavaParameters().createOSProcessHandler();
osProcessHandler.putUserData(STATE, this);
osProcessHandler.addProcessListener(new MyProcessAdapter());
final List<XsltRunnerExtension> extensions = XsltRunnerExtension.getExtensions(myXsltRunConfiguration, myIsDebugger);
for (XsltRunnerExtension extension : extensions) {
osProcessHandler.addProcessListener(extension.createProcessListener(myXsltRunConfiguration.getProject(), myExtensionData));
}
return osProcessHandler;
}
示例11: installEmberCLI
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
private void installEmberCLI() {
final GeneralCommandLine generalCommandLine = new GeneralCommandLine("npm", "install","-g", "ember-cli");
generalCommandLine.setWorkDirectory(getNewProjectFilePath());
try {
final OSProcessHandler handler = new OSProcessHandler(generalCommandLine);
handler.addProcessListener(this);
handler.startNotify();
generalCommandLine.createProcess();
} catch (Exception e) {
handleError(e);
}
}
示例12: startProcess
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler osProcessHandler = createJavaParameters().createOSProcessHandler();
osProcessHandler.putUserData(STATE, this);
osProcessHandler.addProcessListener(new MyProcessAdapter());
final List<XsltRunnerExtension> extensions = XsltRunnerExtension.getExtensions(myXsltRunConfiguration, myIsDebugger);
for (XsltRunnerExtension extension : extensions) {
osProcessHandler.addProcessListener(extension.createProcessListener(myXsltRunConfiguration.getProject(), myExtensionData));
}
return osProcessHandler;
}
示例13: getState
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
return new JavaCommandLineState(env) {
private AppletHtmlFile myHtmlURL = null;
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters params = new JavaParameters();
myHtmlURL = getHtmlURL();
if (myHtmlURL != null) {
final int classPathType = myHtmlURL.isHttp() ? JavaParameters.JDK_ONLY : JavaParameters.JDK_AND_CLASSES;
final RunConfigurationModule runConfigurationModule = getConfigurationModule();
JavaParametersUtil.configureModule(runConfigurationModule, params, classPathType, ALTERNATIVE_JRE_PATH_ENABLED ? ALTERNATIVE_JRE_PATH : null);
final String policyFileParameter = getPolicyFileParameter();
if (policyFileParameter != null) {
params.getVMParametersList().add(policyFileParameter);
}
params.getVMParametersList().addParametersString(VM_PARAMETERS);
params.setMainClass("sun.applet.AppletViewer");
params.getProgramParametersList().add(myHtmlURL.getUrl());
}
return params;
}
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler handler = super.startProcess();
final AppletHtmlFile htmlUrl = myHtmlURL;
if (htmlUrl != null) {
handler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
htmlUrl.deleteFile();
}
});
}
return handler;
}
};
}
示例14: executeCommand
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
@NotNull
public static ExecutionStatus executeCommand(@NotNull GeneralCommandLine commandLine,
@Nullable final OutputProcessor processor,
@Nullable WaitingStrategies.Strategy strategy) throws ExecutionException {
LOG.info(commandLine.getCommandLineString());
OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), "");
final ProcessAdapter listener = new ProcessAdapter() {
@Override
public void onTextAvailable(final ProcessEvent event, final Key outputType) {
if (processor != null) {
final String message = event.getText();
processor.onTextAvailable(message);
}
}
};
if (!(strategy instanceof WaitingStrategies.DoNotWait)) {
handler.addProcessListener(listener);
}
handler.startNotify();
try {
if (!(strategy instanceof WaitingStrategies.WaitForever)) {
if (strategy instanceof WaitingStrategies.WaitForTime) {
handler.waitFor(((WaitingStrategies.WaitForTime)strategy).getTimeMs());
}
}
else {
handler.waitFor();
}
}
catch (ProcessCanceledException e) {
return ExecutionStatus.ERROR;
}
if (!handler.isProcessTerminated()) {
return ExecutionStatus.TIMEOUT;
}
if (!(strategy instanceof WaitingStrategies.DoNotWait)) {
handler.removeProcessListener(listener);
}
int exitCode = handler.getProcess().exitValue();
return exitCode == 0 ? ExecutionStatus.SUCCESS : ExecutionStatus.ERROR;
}
示例15: getState
import com.intellij.execution.process.OSProcessHandler; //导入方法依赖的package包/类
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
final VirtualFile script = getScriptFile();
if (script == null) {
throw new CantRunException("Cannot find script " + scriptPath);
}
final GroovyScriptRunner scriptRunner = findConfiguration();
if (scriptRunner == null) {
throw new CantRunException("Unknown script type " + scriptPath);
}
final Module module = ObjectUtils.chooseNotNull(getModule(), ContainerUtil.getFirstItem(getValidModules()));
if (!scriptRunner.ensureRunnerConfigured(module, this, executor, getProject())) {
return null;
}
final boolean tests = ProjectRootManager.getInstance(getProject()).getFileIndex().isInTestSourceContent(script);
return new JavaCommandLineState(environment) {
@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler handler = super.startProcess();
handler.setShouldDestroyProcessRecursively(true);
if (scriptRunner.shouldRefreshAfterFinish()) {
handler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
if (!ApplicationManager.getApplication().isDisposed()) {
VirtualFileManager.getInstance().asyncRefresh(null);
}
}
});
}
return handler;
}
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
JavaParameters params = createJavaParametersWithSdk(module);
ProgramParametersUtil.configureConfiguration(params, GroovyScriptRunConfiguration.this);
scriptRunner.configureCommandLine(params, module, tests, script, GroovyScriptRunConfiguration.this);
return params;
}
};
}