use of org.eclipse.debug.core.model.IStreamsProxy 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.model.IStreamsProxy in project webtools.servertools by eclipse.
the class TomcatRuntime method checkForCompiler.
/**
* Checks for the existence of the Java compiler in the given java
* executable. A main program is run (<code>org.eclipse.jst.tomcat.core.
* internal.ClassDetector</code>), that dumps a true or false value
* depending on whether the compiler is found. This output is then
* parsed and cached for future reference.
*
* @return true if the compiler was found
*/
protected boolean checkForCompiler() {
// first try the cache
File javaHome = getVMInstall().getInstallLocation();
try {
Boolean b = sdkMap.get(javaHome);
return b.booleanValue();
} catch (Exception e) {
// ignore
}
// locate tomcatcore.jar - it contains the class detector main program
File file = TomcatPlugin.getPlugin();
if (file != null && file.exists()) {
IVMRunner vmRunner = getVMInstall().getVMRunner(ILaunchManager.RUN_MODE);
VMRunnerConfiguration config = new VMRunnerConfiguration("org.eclipse.jst.server.tomcat.core.internal.ClassDetector", new String[] { file.getAbsolutePath() });
config.setProgramArguments(new String[] { "com.sun.tools.javac.Main" });
ILaunch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
try {
vmRunner.run(config, launch, null);
for (int i = 0; i < 600; i++) {
// wait no more than 30 seconds (600 * 50 mils)
if (launch.isTerminated()) {
break;
}
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// ignore
}
}
IStreamsProxy streamsProxy = launch.getProcesses()[0].getStreamsProxy();
String text = null;
if (streamsProxy != null) {
text = streamsProxy.getOutputStreamMonitor().getContents();
if (text != null && text.length() > 0) {
boolean found = false;
if ("true".equals(text))
found = true;
sdkMap.put(javaHome, new Boolean(found));
return found;
}
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error checking for JDK", e);
} finally {
if (!launch.isTerminated()) {
try {
launch.terminate();
} catch (Exception ex) {
// ignore
}
}
}
}
// log error that we were unable to check for the compiler
TomcatPlugin.log(MessageFormat.format("Failed compiler check for {0}", (Object[]) new String[] { javaHome.getAbsolutePath() }));
return false;
}
use of org.eclipse.debug.core.model.IStreamsProxy in project titan.EclipsePlug-ins by eclipse.
the class CliExecutor method executeNextTestElement.
/**
* Executes the next testcase or control part whose name is stored in the execute list.
*/
private void executeNextTestElement() {
if (JniExecutor.MC_READY != suspectedLastState) {
createMainTestComponent();
return;
}
if (executeList.isEmpty()) {
return;
}
String testElement = executeList.remove(0);
IStreamsProxy proxy = process.getStreamsProxy();
if (proxy != null) {
try {
suspectedLastState = JniExecutor.MC_EXECUTING_TESTCASE;
proxy.write(testElement);
if ("smtc \n".equals(testElement)) {
executingConfigFile = true;
}
} catch (IOException e) {
ErrorReporter.logError(EXTERNAL_TERMINATION);
terminate(true);
}
}
}
use of org.eclipse.debug.core.model.IStreamsProxy 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