diff options
author | Roman Kennke <roman@kennke.org> | 2006-11-03 14:00:42 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-11-03 14:00:42 +0000 |
commit | 7e91498dbeb1b00ba1c92a65a2ac4516958d6e52 (patch) | |
tree | ce3447b8a7c5b25a623d54de2db95bd9d4edd01a | |
parent | 2b1ac75662f5dd2d43ff9c63de2aba59ddd1f2f0 (diff) | |
download | classpath-7e91498dbeb1b00ba1c92a65a2ac4516958d6e52.tar.gz |
2006-11-03 Roman Kennke <kennke@aicas.com>
* javax/swing/text/html/HTMLDocument.java
(HTMLReader.FormAction.start): Added support for textarea.
(HTMLReader.FormAction.end): Added support for textarea.
(HTMLReader.HeadAction.end): Call super to actually close the
block.
(HTMLReader.inTextArea): New field.
(HTMLReader.textAreaDocument): New field.
(HTMLReader.handleText): Call textAreaContent when inside
a textarea tag.
(HTMLReader.textAreaContent): Implemented to initialize
the text area's model.
* javax/swing/text/html/FormView.java
(createComponent): Added support for textarea tag.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | javax/swing/text/html/FormView.java | 14 | ||||
-rw-r--r-- | javax/swing/text/html/HTMLDocument.java | 53 |
3 files changed, 75 insertions, 8 deletions
@@ -1,6 +1,22 @@ 2006-11-03 Roman Kennke <kennke@aicas.com> * javax/swing/text/html/HTMLDocument.java + (HTMLReader.FormAction.start): Added support for textarea. + (HTMLReader.FormAction.end): Added support for textarea. + (HTMLReader.HeadAction.end): Call super to actually close the + block. + (HTMLReader.inTextArea): New field. + (HTMLReader.textAreaDocument): New field. + (HTMLReader.handleText): Call textAreaContent when inside + a textarea tag. + (HTMLReader.textAreaContent): Implemented to initialize + the text area's model. + * javax/swing/text/html/FormView.java + (createComponent): Added support for textarea tag. + +2006-11-03 Roman Kennke <kennke@aicas.com> + + * javax/swing/text/html/HTMLDocument.java (HTMLReader.IsindexAction.start): Implemented. 2006-11-03 Roman Kennke <kennke@aicas.com> diff --git a/javax/swing/text/html/FormView.java b/javax/swing/text/html/FormView.java index 103252c47..031a8b7a4 100644 --- a/javax/swing/text/html/FormView.java +++ b/javax/swing/text/html/FormView.java @@ -53,6 +53,8 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JPasswordField; import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.JToggleButton; import javax.swing.UIManager; @@ -282,6 +284,18 @@ public class FormView maxIsPreferred = true; } } + else if (tag == HTML.Tag.TEXTAREA) + { + JTextArea textArea = new JTextArea((Document) model); + int rows = HTML.getIntegerAttributeValue(atts, HTML.Attribute.ROWS, 1); + textArea.setRows(rows); + int cols = HTML.getIntegerAttributeValue(atts, HTML.Attribute.COLS, 20); + textArea.setColumns(cols); + maxIsPreferred = true; + comp = new JScrollPane(textArea, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + } // FIXME: Implement the remaining components. return comp; } diff --git a/javax/swing/text/html/HTMLDocument.java b/javax/swing/text/html/HTMLDocument.java index 2510c0147..e62751f2e 100644 --- a/javax/swing/text/html/HTMLDocument.java +++ b/javax/swing/text/html/HTMLDocument.java @@ -56,6 +56,7 @@ import javax.swing.text.AbstractDocument; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultStyledDocument; +import javax.swing.text.Document; import javax.swing.text.Element; import javax.swing.text.ElementIterator; import javax.swing.text.GapContent; @@ -578,12 +579,27 @@ public class HTMLDocument extends DefaultStyledDocument boolean inStyleTag = false; /** + * This is true when we are inside a <textarea> tag. Any text + * content will then be added to the text area. + * + * This is package private to avoid accessor methods. + */ + boolean inTextArea = false; + + /** * This contains all stylesheets that are somehow read, either * via embedded style tags, or via linked stylesheets. The * elements will be String objects containing a stylesheet each. */ ArrayList styles; + /** + * The document model for a textarea. + * + * This is package private to avoid accessor methods. + */ + Document textAreaDocument; + void print (String line) { if (debug) @@ -681,7 +697,13 @@ public class HTMLDocument extends DefaultStyledDocument } setModel(type, a); } - // TODO: Handle textarea, select and option tags. + else if (t == HTML.Tag.TEXTAREA) + { + inTextArea = true; + textAreaDocument = new PlainDocument(); + a.addAttribute(StyleConstants.ModelAttribute, textAreaDocument); + } + // TODO: Handle select and option tags. // Build the element. super.start(t, a); @@ -693,7 +715,12 @@ public class HTMLDocument extends DefaultStyledDocument */ public void end(HTML.Tag t) { - // TODO: Handle textarea, select and option tags. + if (t == HTML.Tag.TEXTAREA) + { + inTextArea = false; + } + + // TODO: Handle select and option tags. // Finish the element. super.end(t); @@ -949,7 +976,6 @@ public class HTMLDocument extends DefaultStyledDocument * with this Action. */ public void end(HTML.Tag t) - throws NotImplementedException { // We read in all the stylesheets that are embedded or referenced // inside the header. @@ -962,7 +988,8 @@ public class HTMLDocument extends DefaultStyledDocument getStyleSheet().addRule(style); } } - } + super.end(t); + } } class LinkAction extends TagAction @@ -1261,7 +1288,9 @@ public class HTMLDocument extends DefaultStyledDocument { if (shouldInsert() && data != null && data.length > 0) { - if (inPreTag) + if (inTextArea) + textAreaContent(data); + else if (inPreTag) preContent(data); else if (inStyleTag) { @@ -1395,10 +1424,18 @@ public class HTMLDocument extends DefaultStyledDocument * @param data the text to add to the textarea */ protected void textAreaContent(char[] data) - throws NotImplementedException { - // FIXME: Implement. - print ("HTMLReader.textAreaContent not implemented yet"); + try + { + int offset = textAreaDocument.getLength(); + textAreaDocument.insertString(offset, new String(data), null); + } + catch (BadLocationException ex) + { + // Must not happen as we insert at a model location that we + // got from the document itself. + assert false; + } } /** |