use of org.eclipse.debug.core.IStreamListener in project linuxtools by eclipse.
the class DockerComposeConsole method setDockerComposeProcess.
public void setDockerComposeProcess(final IProcess dockerComposeProcess) {
this.dockerComposeProcess = dockerComposeProcess;
// activate and clear the console if it has previous content
activate();
clearConsole();
// catch up with the content that was already output by the Java Process
writeContentInConsole(dockerComposeProcess.getStreamsProxy().getOutputStreamMonitor().getContents());
// then follow the streams
dockerComposeProcess.getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() {
@Override
public void streamAppended(final String text, final IStreamMonitor monitor) {
writeContentInConsole(text);
}
});
dockerComposeProcess.getStreamsProxy().getErrorStreamMonitor().addListener(new IStreamListener() {
@Override
public void streamAppended(final String text, final IStreamMonitor monitor) {
writeContentInConsole(text);
}
});
}
use of org.eclipse.debug.core.IStreamListener in project erlide_eclipse by erlang.
the class ToolExecutor method run_0.
@Deprecated
public ToolResults run_0(final String cmd0, final String args, final String wdir, final ProgressCallback progressCallback, final BuildNotifier notifier) {
final String cmd = new Path(cmd0).isAbsolute() ? cmd0 : ToolExecutor.getToolLocation(cmd0);
if (cmd == null) {
ErlLogger.warn("Tool '" + cmd0 + "' can't be found in $PATH");
return new ToolResults();
}
final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
final ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE);
if (type == null) {
return null;
}
try {
final ILaunchConfigurationWorkingCopy launchConfig = type.newInstance(null, launchManager.generateLaunchConfigurationName("erlTool"));
launchConfig.setAttribute(IExternalToolConstants.ATTR_LOCATION, cmd);
launchConfig.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, args);
launchConfig.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, wdir);
launchConfig.setAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
launchConfig.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
final ILaunch myLaunch = launchConfig.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor(), false, false);
final ToolResults result = new ToolResults();
if (myLaunch.getProcesses().length == 0) {
ErlLogger.error("Tool process was not created?!");
return null;
}
final IProcess process = myLaunch.getProcesses()[0];
process.getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() {
@Override
public void streamAppended(final String text, final IStreamMonitor mon) {
final List<String> lines = Arrays.asList(text.split("\n"));
if (progressCallback != null) {
for (final String line : lines) {
progressCallback.stdout(line);
}
}
}
});
process.getStreamsProxy().getErrorStreamMonitor().addListener(new IStreamListener() {
@Override
public void streamAppended(final String text, final IStreamMonitor mon) {
final List<String> lines = Arrays.asList(text.split("\n"));
if (progressCallback != null) {
for (final String line : lines) {
progressCallback.stderr(line);
}
}
}
});
boolean done = false;
try {
Thread.sleep(60);
} catch (final InterruptedException e1) {
}
final boolean canceled = notifier != null && notifier.isCanceled();
while (!done && !canceled) {
try {
result.exit = process.getExitValue();
done = true;
} catch (final Exception e) {
try {
Thread.sleep(60);
} catch (final InterruptedException e1) {
}
}
}
if (canceled) {
process.terminate();
}
return result;
} catch (final CoreException e) {
ErlLogger.error(e);
return null;
}
}
use of org.eclipse.debug.core.IStreamListener in project erlide_eclipse by erlang.
the class Backend method getShell.
@Override
public IBackendShell getShell(final String id) {
final IBackendShell shell = shellManager.openShell(id);
final IStreamsProxy proxy = getStreamsProxy();
if (proxy != null) {
final IStreamMonitor errorStreamMonitor = proxy.getErrorStreamMonitor();
errorStreamMonitor.addListener(new IStreamListener() {
@Override
public void streamAppended(final String text, final IStreamMonitor monitor) {
shell.add(text, IoRequestKind.STDERR);
}
});
final IStreamMonitor outputStreamMonitor = proxy.getOutputStreamMonitor();
outputStreamMonitor.addListener(new IStreamListener() {
@Override
public void streamAppended(final String text, final IStreamMonitor monitor) {
shell.add(text, IoRequestKind.STDOUT);
}
});
}
return shell;
}
use of org.eclipse.debug.core.IStreamListener in project titan.EclipsePlug-ins by eclipse.
the class SingleExecutor method createProcess.
/**
* Executes the executable parameterized with the configuration file describing the test session.
*
*@param actualConfigPath the path of the configuration file to call the executable with.
*
* @see #startExecution(boolean)
*/
private void createProcess(final String actualConfigPath) {
ProcessBuilder pb = new ProcessBuilder();
Map<String, String> env = pb.environment();
if (!appendEnvironmentalVariables) {
env.clear();
}
if (null != environmentalVariables) {
try {
EnvironmentHelper.resolveVariables(env, environmentalVariables);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
final File executableFile = new File(executablePath);
if (!executableFile.exists()) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(null, "Execution failed", "The executable `" + executableFile + "' does not exist.");
}
});
}
EnvironmentHelper.setTitanPath(env);
EnvironmentHelper.set_LICENSE_FILE_PATH(env);
EnvironmentHelper.set_LD_LIBRARY_PATH(DynamicLinkingHelper.getProject(projectName), env);
MessageConsole console = TITANDebugConsole.getConsole();
List<String> command = new ArrayList<String>();
command.add("sh");
command.add("-c");
command.add(" sleep 1; cd '" + PathConverter.convert(workingdirectoryPath, true, console) + "'; '" + PathConverter.convert(executablePath, true, console) + "' '" + PathConverter.convert(actualConfigPath, true, console) + "'");
MessageConsoleStream stream = TITANConsole.getConsole().newMessageStream();
for (String c : command) {
stream.print(c + ' ');
}
stream.println();
pb.command(command);
pb.redirectErrorStream(true);
if (null != workingdirectoryPath) {
File workingDir = new File(workingdirectoryPath);
if (!workingDir.exists()) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(null, "Execution failed", "The working directory `" + workingdirectoryPath + "' does not exist.");
}
});
}
pb.directory(workingDir);
}
try {
proc = pb.start();
if (null != mainControllerRoot) {
ILaunch launch = ((LaunchElement) mainControllerRoot.parent()).launch();
process = DebugPlugin.newProcess(launch, proc, MAIN_CONTROLLER);
}
IStreamsProxy proxy = process.getStreamsProxy();
if (null != proxy) {
IStreamMonitor outputstreammonitor = proxy.getOutputStreamMonitor();
IStreamListener listener = new IStreamListener() {
@Override
public void streamAppended(final String text, final IStreamMonitor monitor) {
processConsoleOutput(text);
}
};
if (null != outputstreammonitor) {
String temp = outputstreammonitor.getContents();
processConsoleOutput(temp);
outputstreammonitor.addListener(listener);
}
}
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
proc = null;
}
}
Aggregations