@Override public void write(byte[] b) throws IOException { write(b, 0, b.length); } /*
/** * Creates and returns a new output stream which may be used to write to this console. * A console may be connected to more than one output stream at once. Clients are * responsible for closing any output streams created on this console. * <p> * Clients should avoid writing large amounts of output to this stream in the UI * thread. The console needs to process the output in the UI thread and if the client * hogs the UI thread writing output to the console, the console will not be able * to process the output. * </p> * @return a new output stream connected to this console */ public IOConsoleOutputStream newOutputStream() { IOConsoleOutputStream outputStream = new IOConsoleOutputStream(this); outputStream.setEncoding(fEncoding); synchronized(openStreams) { openStreams.add(outputStream); } return outputStream; }
/** * Writes a string to the attached console. * * @param str the string to write to the attached console. * @throws IOException if the stream is closed. */ public void write(String str) throws IOException { encodedWrite(str); }
/** * Disposes this console. */ protected void dispose() { super.dispose(); partitioner.disconnect(); //make a copy of the open streams and close them all //a copy is needed as close the streams results in a callback that //removes the streams from the openStreams collection (bug 152794) Object[] allStreams= openStreams.toArray(); for (int i = 0; i < allStreams.length; i++) { Object stream = allStreams[i]; if (stream instanceof IOConsoleInputStream) { IOConsoleInputStream is = (IOConsoleInputStream) stream; try { is.close(); } catch (IOException e) { } } else if (stream instanceof IOConsoleOutputStream) { IOConsoleOutputStream os = (IOConsoleOutputStream) stream; try { os.close(); } catch (IOException e) { } } } inputStream = null; }
/** * 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); } }
@Override public void propertyChange(PropertyChangeEvent event) { final String streamId = getStreamId(event.getProperty()); if (streamId != null) { AntUIPlugin.getStandardDisplay().asyncExec(() -> { IOConsoleOutputStream stream = getConsole().getStream(streamId); if (stream != null) { stream.setColor(getColor(streamId)); } }); } }
private synchronized void encodedWrite(String encodedString) throws IOException { if(closed) { throw new IOException("Output Stream is closed"); //$NON-NLS-1$ } String newencoding = encodedString; if (prependCR){ newencoding = "\r" + newencoding; //$NON-NLS-1$ prependCR=false; } if (newencoding.endsWith("\r")) { //$NON-NLS-1$ prependCR = true; newencoding = new String(newencoding.substring(0, newencoding.length() - 1)); } notifyParitioner(newencoding); }
private int getFontStyle() { if (type.equals(INPUT_PARTITION_TYPE)) { return inputStream.getFontStyle(); } return outputStream.getFontStyle(); }
public Color getColor() { if (type.equals(INPUT_PARTITION_TYPE)) { return inputStream.getColor(); } return outputStream.getColor(); }
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) { } } }
IOConsoleOutputStream stream = getStream(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM); if (stream != null) { stream.setActivateOnWrite(activateOnOut); IOConsoleOutputStream stream = getStream(IDebugUIConstants.ID_STANDARD_ERROR_STREAM); if (stream != null) { stream.setActivateOnWrite(activateOnErr); IOConsoleOutputStream stream = getStream(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM); if (stream != null) { stream.setColor(fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM)); IOConsoleOutputStream stream = getStream(IDebugUIConstants.ID_STANDARD_ERROR_STREAM); if (stream != null) { stream.setColor(fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_ERROR_STREAM));
protected void initializeConsoleStreams(Display display) { if(!initialized) { setCommandStream(newOutputStream()); setErrorStream(newOutputStream()); setMessageStream(newOutputStream()); // TODO convert this to use themes // install colors commandColor = new Color(display, new RGB(0, 0, 0)); messageColor = new Color(display, new RGB(0, 0, 255)); errorColor = new Color(display, new RGB(255, 0, 0)); getCommandStream().setColor(commandColor); getMessageStream().setColor(messageColor); getErrorStream().setColor(errorColor); // install font setFont(JFaceResources.getFontRegistry().get("pref_console_font")); //$NON-NLS-1$ initialized = true; } }
public synchronized void close() throws IOException { if(closed) { throw new IOException("Output Stream is closed"); //$NON-NLS-1$ } if (prependCR) { // force writing of last /r prependCR = false; notifyParitioner("\r"); //$NON-NLS-1$ } console.streamClosed(this); closed = true; partitioner = null; }
/** * Returns the font of the input stream if the type of the partition * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output * stream font * * @return the font of one of the backing streams */ private int getFontStyle() { if (type.equals(INPUT_PARTITION_TYPE)) { return inputStream.getFontStyle(); } return outputStream.getFontStyle(); }
/** * Returns the colour of the input stream if the type of the partition * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output * stream colour * * @return the colour of one of the backing streams */ public Color getColor() { if (type.equals(INPUT_PARTITION_TYPE)) { return inputStream.getColor(); } return outputStream.getColor(); }
public void write(byte[] b) throws IOException { write(b, 0, b.length); } /*
private void notifyParitioner(String encodedString) throws IOException { try { partitioner.streamAppended(this, encodedString); if (activateOnWrite) { console.activate(); } else { ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(console); } } catch (IOException e) { if (!closed) { close(); } throw e; } }
/** * Creates and returns a new output stream which may be used to write to this console. * A console may be connected to more than one output stream at once. Clients are * responsible for closing any output streams created on this console. * <p> * Clients should avoid writing large amounts of output to this stream in the UI * thread. The console needs to process the output in the UI thread and if the client * hogs the UI thread writing output to the console, the console will not be able * to process the output. * </p> * @return a new output stream connected to this console */ public IOConsoleOutputStream newOutputStream() { IOConsoleOutputStream outputStream = new IOConsoleOutputStream(this); outputStream.setEncoding(fEncoding); synchronized(openStreams) { openStreams.add(outputStream); } return outputStream; }
private void encodedWrite(String encodedString) throws IOException { if(closed) { throw new IOException("Output Stream is closed"); //$NON-NLS-1$ } if (prependCR){ encodedString="\r"+encodedString; //$NON-NLS-1$ prependCR=false; } if (encodedString.endsWith("\r")) { //$NON-NLS-1$ prependCR = true; encodedString = new String(encodedString.substring(0, encodedString.length()-1)); } notifyParitioner(encodedString); }
@Override public void write(byte[] b, int off, int len) throws IOException { if (fNeedsEncoding) { encodedWrite(new String(b, off, len, fEncoding)); } else { encodedWrite(new String(b, off, len)); } } /*