summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Balkissoon <abalkiss@redhat.com>2006-01-09 18:57:23 +0000
committerAnthony Balkissoon <abalkiss@redhat.com>2006-01-09 18:57:23 +0000
commit546dcbece4c4f9f5e5efdd00ac5e7d32de03b945 (patch)
tree57fbc8f8d99e1e8123a2135eb91c1ceef0c69e8a
parent5a6e198e29bad075f4b83d92a28f89fd2d24757d (diff)
downloadclasspath-546dcbece4c4f9f5e5efdd00ac5e7d32de03b945.tar.gz
2006-01-09 Anthony Balkissoon <abalkiss@redhat.com>generics-merge-20060109
* javax/swing/text/DefaultStyledDocument.java: (insertUpdate): Removed call to checkForInsertAfterNewline and instead inlined this method because it needs to change the value of the finalStartTag and finalStartDirection variables. (checkForInsertAfterNewline): Removed this method. (handleInsertAfterNewline): Added case for making the start tag's direction JoinNextDirection.
-rw-r--r--ChangeLog10
-rw-r--r--javax/swing/text/DefaultStyledDocument.java81
2 files changed, 44 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index bd0a6c934..8fc4bbff3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-01-09 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/DefaultStyledDocument.java:
+ (insertUpdate): Removed call to checkForInsertAfterNewline and instead
+ inlined this method because it needs to change the value of the
+ finalStartTag and finalStartDirection variables.
+ (checkForInsertAfterNewline): Removed this method.
+ (handleInsertAfterNewline): Added case for making the start tag's
+ direction JoinNextDirection.
+
2006-01-09 Lillian Angel <langel@redhat.com>
* javax/swing/plaf/basic/BasicTreeUI.java:
diff --git a/javax/swing/text/DefaultStyledDocument.java b/javax/swing/text/DefaultStyledDocument.java
index a3d0ba7a8..bc1a2d663 100644
--- a/javax/swing/text/DefaultStyledDocument.java
+++ b/javax/swing/text/DefaultStyledDocument.java
@@ -1596,9 +1596,36 @@ public class DefaultStyledDocument extends AbstractDocument
int segmentEnd = txt.offset + txt.count;
// Check to see if we're inserting immediately after a newline.
- checkForInsertAfterNewline(offset, endOffset, prevParagraph, paragraph,
- paragraphAttributes, prevCharWasNewline,
- finalStartTag, finalStartDirection, specs);
+ if (offset > 0)
+ {
+ try
+ {
+ String s = getText(offset - 1, 1);
+ if (s.equals("\n"))
+ {
+ finalStartDirection =
+ handleInsertAfterNewline(specs, offset, endOffset,
+ prevParagraph,
+ paragraph,
+ paragraphAttributes);
+
+ prevCharWasNewline = true;
+ // Find the final start tag from the ones just created.
+ for (int i = 0; i < specs.size(); i++)
+ if (((ElementSpec) specs.get(i)).getType()
+ == ElementSpec.StartTagType)
+ finalStartTag = (ElementSpec)specs.get(i);
+ }
+ }
+ catch (BadLocationException ble)
+ {
+ // This shouldn't happen.
+ AssertionError ae = new AssertionError();
+ ae.initCause(ble);
+ throw ae;
+ }
+ }
+
for (int i = txt.offset; i < segmentEnd; ++i)
{
@@ -1663,49 +1690,6 @@ public class DefaultStyledDocument extends AbstractDocument
}
/**
- * A helper method that checks to see if insertUpdate was called when text
- * was inserted immediately after a newline, and calls
- * handleInsertAfterNewline if that is the case.
- */
- void checkForInsertAfterNewline(int offset, int endOffset,
- Element prevParagraph, Element paragraph,
- AttributeSet paragraphAttributes,
- boolean prevCharWasNewline,
- ElementSpec finalStartTag,
- short finalStartDirection, Vector specs)
- {
- if (offset > 0)
- {
- try
- {
- String s = getText(offset - 1, 1);
- if (s.equals("\n"))
- {
- finalStartDirection =
- handleInsertAfterNewline(specs, offset, endOffset,
- prevParagraph,
- paragraph,
- paragraphAttributes);
-
- prevCharWasNewline = true;
- // Find the final start tag from the ones just created.
- for (int i = 0; i < specs.size(); i++)
- if (((ElementSpec) specs.get(i)).getType()
- == ElementSpec.StartTagType)
- finalStartTag = (ElementSpec)specs.get(i);
- }
- }
- catch (BadLocationException ble)
- {
- // This shouldn't happen.
- AssertionError ae = new AssertionError();
- ae.initCause(ble);
- throw ae;
- }
- }
- }
-
- /**
* A helper method to set up the ElementSpec buffer for the special
* case of an insertion occurring immediately after a newline.
* @param specs the ElementSpec buffer to initialize.
@@ -1720,7 +1704,10 @@ public class DefaultStyledDocument extends AbstractDocument
specs.add(new ElementSpec(a, ElementSpec.StartTagType));
if (prevParagraph.getEndOffset() != endOffset)
return ElementSpec.JoinFractureDirection;
-
+ // If there is an Element after this one, use JoinNextDirection.
+ Element parent = paragraph.getParentElement();
+ if (parent.getElementCount() > parent.getElementIndex(offset) + 1)
+ return ElementSpec.JoinNextDirection;
}
else
{