/**
*
*/
package xvrengine.launching;
import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.xvr.console.saros.SarosConsole;
import org.xvr.xvrengine.saros.SarosSessionListener;
import de.fu_berlin.inf.dpp.activities.serializable.XVRAA;
import de.fu_berlin.inf.dpp.activities.serializable.XVRAA.XVRActionType;
/**
* @author raffaello
*
*/
public class XVRConsoleStreamer implements IStreamListener {
@SuppressWarnings("unused")
private SarosConsole console;
private IStreamMonitor monitor;
/**
* @param name
*/
public XVRConsoleStreamer() {
this.console = new SarosConsole();
this.monitor = null;
}
// /* (non-Javadoc)
// * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
// */
// @Override
// protected IStatus run(IProgressMonitor monitor) {
//
// BufferedInputStream stream = new BufferedInputStream(sp.getOutputStreamMonitor());
// byte[] buffer = new byte[1024];
// int read = 0;
// try {
// while((read = stream.read(buffer, 0, 1024)) != -1)
// this.console.print(new String(buffer));
//
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// return Status.OK_STATUS;
// }
public void setStream(IStreamMonitor monitor){
this.monitor = monitor;
this.monitor.addListener(this);
}
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
XVRAA a = new XVRAA(XVRActionType.CONSOLE_MESSAGE, text);
SarosSessionListener.getInstance().send(a);
}
public void removeStreamMonitor() {
this.monitor.removeListener(this);
this.monitor = null;
}
}