Added the addEdit calls in insertFracture. Now, this correctly updates
the document structure when a fracture is inserted.
2006-01-11 Lillian Angel <[EMAIL PROTECTED]>
* javax/swing/text/DefaultStyledDocument.java
(insertFracture): Added calls to addEdit for each time a
structure is changed. addEdit is called on the newBranch,
previous, and parent structures.
Index: javax/swing/text/DefaultStyledDocument.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.31
diff -u -r1.31 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java 11 Jan 2006 20:36:57 -0000 1.31
+++ javax/swing/text/DefaultStyledDocument.java 11 Jan 2006 20:46:43 -0000
@@ -997,21 +997,25 @@
Element[] newLeaves = new Element[numReplaced];
newLeaves[0] = firstLeafInNewBranch;
for (int i = 1; i < numReplaced; i++)
- {
- newLeaves[i] = previous.getElement(previousIndex + i);
- }
+ newLeaves[i] = previous.getElement(previousIndex + i);
newBranch.replace(0, 0, newLeaves);
-
+ addEdit(newBranch, 0, null, newLeaves);
+
// Now we remove the children after the offset from the previous
// paragraph. (Step 3).
- previous.replace(previousIndex,
- previous.getElementCount() - previousIndex,
- new Element[] { newPreviousLeaf });
+ int removeSize = previous.getElementCount() - previousIndex;
+ Element[] add = new Element[] { newPreviousLeaf };
+ Element[] remove = new Element[removeSize];
+ for (int j = 0; j < removeSize; j++)
+ remove[j] = previous.getElement(previousIndex + j);
+ previous.replace(previousIndex, removeIndex, add);
+ addEdit(previous, previousIndex, remove, add);
// Finally we add the new paragraph to the parent. (Step 5).
- parent.replace(parentIndex + 1, 0, new Element[] { newBranch });
-
- // FIXME: Add the edits to the DocumentEvent via the addEdit method.
+ Element[] nb = new Element[] { newBranch };
+ int index = parentIndex + 1;
+ parent.replace(index, 0, nb);
+ addEdit(parent, index, null, nb);
}
/**
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches