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) {
anyOutput = true;
notifyOutput(progressCallback, text);
}
});
process.getStreamsProxy().getErrorStreamMonitor()
.addListener(new IStreamListener() {
@Override
public void streamAppended(final String text,
final IStreamMonitor mon) {
anyError = true;
notifyError(progressCallback, text);
}
});
boolean done = false;
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 (!anyOutput) {
final String text = process.getStreamsProxy().getOutputStreamMonitor()
.getContents();
notifyOutput(progressCallback, text);
}
if (!anyError) {
final String text = process.getStreamsProxy().getErrorStreamMonitor()
.getContents();
notifyError(progressCallback, text);
}
if (canceled) {
process.terminate();
}
return result;
} catch (final CoreException e) {
ErlLogger.error(e);
return null;