[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: DefaultStyledDocument DocumentEvent handling and more
From: |
Anthony Balkissoon |
Subject: |
[cp-patches] FYI: DefaultStyledDocument DocumentEvent handling and more |
Date: |
Tue, 17 Jan 2006 11:56:14 -0500 |
I eagerly await the day when DefaultStyledDocument won't haunt my every
waking minute.
This patch addresses an outstanding and known issue with
DefaultStyledDocument and ElementBuffer which is that we weren't
updating the DocumentEvent associated with changes at the proper time.
We also weren't making structural changes at the proper time, and this
leads to problems within the text classes. The main part of this patch
is to allow change Edit objects to use Vectors instead of arrays to
store added and removed children, and then to properly use this
throughout the ElementBuffer class. Rather than always creating a new
Edit, we see if one exists already for the paragraph in question, and if
so, we simply augment it. We then apply all the structural changes
stored in the Edit objects all at once and at the same time as updating
the DocumentEvent.
This patch also deals with a more subtle internal problem by treating
the first ContentTag inserted separately from the other tags.
Finally, a small fix that I found for StyleContext, an
ArrayIndexOutOfBoundsException was being thrown because the bounds of a
for loop were off by one.
2006-01-17 Anthony Balkissoon <address@hidden>
* javax/swing/text/DefaultStyledDocument.java:
(pad): New debugging method.
(printElements): Likewise.
(printPendingEdits): Likewise.
(printElement): Likewise.
(Edit): Improved docs, moved this class to be an inner class of
ElementBuffer since it only applies within that scope. Changed added
and removed to be Vectors instead of arrays because we need to be able
to add to them after construction.
(ElementBuffer): Updated docs with link to article that helped in this
classes implementation.
(ElementBuffer.Edit.getRemovedElements): New method.
(ElementBuffer.Edit.getAddedElements): Likewise.
(ElementBuffer.Edit.addRemovedElement): Likewise.
(ElementBuffer.Edit.addRemovedElements): Likewise.
(ElementBuffer.Edit.addAddedElement): Likewise.
(ElementBuffer.Edit.addAddedElements): Likewise.
(ElementBuffer.Edit<init>): Improved docs, call addRemovedElements and
addAddedElements.
(ElementBuffer.getEditForParagraphAndIndex): New method.
(ElementBuffer.removeUpdate): Changed type of paragraph to
BranchElement. Corrected style of adding the edit to use the new Edit
facilities.
(ElementBuffer.changeUpdate): Changed style of adding the edit to use
the new Edit facilities.
(ElementBuffer.split): Likewise.
(ElementBuffer.insertParagraph): Likewise.
(ElementBuffer.insertContentTag): Likewise.
(ElementBuffer.insert): Push all BranchElements until the deepest one,
not just the root and the first one. Apply the structural changes to
the tree at the same time as updating the DocumentEvent.
(ElementBuffer.insertUpdate): Fixed docs. Removed the special case
handling of EndTags as the first ElementSpec. Instead have to handle
ContentTags as a special case if they are the first ElementSpec and if
not have to fracture the tree.
(ElementBuffer.createFracture): New method. May not be complete yet.
Added FIXME indicating what may remain to be done.
(ElementBuffer.insertFirstContentTag): New method.
(ElementBuffer.insertFracture): Added FIXME explaining what remains to
be done. Changed the adding of edits to use the new Edit facilities.
Removed the adding of edits for Elements that weren't in the tree prior
to the insertion.
(insertUpdate): Removed incorrect condition for setting a StartTag's
direction to JoinNextDirection.
* javax/swing/text/StyleContent.java:
(SmallAttributeSet.toString): Fixed an off-by-one error in the loop
that was causing an ArrayOutOfBoundsException.
--Tony
ElementBufferHandleEditsBetter.diff
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: DefaultStyledDocument DocumentEvent handling and more,
Anthony Balkissoon <=