summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2005-11-17 21:42:46 +0000
committerRoman Kennke <roman@kennke.org>2005-11-17 21:42:46 +0000
commit32ee9530e268e92bb6f231d6b0d53be1dfdf396c (patch)
tree843a79d078a11e5c8b1092527c8ae71f6513a633
parent338bc4e32ab5a992ca1d256c6d1adfe0c243f989 (diff)
downloadclasspath-32ee9530e268e92bb6f231d6b0d53be1dfdf396c.tar.gz
2005-11-17 Roman Kennke <kennke@aicas.com>libgcj-import-20051117
* javax/swing/JEditorPane.java (PlainEditorKit): New inner class. (createDefaultEditorKit): Return an instance of PlainEditorKit. * javax/swing/JTextPane.java (insertComponent): Implemented previously stubbed method. (insertIcon): Implemented previously stubbed method.
-rw-r--r--ChangeLog13
-rw-r--r--javax/swing/JEditorPane.java31
-rw-r--r--javax/swing/JTextPane.java36
3 files changed, 70 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 5bc1bcb2e..1e5f04326 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,17 @@
2005-11-17 Roman Kennke <kennke@aicas.com>
- * javax/swing/BasicEditorPaneUI.java
+ * javax/swing/JEditorPane.java
+ (PlainEditorKit): New inner class.
+ (createDefaultEditorKit): Return an instance of PlainEditorKit.
+ * javax/swing/JTextPane.java
+ (insertComponent): Implemented previously stubbed method.
+ (insertIcon): Implemented previously stubbed method.
+
+2005-11-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicEditorPaneUI.java
(create): Removed unneeded method.
- * javax/swing/BasicTextPaneUI.java
+ * javax/swing/plaf/basic/BasicTextPaneUI.java
(create): Removed unneeded method.
2005-11-17 Roman Kennke <kennke@aicas.com>
diff --git a/javax/swing/JEditorPane.java b/javax/swing/JEditorPane.java
index 9ddf970de..39f7c1f14 100644
--- a/javax/swing/JEditorPane.java
+++ b/javax/swing/JEditorPane.java
@@ -59,6 +59,9 @@ import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import javax.swing.text.Element;
import javax.swing.text.JTextComponent;
+import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
+import javax.swing.text.WrappedPlainView;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
@@ -466,6 +469,30 @@ public class JEditorPane extends JTextComponent
}
}
+ /**
+ * An EditorKit used for plain text. This is the default editor kit for
+ * JEditorPanes.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ private static class PlainEditorKit extends DefaultEditorKit
+ {
+
+ /**
+ * Returns a ViewFactory that supplies WrappedPlainViews.
+ */
+ public ViewFactory getViewFactory()
+ {
+ return new ViewFactory()
+ {
+ public View create(Element el)
+ {
+ return new WrappedPlainView(el);
+ }
+ };
+ }
+ }
+
private static final long serialVersionUID = 3140472492599046285L;
private URL page;
@@ -497,12 +524,12 @@ public class JEditorPane extends JTextComponent
protected EditorKit createDefaultEditorKit()
{
- return new DefaultEditorKit();
+ return new PlainEditorKit();
}
public static EditorKit createEditorKitForContentType(String type)
{
- return new DefaultEditorKit();
+ return new PlainEditorKit();
}
/**
diff --git a/javax/swing/JTextPane.java b/javax/swing/JTextPane.java
index 1f5b99e43..a2aebd4ca 100644
--- a/javax/swing/JTextPane.java
+++ b/javax/swing/JTextPane.java
@@ -47,7 +47,9 @@ import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import javax.swing.text.Element;
import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import javax.swing.text.StyledEditorKit;
@@ -192,9 +194,20 @@ public class JTextPane
*/
public void insertComponent(Component component)
{
- // TODO: One space must be inserted here with attributes set to indicate
- // that the component must be displayed here. Have to figure out the
- // attributes.
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ atts.addAttribute(StyleConstants.ComponentAttribute, component);
+ atts.addAttribute(StyleConstants.NameAttribute,
+ StyleConstants.ComponentElementName);
+ try
+ {
+ getDocument().insertString(getCaret().getDot(), " ", atts);
+ }
+ catch (BadLocationException ex)
+ {
+ AssertionError err = new AssertionError("Unexpected bad location");
+ err.initCause(ex);
+ throw err;
+ }
}
/**
@@ -204,9 +217,20 @@ public class JTextPane
*/
public void insertIcon(Icon icon)
{
- // TODO: One space must be inserted here with attributes set to indicate
- // that the icon must be displayed here. Have to figure out the
- // attributes.
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ atts.addAttribute(StyleConstants.IconAttribute, icon);
+ atts.addAttribute(StyleConstants.NameAttribute,
+ StyleConstants.IconElementName);
+ try
+ {
+ getDocument().insertString(getCaret().getDot(), " ", atts);
+ }
+ catch (BadLocationException ex)
+ {
+ AssertionError err = new AssertionError("Unexpected bad location");
+ err.initCause(ex);
+ throw err;
+ }
}
/**