[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: swing text fixes
Kaffe CVS
cvs-commits at kaffe.org
Thu Jan 6 14:33:11 PST 2005
PatchSet 5800
Date: 2005/01/06 22:24:46
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Resynced with GNU Classpath: swing text fixes
Members:
ChangeLog:1.3344->1.3345
libraries/javalib/javax/swing/text/AbstractDocument.java:1.6->1.7
libraries/javalib/javax/swing/text/GapContent.java:1.2->1.3
libraries/javalib/javax/swing/text/PlainDocument.java:1.5->1.6
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3344 kaffe/ChangeLog:1.3345
--- kaffe/ChangeLog:1.3344 Thu Jan 6 20:04:46 2005
+++ kaffe/ChangeLog Thu Jan 6 22:24:46 2005
@@ -1,3 +1,30 @@
+2005-01-06 Dalibor Topic <robilad at kaffe.org>
+
+ Resynced with GNU Classpath.
+
+ 2005-01-02 Michael Koch <konqueror at gmx.de>
+
+ * javax/swing/text/AbstractDocument.java
+ (AbstractElement.getLength): Fixed off-by-one error.
+ (AbstractElement.children): Made abstract.
+ (AbstractElement.getAllowsChildren): Likewise.
+ (AbstractElement.getElement): Likewise.
+ (AbstractElement.dumpElement): New private method.
+ (AbstractElement.dump): New method.
+ (BranchElememt.getName): Fixed implementation.
+ (BranchElememt.toString): Likewise.
+ (BranchElememt.getElement): Fixed arguments.
+ (LeafElement.getName): Fixed implementation.
+ (LeafElement.toString): Likewise.
+ * javax/swing/text/GapContent.java
+ (GapContent): Put default content into buffer.
+ * javax/swing/text/PlainDocument.java
+ (reindex): Use empty attribute sets instead of null.
+ (createDefaultRoot): Reimplemented.
+ (insertUpdate): Call super method.
+ (removeUpdate): Likewise.
+ (getParagraphElement): Implemented.
+
2005-01-06 Dalibor Topic <topic at mpiat2305>
* test/jni/Makefile.am (jniBase_LDADD): Link jitBasic with
Index: kaffe/libraries/javalib/javax/swing/text/AbstractDocument.java
diff -u kaffe/libraries/javalib/javax/swing/text/AbstractDocument.java:1.6 kaffe/libraries/javalib/javax/swing/text/AbstractDocument.java:1.7
--- kaffe/libraries/javalib/javax/swing/text/AbstractDocument.java:1.6 Sun Oct 24 13:39:22 2004
+++ kaffe/libraries/javalib/javax/swing/text/AbstractDocument.java Thu Jan 6 22:25:27 2005
@@ -38,6 +38,7 @@
package javax.swing.text;
+import java.io.PrintStream;
import java.io.Serializable;
import java.util.Collections;
import java.util.Dictionary;
@@ -187,7 +188,7 @@
public int getLength()
{
- return content.length();
+ return content.length() - 1;
}
public EventListener[] getListeners(Class listenerType)
@@ -428,15 +429,9 @@
// TreeNode implementation
- public Enumeration children()
- {
- return Collections.enumeration(tree_children);
- }
+ public abstract Enumeration children();
- public boolean getAllowsChildren()
- {
- return true;
- }
+ public abstract boolean getAllowsChildren();
public TreeNode getChildAt(int index)
{
@@ -553,10 +548,7 @@
return AbstractDocument.this;
}
- public Element getElement(int index)
- {
- return (Element) element_children.get(index);
- }
+ public abstract Element getElement(int index);
public String getName()
{
@@ -575,6 +567,42 @@
public abstract int getElementIndex(int offset);
public abstract int getStartOffset();
+
+ private void dumpElement(PrintStream stream, String indent, Element element)
+ {
+ System.out.println(indent + "<" + element.getName() +">");
+
+ if (element.isLeaf())
+ {
+ int start = element.getStartOffset();
+ int end = element.getEndOffset();
+ String text = "";
+ try
+ {
+ text = getContent().getString(start, end - start);
+ }
+ catch (BadLocationException e)
+ {
+ }
+ System.out.println(indent + " ["
+ + start + ","
+ + end + "]["
+ + text + "]");
+ }
+ else
+ {
+ for (int i = 0; i < element.getElementCount(); ++i)
+ dumpElement(stream, indent + " ", element.getElement(i));
+ }
+ }
+
+ public void dump(PrintStream stream, int indent)
+ {
+ String indentStr = "";
+ for (int i = 0; i < indent; ++i)
+ indentStr += " ";
+ dumpElement(stream, indentStr, this);
+ }
}
public class BranchElement extends AbstractElement
@@ -631,7 +659,7 @@
public String getName()
{
- return "AbstractDocument.BranchElement";
+ return ParagraphElementName;
}
public int getStartOffset()
@@ -671,7 +699,8 @@
public String toString()
{
- return getName() + ": " + "content";
+ return ("BranchElement(" + getName() + ") "
+ + getStartOffset() + "," + getEndOffset() + "\n");
}
}
@@ -782,7 +811,7 @@
return false;
}
- public Element getElement()
+ public Element getElement(int index)
{
return null;
}
@@ -804,7 +833,7 @@
public String getName()
{
- return "AbstractDocument.LeafElement";
+ return ContentElementName;
}
public int getStartOffset()
@@ -819,7 +848,8 @@
public String toString()
{
- return getName() + ": " + "content";
+ return ("LeafElement(" + getName() + ") "
+ + getStartOffset() + "," + getEndOffset() + "\n");
}
}
}
Index: kaffe/libraries/javalib/javax/swing/text/GapContent.java
diff -u kaffe/libraries/javalib/javax/swing/text/GapContent.java:1.2 kaffe/libraries/javalib/javax/swing/text/GapContent.java:1.3
--- kaffe/libraries/javalib/javax/swing/text/GapContent.java:1.2 Sun Nov 14 01:10:10 2004
+++ kaffe/libraries/javalib/javax/swing/text/GapContent.java Thu Jan 6 22:25:27 2005
@@ -35,6 +35,7 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.io.Serializable;
@@ -57,6 +58,7 @@
public GapContent(int size)
{
+ buf.append("\n");
}
public Position createPosition(final int offset) throws BadLocationException
Index: kaffe/libraries/javalib/javax/swing/text/PlainDocument.java
diff -u kaffe/libraries/javalib/javax/swing/text/PlainDocument.java:1.5 kaffe/libraries/javalib/javax/swing/text/PlainDocument.java:1.6
--- kaffe/libraries/javalib/javax/swing/text/PlainDocument.java:1.5 Sun Dec 12 01:35:15 2004
+++ kaffe/libraries/javalib/javax/swing/text/PlainDocument.java Thu Jan 6 22:25:27 2005
@@ -35,6 +35,7 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.util.ArrayList;
@@ -70,24 +71,23 @@
ArrayList elts = new ArrayList();
int j = 0;
- for (int i = str.indexOf('\n', 0); i != -1; i = str.indexOf('\n', i+1))
+ for (int i = str.indexOf('\n', 0); i != -1; i = str.indexOf('\n', i + 1))
{
- elts.add(createLeafElement(rootElement, null, j, i));
- j = i;
+ elts.add(createLeafElement(rootElement, SimpleAttributeSet.EMPTY, j, i + 1));
+ j = i + 1;
}
if (j < content.length())
- elts.add(createLeafElement(rootElement, null, j, content.length()));
+ elts.add(createLeafElement(rootElement, SimpleAttributeSet.EMPTY, j, content.length()));
lines = new Element[elts.size()];
for (int i = 0; i < elts.size(); ++i)
lines[i] = (Element) elts.get(i);
-
}
catch (BadLocationException e)
{
lines = new Element[1];
- lines[0] = createLeafElement(rootElement, null, 0, 1);
+ lines[0] = createLeafElement(rootElement, SimpleAttributeSet.EMPTY, 0, 1);
}
((BranchElement) rootElement).replace(0, rootElement.getElementCount(), lines);
@@ -95,19 +95,28 @@
protected AbstractDocument.AbstractElement createDefaultRoot()
{
- rootElement = createBranchElement(null, null);
- reindex();
- return (AbstractElement) rootElement;
+ BranchElement root =
+ (BranchElement) createBranchElement(null, SimpleAttributeSet.EMPTY);
+
+ Element[] array = new Element[1];
+ array[0] = createLeafElement(root, SimpleAttributeSet.EMPTY, 0, 1);
+ root.replace(0, 0, array);
+
+ return root;
}
- protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr)
+ protected void insertUpdate(DefaultDocumentEvent event, AttributeSet attributes)
{
reindex();
+
+ super.insertUpdate(event, attributes);
}
- protected void removeUpdate(DefaultDocumentEvent chng)
+ protected void removeUpdate(DefaultDocumentEvent event)
{
reindex();
+
+ super.removeUpdate(event);
}
public Element getDefaultRootElement()
@@ -117,6 +126,7 @@
public Element getParagraphElement(int pos)
{
- return null;
+ Element root = getDefaultRootElement();
+ return root.getElement(root.getElementIndex(pos));
}
}
More information about the kaffe
mailing list