This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[GUI] Patch: javax.swing.text - reformatted
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Fri, 11 Jun 2004 10:08:01 +0200
- Subject: [GUI] Patch: javax.swing.text - reformatted
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I just commited the attached patch to reformat some classes in
javax.swing.text to allow easier integration of following patches.
Michael
2004-06-11 Michael Koch <konqueror@gmx.de>
* javax/swing/text/AbstractDocument.java,
javax/swing/text/Document.java,
javax/swing/text/GapContent.java,
javax/swing/text/JTextComponent.java,
javax/swing/text/PlainDocument.java:
Reformatted.
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAyWhhWSOgCCdjSDsRAgrmAKCHcnFuAPOZ9jJhe2GABBMkCA3DoACfS3qg
rCYSyyOFmBrGISoY3UgHOs8=
=03ST
-----END PGP SIGNATURE-----
Index: javax/swing/text/AbstractDocument.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/text/AbstractDocument.java,v
retrieving revision 1.3.8.1
diff -u -b -B -r1.3.8.1 AbstractDocument.java
--- javax/swing/text/AbstractDocument.java 9 Jun 2004 08:40:11 -0000 1.3.8.1
+++ javax/swing/text/AbstractDocument.java 11 Jun 2004 08:04:26 -0000
@@ -49,7 +48,9 @@
import javax.swing.tree.TreeNode;
import javax.swing.undo.UndoableEdit;
-public abstract class AbstractDocument implements Document
+
+public abstract class AbstractDocument
+ implements Document
{
Vector doc_list = new Vector();
Vector undo_list = new Vector();
@@ -59,9 +61,11 @@
public abstract Element getDefaultRootElement();
// some inner classes sun says I should have:
- abstract class AbstractElement implements Element, TreeNode
+ abstract class AbstractElement
+ implements Element, TreeNode
{
- int count, offset;
+ int count;
+ int offset;
AttributeSet attr;
Vector elts = new Vector();
String name;
@@ -70,25 +74,74 @@
TreeNode tree_parent;
public AbstractElement(Element p, AttributeSet s)
- { parent = p; attr = s; }
+ {
+ parent = p;
+ attr = s;
+ }
+
+ public Enumeration children()
+ {
+ return kids.elements();
+ }
+
+ public boolean getAllowsChildren()
+ {
+ return true;
+ }
+
+ public TreeNode getChildAt(int index)
+ {
+ return (TreeNode) kids.elementAt(index);
+ }
+
+ public int getChildCount()
+ {
+ return kids.size();
+ }
+
+ public int getIndex(TreeNode node)
+ {
+ return kids.indexOf(node);
+ }
+
+ public TreeNode getParent()
+ {
+ return tree_parent;
+ }
+
+ public AttributeSet getAttributes()
+ {
+ return attr;
+ }
+
+ public Document getDocument()
+ {
+ return AbstractDocument.this;
+ }
- public Enumeration children() { return kids.elements(); }
- public boolean getAllowsChildren() { return true; }
- public TreeNode getChildAt(int index) { return (TreeNode) kids.elementAt(index); }
- public int getChildCount() { return kids.size(); }
- public int getIndex(TreeNode node) { return kids.indexOf(node); }
- public TreeNode getParent() { return tree_parent; }
-
- public AttributeSet getAttributes() { return attr; }
- public Document getDocument() { return AbstractDocument.this; }
- public Element getElement(int index) { return (Element)elts.elementAt(index); }
- public String getName() { return name; }
- public Element getParentElement() { return parent; }
+ public Element getElement(int index)
+ {
+ return (Element) elts.elementAt(index);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Element getParentElement()
+ {
+ return parent;
+ }
public abstract boolean isLeaf();
+
public abstract int getEndOffset();
+
public abstract int getElementCount();
+
public abstract int getElementIndex(int offset);
+
public abstract int getStartOffset();
}
@@ -96,17 +149,37 @@
{
}
-
class BranchElement extends AbstractElement
{
public BranchElement(Element e, AttributeSet a, int s, int end)
- { super(e, a); }
+ {
+ super(e, a);
+ }
- public boolean isLeaf() { return false; }
- public int getEndOffset() { return 0; }
- public int getElementCount() { return 0; }
- public int getElementIndex(int offset) { return 0; }
- public int getStartOffset() { return 0; }
+ public boolean isLeaf()
+ {
+ return false;
+ }
+
+ public int getEndOffset()
+ {
+ return 0;
+ }
+
+ public int getElementCount()
+ {
+ return 0;
+ }
+
+ public int getElementIndex(int offset)
+ {
+ return 0;
+ }
+
+ public int getStartOffset()
+ {
+ return 0;
+ }
}
interface Content
@@ -112,10 +185,16 @@
interface Content
{
Position createPosition(int offset) throws BadLocationException;
+
int length();
- UndoableEdit insertString(int where, String str) throws BadLocationException;
+
+ UndoableEdit insertString(int where, String str)
+ throws BadLocationException;
+
UndoableEdit remove(int where, int nitems) throws BadLocationException;
+
String getString(int where, int len) throws BadLocationException;
+
void getChars(int where, int len, Segment txt) throws BadLocationException;
}
@@ -119,14 +198,36 @@
void getChars(int where, int len, Segment txt) throws BadLocationException;
}
- class DefaultDocumentEvent implements DocumentEvent
+ class DefaultDocumentEvent
+ implements DocumentEvent
+ {
+ public int len;
+ public int off;
+
+ public Document getDocument()
+ {
+ return AbstractDocument.this;
+ }
+
+ public int getLength()
{
- public int len, off;
- public Document getDocument() { return AbstractDocument.this; }
- public int getLength() { return len; }
- public int getOffset() { return off; }
- public DocumentEvent.EventType getType() { return null; }
- public DocumentEvent.ElementChange getChange(Element elem) { return null; }
+ return len;
+ }
+
+ public int getOffset()
+ {
+ return off;
+ }
+
+ public DocumentEvent.EventType getType()
+ {
+ return null;
+ }
+
+ public DocumentEvent.ElementChange getChange(Element elem)
+ {
+ return null;
+ }
}
static class ElementEdit
@@ -136,15 +237,35 @@
class LeafElement extends AbstractElement
{
LeafElement(Element e, AttributeSet a, int s, int end)
- { super(e, a); }
+ {
+ super(e, a);
+ }
+
+ public boolean isLeaf()
+ {
+ return true;
+ }
+
+ public int getEndOffset()
+ {
+ return 0;
+ }
- public boolean isLeaf() { return true; }
- public int getEndOffset() { return 0; }
- public int getElementCount() { return 0; }
- public int getElementIndex(int offset) { return 0; }
- public int getStartOffset() { return 0; }
+ public int getElementCount()
+ {
+ return 0;
+ }
+
+ public int getElementIndex(int offset)
+ {
+ return 0;
}
+ public int getStartOffset()
+ {
+ return 0;
+ }
+ }
Content content;
@@ -158,8 +279,6 @@
* the meat:
*
***********/
-
-
public void addDocumentListener(DocumentListener listener)
{
doc_list.addElement(listener);
@@ -175,9 +294,10 @@
return new BranchElement(parent, a, 0, 0);
}
- protected Element createLeafElement(Element parent, AttributeSet a, int p0, int p1)
+ protected Element createLeafElement(Element parent, AttributeSet a, int p0,
+ int p1)
{
- return new LeafElement(parent, a, p0, p1-p0);
+ return new LeafElement(parent, a, p0, p1 - p0);
}
public Position createPosition(int offs)
@@ -270,10 +390,14 @@
public String getText(int offset, int length)
{
- try {
+ try
+ {
return content.getString(offset, length);
- } catch (Exception e) {
- System.out.println("Hmmm, fail to getText: " + offset + " -> " + length);
+ }
+ catch (Exception e)
+ {
+ System.out.println("Hmmm, fail to getText: " + offset + " -> "
+ + length);
return null;
}
}
@@ -293,7 +417,7 @@
txt.offset = offset;
txt.count = length;
- char chars[] = new char[ a.length() ];
+ char[] chars = new char[a.length()];
a.getChars(0, a.length(), chars, 0);
@@ -302,10 +426,13 @@
public void insertString(int offs, String str, AttributeSet a)
{
- try {
+ try
+ {
content.insertString(offs, str);
- } catch (Exception e) {
- System.err.println("FAILED TO INSERT-STRING: " + e + ", at:"+offs);
+ }
+ catch (Exception e)
+ {
+ System.err.println("FAILED TO INSERT-STRING: " + e + ", at:" + offs);
}
}
Index: javax/swing/text/Document.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/text/Document.java,v
retrieving revision 1.4
diff -u -b -B -r1.4 Document.java
--- javax/swing/text/Document.java 10 Jan 2004 21:07:44 -0000 1.4
+++ javax/swing/text/Document.java 11 Jun 2004 08:04:26 -0000
@@ -43,7 +44,6 @@
public interface Document
{
String StreamDescriptionProperty = "stream";
-
String TitleProperty = "text";
void addDocumentListener(DocumentListener listener);
Index: javax/swing/text/GapContent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/text/GapContent.java,v
retrieving revision 1.2
diff -u -b -B -r1.2 GapContent.java
--- javax/swing/text/GapContent.java 10 Jan 2004 21:07:44 -0000 1.2
+++ javax/swing/text/GapContent.java 11 Jun 2004 08:04:26 -0000
@@ -37,12 +37,14 @@
package javax.swing.text;
+
// too lazy to make a real gapcontent.
// lets just use a stringbuffer instead.
-
import javax.swing.undo.UndoableEdit;
-public class GapContent implements AbstractDocument.Content
+
+public class GapContent
+ implements AbstractDocument.Content
{
StringBuffer buf = new StringBuffer();
@@ -72,13 +75,15 @@
return buf.length();
}
- public UndoableEdit insertString(int where, String str) throws BadLocationException
+ public UndoableEdit insertString(int where, String str)
+ throws BadLocationException
{
buf.insert(where, str);
return null;
}
- public UndoableEdit remove(int where, int nitems) throws BadLocationException
+ public UndoableEdit remove(int where, int nitems)
+ throws BadLocationException
{
buf.delete(where, where + nitems);
return null;
@@ -89,13 +94,12 @@
return buf.toString();
}
- public void getChars(int where, int len, Segment txt) throws BadLocationException
+ public void getChars(int where, int len, Segment txt)
+ throws BadLocationException
{
txt.array = new char[len];
- System.arraycopy(buf.toString().toCharArray(), where,
- txt.array, 0,
- len);
+ System.arraycopy(buf.toString().toCharArray(), where, txt.array, 0, len);
txt.count = len;
txt.offset = 0;
Index: javax/swing/text/JTextComponent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/text/JTextComponent.java,v
retrieving revision 1.4.2.3
diff -u -b -B -r1.4.2.3 JTextComponent.java
--- javax/swing/text/JTextComponent.java 10 Jun 2004 07:28:16 -0000 1.4.2.3
+++ javax/swing/text/JTextComponent.java 11 Jun 2004 08:04:26 -0000
@@ -42,8 +42,8 @@
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Insets;
-import java.awt.Rectangle;
import java.awt.Point;
+import java.awt.Rectangle;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
@@ -92,7 +93,8 @@
* getCaretPosition
* @returns int
*/
- public int getCaretPosition() {
+ public int getCaretPosition()
+ {
return 0; // TODO
} // getCaretPosition()
@@ -100,7 +102,8 @@
* getSelectedText
* @returns String
*/
- public String getSelectedText() {
+ public String getSelectedText()
+ {
return null; // TODO
} // getSelectedText()
@@ -108,7 +111,8 @@
* getSelectionStart
* @returns int
*/
- public int getSelectionStart() {
+ public int getSelectionStart()
+ {
return 0; // TODO
} // getSelectionStart()
@@ -116,7 +120,8 @@
* getSelectionEnd
* @returns int
*/
- public int getSelectionEnd() {
+ public int getSelectionEnd()
+ {
return 0; // TODO
} // getSelectionEnd()
@@ -124,7 +129,8 @@
* caretUpdate
* @param value0 TODO
*/
- public void caretUpdate(CaretEvent value0) {
+ public void caretUpdate(CaretEvent value0)
+ {
// TODO
} // caretUpdate()
@@ -132,7 +138,8 @@
* getAccessibleStateSet
* @returns AccessibleStateSet
*/
- public AccessibleStateSet getAccessibleStateSet() {
+ public AccessibleStateSet getAccessibleStateSet()
+ {
return null; // TODO
} // getAccessibleStateSet()
@@ -140,7 +147,8 @@
* getAccessibleRole
* @returns AccessibleRole
*/
- public AccessibleRole getAccessibleRole() {
+ public AccessibleRole getAccessibleRole()
+ {
return null; // TODO
} // getAccessibleRole()
@@ -148,7 +156,8 @@
* getAccessibleText
* @returns AccessibleText
*/
- public AccessibleText getAccessibleText() {
+ public AccessibleText getAccessibleText()
+ {
return null; // TODO
} // getAccessibleText()
@@ -156,7 +165,8 @@
* insertUpdate
* @param value0 TODO
*/
- public void insertUpdate(DocumentEvent value0) {
+ public void insertUpdate(DocumentEvent value0)
+ {
// TODO
} // insertUpdate()
@@ -164,7 +174,8 @@
* removeUpdate
* @param value0 TODO
*/
- public void removeUpdate(DocumentEvent value0) {
+ public void removeUpdate(DocumentEvent value0)
+ {
// TODO
} // removeUpdate()
@@ -172,7 +183,8 @@
* changedUpdate
* @param value0 TODO
*/
- public void changedUpdate(DocumentEvent value0) {
+ public void changedUpdate(DocumentEvent value0)
+ {
// TODO
} // changedUpdate()
@@ -181,7 +193,8 @@
* @param value0 TODO
* @returns int
*/
- public int getIndexAtPoint(Point value0) {
+ public int getIndexAtPoint(Point value0)
+ {
return 0; // TODO
} // getIndexAtPoint()
@@ -189,7 +202,8 @@
* getRootEditorRect
* @returns Rectangle
*/
- Rectangle getRootEditorRect() {
+ Rectangle getRootEditorRect()
+ {
return null; // TODO
} // getRootEditorRect()
@@ -198,7 +212,8 @@
* @param value0 TODO
* @returns Rectangle
*/
- public Rectangle getCharacterBounds(int value0) {
+ public Rectangle getCharacterBounds(int value0)
+ {
return null; // TODO
} // getCharacterBounds()
@@ -206,7 +221,8 @@
* getCharCount
* @returns int
*/
- public int getCharCount() {
+ public int getCharCount()
+ {
return 0; // TODO
} // getCharCount()
@@ -215,7 +231,8 @@
* @param value0 TODO
* @returns AttributeSet
*/
- public AttributeSet getCharacterAttribute(int value0) {
+ public AttributeSet getCharacterAttribute(int value0)
+ {
return null; // TODO
} // getCharacterAttribute()
@@ -225,7 +242,8 @@
* @param value1 TODO
* @returns String
*/
- public String getAtIndex(int value0, int value1) {
+ public String getAtIndex(int value0, int value1)
+ {
return null; // TODO
} // getAtIndex()
@@ -235,7 +253,8 @@
* @param value1 TODO
* @returns String
*/
- public String getAfterIndex(int value0, int value1) {
+ public String getAfterIndex(int value0, int value1)
+ {
return null; // TODO
} // getAfterIndex()
@@ -245,15 +264,12 @@
* @param value1 TODO
* @returns String
*/
- public String getBeforeIndex(int value0, int value1) {
+ public String getBeforeIndex(int value0, int value1)
+ {
return null; // TODO
} // getBeforeIndex()
-
-
} // AccessibleJTextComponent
-
-
public static class KeyBinding
{
public KeyStroke key;
@@ -359,10 +382,14 @@
}
public Icon getIcon()
- { return icon; }
- public int getIconTextGap()
- { return icon_gap; }
+ {
+ return icon;
+ }
+ public int getIconTextGap()
+ {
+ return icon_gap;
+ }
Component getLabelFor()
{
@@ -378,14 +405,13 @@
public void setText(String text)
{
- getDocument().remove(0,doc.getLength());
+ getDocument().remove(0, doc.getLength());
getDocument().insertString(0, text, null);
}
public String getText()
{
- return getDocument().getText(0,
- getDocument().getLength());
+ return getDocument().getText(0, getDocument().getLength());
}
public String getUIClassID()
@@ -404,7 +432,8 @@
return 0;
}
- public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
+ public boolean imageUpdate(Image img, int infoflags, int x, int y, int w,
+ int h)
{
// This is overriden to return false if the current Icon's Image is not equal to the passed in Image img.
return (img == icon);
Index: javax/swing/text/PlainDocument.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/text/PlainDocument.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 PlainDocument.java