The spec for javax.swing.text.View.forwardUpdate says that newly added
child views should not be notified of updates (makes sense to me). This
patch implements this.
2006-02-07 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/text/View.java
(forwardUpdate): Don't notify newly added child views as
specified.
/Roman
Index: javax/swing/text/View.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/View.java,v
retrieving revision 1.25
diff -u -r1.25 View.java
--- javax/swing/text/View.java 5 Jan 2006 20:15:34 -0000 1.25
+++ javax/swing/text/View.java 7 Feb 2006 13:53:43 -0000
@@ -40,7 +40,6 @@
import java.awt.Container;
import java.awt.Graphics;
-import java.awt.Rectangle;
import java.awt.Shape;
import javax.swing.SwingConstants;
@@ -392,6 +391,10 @@
* of the change to the model. This calles [EMAIL PROTECTED] #forwardUpdateToView}
* for each View that must be forwarded to.
*
+ * If <code>ec</code> is not <code>null</code> (this means there have been
+ * structural changes to the element that this view is responsible for) this
+ * method should recognize this and don't notify newly added child views.
+ *
* @param ec the ElementChange describing the element changes (may be
* <code>null</code> if there were no changes)
* @param ev the DocumentEvent describing the changes to the model
@@ -404,8 +407,23 @@
DocumentEvent ev, Shape shape, ViewFactory vf)
{
int count = getViewCount();
+ int index = -1;
+ int addLength = -1;
+ if (ec != null)
+ {
+ index = ec.getIndex();
+ addLength = ec.getChildrenAdded().length;
+ }
+
for (int i = 0; i < count; i++)
{
+ // Skip newly added child views.
+ if (index >= 0 && index == i && addLength > 0)
+ {
+ // We add addLengt - 1 here because the for loop does add 1 more.
+ i += addLength - 1;
+ continue;
+ }
View child = getView(i);
forwardUpdateToView(child, ev, shape, vf);
}