/* * Created on Jul 16, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package CDBuilder.console; import org.eclipse.jface.text.AbstractDocument; import org.eclipse.jface.text.DefaultLineTracker; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.ITextStore; import org.eclipse.jface.text.TextViewer; /** * @author ssim * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class ConsoleDocument extends AbstractDocument { private static ConsoleDocument cdos; private TextViewer tv; private ConsoleDocument(TextViewer tv) { this.tv = tv; setTextStore(newTextStore()); setLineTracker(new DefaultLineTracker()); completeInitialization(); } public static ConsoleDocument getCDOS( TextViewer tv) { if(cdos == null) { Document doc = new Document(); cdos = new ConsoleDocument(tv); } return cdos; } public static ConsoleDocument getCDOS() { //if(cdos == null) { // Document doc = new Document(); // cdos = new ConsoleDocument(); //} return cdos; } public void set(String text) { if ( getNumberOfLines() > 50) sizeTrunacate(); super.set(get() + text) ; tv.setTopIndex(tv.getDocument().getNumberOfLines()); } public void clear() { super.set(""); } protected ITextStore newTextStore() { return new ConsoleOutputTextStore(2500); } private void sizeTrunacate() { try { String data = get(2,getLength()); super.set(data); } catch (Exception E) { } } }