@Override public void write(final char[] cbuf, final int off, final int len) throws IOException { if (thread == null) { return; } if (thread.isInterrupted()) { content = null; thread = null; throw new InterruptedIOException(); } try { content.insertChars(content.length() - 1, cbuf, off, len); if (content.length() > nextMessageThreshold) { nextMessageThreshold += nextMessageIncrement; final String message = String.format("Rendering: %,9d chars", content.length()); SwingUtilities.invokeLater(() -> { if (jtextArea.getDocument() == originalDocument) { jtextArea.setText(message); } }); } } catch (BadLocationException e1) { thread.interrupt(); throw new IOException("Bad location in TextAreaWriter::write", e1); } }
@Override public void write(final char[] cbuf, final int off, final int len) throws IOException { if (thread == null) { return; } if (thread.isInterrupted()) { content = null; thread = null; throw new InterruptedIOException(); } try { content.insertChars(content.length() - 1, cbuf, off, len); if (content.length() > nextMessageThreshold) { nextMessageThreshold += nextMessageIncrement; final String message = String.format("Rendering: %,9d chars", content.length()); SwingUtilities.invokeLater(() -> { if (jtextArea.getDocument() == originalDocument) { jtextArea.setText(message); } }); } } catch (BadLocationException e1) { thread.interrupt(); throw new IOException("Bad location in TextAreaWriter::write", e1); } }
public void insertChars(int position, final char cbuf[], final int off, final int len) throws BadLocationException { if (position > length() || position < 0) { throw new BadLocationException("Invalid insert", length()); } if (off == 0) { replace(position, 0, cbuf, len); } else { char tmp[] = new char[len]; System.arraycopy(cbuf, off, tmp, 0, len); replace(position, 0, tmp, len); } } }
/** * Constructs a plain text document. A default root element is created, * and the tab size set to 8. Text already in c is processed as if it had been inserted - i.e. elements are * created for each line. * * @param c the container for the content */ CharInsertableDocument(CharInsertableGapContent c) { super(c); DefaultDocumentEvent event = new DefaultDocumentEvent(0, c.length(), DocumentEvent.EventType.INSERT); insertUpdate(event, null); event.end(); fireInsertUpdate(event); } }
/** * Constructs a plain text document. A default root element is created, * and the tab size set to 8. Text already in c is processed as if it had been inserted - i.e. elements are * created for each line. * * @param c the container for the content */ CharInsertableDocument(CharInsertableGapContent c) { super(c); DefaultDocumentEvent event = new DefaultDocumentEvent(0, c.length(), DocumentEvent.EventType.INSERT); insertUpdate(event, null); event.end(); fireInsertUpdate(event); } }
public void insertChars(int position, final char cbuf[], final int off, final int len) throws BadLocationException { if (position > length() || position < 0) { throw new BadLocationException("Invalid insert", length()); } if (off == 0) { replace(position, 0, cbuf, len); } else { char tmp[] = new char[len]; System.arraycopy(cbuf, off, tmp, 0, len); replace(position, 0, tmp, len); } } }