[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Patch: PlainDocument improvements and added functionality
From: |
Anthony Balkissoon |
Subject: |
[cp-patches] Patch: PlainDocument improvements and added functionality |
Date: |
Tue, 15 Nov 2005 14:57:24 -0500 |
This patch implements ElementChange interface behaviour for
PlainDocument. When entire lines are inserted or removed the
DocumentEvent must have an ElementChange attached to it describing the
new lines or the removed lines.
Roman correctly noticed that this behaviour should not be in
AbstractDocument so he removed the code from insertString. This patch
further removes it from AbstractDocument.remove() and puts it where it
belongs, in the insertUpdate() and removeUpdate() methods of the
Document implementation.
I removed the package private method reindex and moved most of this code
directly into insertUpdate. However, instead of reindexing the entire
Document we only look for new lines in the newly inserted text. This is
necessary to get the correct ElementEdit and also represents a
performance improvement. Before this, entering each character caused us
to reindex the entire document (this is basically searching through and
finding all the new lines in the whole document). Now after a character
insertion we only have to check that character to see if it's a newline.
This should be an important difference in a large document. Note
however that I've only implemented this for PlainView, there are other
text View classes that need similar improvements.
2005-11-14 Anthony Balkissoon <address@hidden>
* javax/swing/text/AbstractDocument.java:
(remove): Do not set up an ElementEdit here, this is done in the
Document implementation's removeUpdate method.
* javax/swing/text/PlainDocument.java:
(insertUpdate): Do not call reindex, instead, reindex the lines here
directly but only starting from the offset of the newly inserted text.
Also, if entire lines have been added or removed, set up an ElementEdit
and add it to the DocumentEvent. Chain BadLocationException to an
AssertionError and throw it in the unexpected case.
(removeUpdate): If entire lines have been added or removed, set up an
ElementEdit and add it to the DocumentEvent. Chain
BadLocationException to an AssertionError and throw it in the
unexpected case.
(reindex): Removed unnecessary method.
PlainDocumentElementChange.diff
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] Patch: PlainDocument improvements and added functionality,
Anthony Balkissoon <=