1 11 package org.eclipse.ant.internal.ui.launchConfigurations; 12 13 import org.eclipse.core.runtime.ListenerList; 14 import org.eclipse.debug.core.IStreamListener; 15 import org.eclipse.debug.core.model.IFlushableStreamMonitor; 16 17 20 public class AntStreamMonitor implements IFlushableStreamMonitor { 21 22 private StringBuffer fContents = new StringBuffer (); 23 private ListenerList fListeners = new ListenerList(1); 24 private boolean fBuffered = true; 25 26 29 public void addListener(IStreamListener listener) { 30 fListeners.add(listener); 31 } 32 33 36 public String getContents() { 37 return fContents.toString(); 38 } 39 40 43 public void removeListener(IStreamListener listener) { 44 fListeners.remove(listener); 45 } 46 47 52 public void append(String message) { 53 if (isBuffered()) { 54 fContents.append(message); 55 } 56 Object [] listeners = fListeners.getListeners(); 57 for (int i = 0; i < listeners.length; i++) { 58 IStreamListener listener = (IStreamListener)listeners[i]; 59 listener.streamAppended(message, this); 60 } 61 } 62 65 public void flushContents() { 66 fContents.setLength(0); 67 } 68 69 72 public boolean isBuffered() { 73 return fBuffered; 74 } 75 76 79 public void setBuffered(boolean buffer) { 80 fBuffered = buffer; 81 } 82 } 83 84 | Popular Tags |