Index: javax/swing/text/html/HTMLDocument.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/HTMLDocument.java,v retrieving revision 1.16 diff -u -r1.16 HTMLDocument.java --- javax/swing/text/html/HTMLDocument.java 15 Dec 2005 20:20:40 -0000 1.16 +++ javax/swing/text/html/HTMLDocument.java 16 Dec 2005 21:27:51 -0000 @@ -83,8 +83,7 @@ */ public HTMLDocument() { - // FIXME: Should be using default style sheet from HTMLEditorKit - this(new StyleSheet()); + this(null); } /** @@ -108,6 +107,12 @@ public HTMLDocument(AbstractDocument.Content c, StyleSheet styles) { this.content = c; + if (styles == null) + { + styles = new StyleSheet(); + styles.importStyleSheet(getClass().getResource(HTMLEditorKit. + DEFAULT_CSS)); + } this.styleSheet = styles; } Index: javax/swing/text/html/HTMLEditorKit.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/HTMLEditorKit.java,v retrieving revision 1.19 diff -u -r1.19 HTMLEditorKit.java --- javax/swing/text/html/HTMLEditorKit.java 15 Dec 2005 20:20:41 -0000 1.19 +++ javax/swing/text/html/HTMLEditorKit.java 16 Dec 2005 21:27:51 -0000 @@ -38,6 +38,7 @@ package javax.swing.text.html; + import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -96,7 +97,7 @@ */ public LinkController() { - // Nothing to do here. + super(); } /** @@ -229,6 +230,8 @@ HTML.Tag alternateAddTag) { super(name); + // Fields are for easy access when the action is applied to an actual + // document. this.html = html; this.parentTag = parentTag; this.addTag = addTag; @@ -350,13 +353,21 @@ */ public void actionPerformed(ActionEvent ae) { - // FIXME: Not implemented. + Object source = ae.getSource(); + if (source instanceof JEditorPane) + { + JEditorPane pane = ((JEditorPane) source); + Document d = pane.getDocument(); + if (d instanceof HTMLDocument) + insertHTML(pane, (HTMLDocument) d, 0, html, 0, 0, addTag); + // FIXME: is this correct parameters? + } + // FIXME: else not implemented } - } + } /** - * Abstract Action class that helps inserting HTML - * into an existing document. + * Abstract Action class that helps inserting HTML into an existing document. */ public abstract static class HTMLTextAction extends StyledEditorKit.StyledTextAction @@ -815,7 +826,7 @@ /** * The parser. */ - Parser parserDel; + Parser parser; /** * The mouse listener used for links. @@ -826,6 +837,15 @@ * Style context for this editor. */ StyleContext styleContext; + + /** The content type */ + String contentType = "text/html"; + + /** The input attributes defined by default.css */ + MutableAttributeSet inputAttributes; + + /** The editor pane used. */ + JEditorPane editorPane; /** * Constructs an HTMLEditorKit, creates a StyleContext, and loads the style sheet. @@ -834,9 +854,9 @@ { super(); styleContext = new StyleContext(); - // FIXME: Should load default.css for style sheet, - // javax/swing/text/html/default.css styleSheet = new StyleSheet(); + styleSheet.importStyleSheet(getClass().getResource(DEFAULT_CSS)); + // FIXME: Set inputAttributes with default.css } /** @@ -872,9 +892,9 @@ */ protected Parser getParser() { - if (parserDel == null) - parserDel = new ParserDelegator(); - return parserDel; + if (parser == null) + parser = new ParserDelegator(); + return parser; } /** @@ -936,9 +956,11 @@ throw new BadLocationException("Bad location", pos); if (parser == null) throw new IOException("Parser is null."); - - ParserCallback pc = ((HTMLDocument) doc).getReader(pos); - + + HTMLDocument hd = ((HTMLDocument) doc); + hd.setBase(editorPane.getPage()); + ParserCallback pc = hd.getReader(pos); + // FIXME: What should ignoreCharSet be set to? // parser.parse inserts html into the buffer @@ -983,7 +1005,7 @@ */ public String getContentType() { - return "text/html"; + return contentType; } /** @@ -1008,8 +1030,8 @@ protected void createInputAttributes(Element element, MutableAttributeSet set) { - // FIXME: Not implemented. - super.createInputAttributes(element, set); + set.addAttributes(element.getAttributes()); + // FIXME: Not fully implemented. } /** @@ -1022,6 +1044,8 @@ super.install(c); mouseListener = new LinkController(); c.addMouseListener(mouseListener); + editorPane = c; + // FIXME: need to set up hyperlinklistener object } /** @@ -1035,6 +1059,7 @@ super.deinstall(c); c.removeMouseListener(mouseListener); mouseListener = null; + editorPane = null; } /** @@ -1108,8 +1133,11 @@ public MutableAttributeSet getInputAttributes() { - // FIXME: Not implemented. - return super.getInputAttributes(); + if (inputAttributes != null) + inputAttributes.addAttributes(super.getInputAttributes()); + else + inputAttributes = super.getInputAttributes(); + return inputAttributes; } /** Index: javax/swing/text/html/StyleSheet.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/StyleSheet.java,v retrieving revision 1.2 diff -u -r1.2 StyleSheet.java --- javax/swing/text/html/StyleSheet.java 15 Dec 2005 20:20:41 -0000 1.2 +++ javax/swing/text/html/StyleSheet.java 16 Dec 2005 21:27:51 -0000 @@ -42,7 +42,9 @@ import java.awt.Font; import java.awt.Graphics; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.io.Reader; import java.io.Serializable; @@ -261,14 +263,24 @@ */ public void importStyleSheet(URL url) { - // FIXME: Not implemented. + try + { + // FIXME: Need to make sure url points to a valid CSS document. + loadRules(new BufferedReader(new InputStreamReader(url.openStream())), + url); + } + catch (IOException ioe) + { + // Do nothing here. + } } /** - * Sets the base url. All import statements that are relative, will be + * Sets the base url. All import statements that are relative, will be * relative to base. * - * @param base - the base URL. + * @param base - + * the base URL. */ public void setBase(URL base) { Index: javax/swing/text/html/default.css =================================================================== RCS file: javax/swing/text/html/default.css diff -N javax/swing/text/html/default.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ javax/swing/text/html/default.css 16 Dec 2005 21:27:51 -0000 @@ -0,0 +1,377 @@ +/* default.css -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +nobr { + white-space: nowrap; +} + +ol { + margin-right: 50px; + margin-top: 10px; + margin-left: 50px; + margin-bottom: 10px; + list-style-type: decimal; +} + +u { + text-decoration: underline; +} + +s { + text-decoration: line-through; +} + +p { + margin-top: 15px; +} + +dd p { + margin-left: 0px; + margin-top: 0px; + margin-bottom: 0px; +} + +ol li p { + margin-top: 0px; + margin-bottom: 0px; +} + + +address { + font-style: italic; + color: blue; +} + +i { + font-style: italic; +} + +h6 { + margin-top: 10px; + font-size: xx-small; + font-weight: bold; + margin-bottom: 10px; +} + +h5 { + margin-top: 10px; + font-size: x-small; + font-weight: bold; + margin-bottom: 10px; +} + +h4 { + margin-top: 10px; + font-size: small; + font-weight: bold; + margin-bottom: 10px; +} + +h3 { + margin-top: 10px; + font-size: medium; + font-weight: bold; + margin-bottom: 10px; +} + +dir li p { + margin-top: 0px; + margin-bottom: 0px; +} + +h2 { + margin-top: 10px; + font-size: large; + font-weight: bold; + margin-bottom: 10px; +} + +b { + font-weight: bold; +} + +h1 { + margin-top: 10px; + font-size: x-large; + font-weight: bold; + margin-bottom: 10px; +} + +caption { + text-align: center; + caption-side: top; +} + +a { + text-decoration: underline; + color: blue; +} + +ul li ul li ul li { + margin-left: 0px; + margin-top: 0px; + margin-bottom: 0px; +} + +menu { + margin-right: 40px; + margin-top: 10px; + margin-left: 40px; + margin-bottom: 10px; +} + +menu li p { + margin-top: 0px; + margin-bottom: 0px; +} + +sup { + vertical-align: super; +} + +body { + margin-right: 0px; + margin-left: 0px; + font-family: Serif; + font-size: 14pt; + font-weight: normal; + color: black; +} + +ul li ul li ul { + margin-right: 25px; + margin-left: 25px; + list-style-type: square; +} + +blockquote { + margin-right: 35px; + margin-left: 35px; + margin-top: 5px; + margin-bottom: 5px; +} + +samp { + font-family: Monospaced; + font-size: small; +} + +cite { + font-style: italic; +} + +sub { + vertical-align: sub; +} + +em { + font-style: italic; +} + +ul li p { + margin-top: 0px; + margin-bottom: 0px; +} + +ul li ul li { + margin-right: 0px; + margin-left: 0px; + margin-top: 0px; + margin-bottom: 0px; +} + +var { + font-style: italic; + font-weight: bold; +} + +table { + border-color: Gray; + border-style: outset; +} + +dfn { + font-style: italic; +} + +menu li { + margin-right: 0px; + margin-left: 0px; + margin-top: 0px; + margin-bottom: 0px; +} + +strong { + font-weight: bold; +} + +ul { + margin-right: 50px; + margin-top: 10px; + margin-left: 50px; + margin-bottom: 10px; + list-style-type: disc; +} + +center { + text-align: center; +} + +ul li ul { + margin-right: 25px; + margin-left: 25px; + list-style-type: circle; +} + +kbd { + font-family: Monospaced; + font-size: small; +} + +dir li { + margin-right: 0px; + margin-left: 0px; + margin-top: 0px; + margin-bottom: 0px; +} + +ul li menu { + margin-right: 25px; + margin-left: 25px; + list-style-type: circle; +} + +dt { + margin-top: 0px; + margin-bottom: 0px; +} + +ol li { + margin-right: 0px; + margin-left: 0px; + margin-top: 0px; + margin-bottom: 0px; +} + +li p { + margin-top: 0px; + margin-bottom: 0px; +} + +default { +} + +strike { + text-decoration: line-through; +} + +dl { + margin-left: 0px; + margin-top: 10px; + margin-bottom: 10px; +} + +tt { + font-family: Monospaced; +} + +ul li {margin-right: 0px; + margin-left: 0px; + margin-top: 0px; + margin-bottom: 0px; +} + +dir { + margin-right: 40px; + margin-top: 10px; + margin-left: 40px; + margin-bottom: 10px; +} + +tr { + text-align: left; +} + +pre p { + margin-top: 0px; +} + +dd { + margin-right: 40px; + margin-top: 0px; + margin-left: 40px; + margin-bottom: 0px; +} + +th { + padding-bottom: 3px; + text-align: center; + padding-top: 3px; + padding-right: 3px; + padding-left: 3px; + font-weight: bold; + border-color: Gray; + border-style: inset; +} + +pre { + margin-top: 5px; + font-family: Monospaced; + margin-bottom: 5px; +} + +td { + padding-bottom: 3px; + padding-top: 3px; + padding-right: 3px; + padding-left: 3px; + border-color: Gray; + border-style: inset; +} + +code { + font-family: Monospaced; + font-size: small; +} + +small { + font-size: x-small; +} + +big { + font-size: x-large; +}