/** * Connects the given stream monitor to a new output stream with the given identifier. * * @param streamMonitor stream monitor * @param streamIdentifier stream identifier * @param activateOnWrite whether the stream should displayed when written to */ @SuppressWarnings("resource") private void connect(IStreamMonitor streamMonitor, String streamIdentifier, boolean activateOnWrite) { IOConsoleOutputStream stream = null; if (fAllocateConsole) { stream = newOutputStream(); Color color = fColorProvider.getColor(streamIdentifier); stream.setColor(color); stream.setActivateOnWrite(activateOnWrite); } synchronized (streamMonitor) { StreamListener listener = new StreamListener(streamIdentifier, streamMonitor, stream); fStreamListeners.add(listener); } }
/** * cleanup method to close all of the open stream to this console */ private synchronized void closeStreams() { if (fStreamsClosed) { return; } for (StreamListener listener : fStreamListeners) { listener.closeStream(); } if (fFileOutputStream != null) { synchronized (fFileOutputStream) { try { fFileOutputStream.flush(); fFileOutputStream.close(); } catch (IOException e) { } } } try { fInput.close(); } catch (IOException e) { } fStreamsClosed = true; }
public void closeStream() { if (fStreamMonitor == null) { return; } synchronized (fStreamMonitor) { fStreamMonitor.removeListener(this); if (!fFlushed) { String contents = fStreamMonitor.getContents(); streamAppended(contents, fStreamMonitor); } fListenerRemoved = true; try { if (fStream != null) { fStream.close(); } } catch (IOException e) { } } }
/** * disposes the listeners for each of the stream associated with this * console */ private synchronized void disposeStreams() { for (StreamListener listener : fStreamListeners) { listener.dispose(); } fFileOutputStream = null; fInput = null; }
public void dispose() { if (!fListenerRemoved) { closeStream(); } fStream = null; fStreamMonitor = null; fStreamId = null; } }
public StreamListener(String streamIdentifier, IStreamMonitor monitor, IOConsoleOutputStream stream) { this.fStreamId = streamIdentifier; this.fStreamMonitor = monitor; this.fStream = stream; fStreamMonitor.addListener(this); //fix to bug 121454. Ensure that output to fast processes is processed. streamAppended(null, monitor); }