After reading some supplementary Swing material, I noticed that we are
missing some methods that do more than just call super. I added in the
stubs for later implementation by Tony or I. I also added some comments
that I felt were important to read when we implement certain functions.
2005-12-15 Lillian Angel <[EMAIL PROTECTED]>
* javax/swing/text/html/HTMLDocument.java
(HTMLDocument): Added a FIXME
(create): Added stub.
(createDefaultRoot): Likewise.
(createLeafElement): Likewise.
(createBranchElement): Likewise.
(insertUpdate): Likewise.
(setParagraphAttributes): Likewise.
(fireChangedUpdate): Likewise.
* javax/swing/text/html/HTMLEditorKit.java
(LinkController): Removed FIXME
(mouseClicked): Added comment
(mouseDragged): Likewise.
(mouseMoved): Likewise.
(activateLink): Likewise.
(insertAtBoundary): Likewise.
(HTMLFactory): Added constructor.
(HTMLEditorKit): Added FIXME to constructor.
* javax/swing/text/html/StyleSheet.java
(removeStyleSheet): Fixed implementation.
Index: javax/swing/text/html/HTMLDocument.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/HTMLDocument.java,v
retrieving revision 1.15
diff -u -r1.15 HTMLDocument.java
--- javax/swing/text/html/HTMLDocument.java 15 Dec 2005 19:20:07 -0000 1.15
+++ javax/swing/text/html/HTMLDocument.java 15 Dec 2005 20:15:13 -0000
@@ -46,6 +46,8 @@
import java.util.Stack;
import java.util.Vector;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.UndoableEditEvent;
import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
@@ -81,6 +83,7 @@
*/
public HTMLDocument()
{
+ // FIXME: Should be using default style sheet from HTMLEditorKit
this(new StyleSheet());
}
@@ -120,6 +123,100 @@
}
/**
+ * Replaces the contents of the document with the given element specifications.
+ * This is called before insert if the loading is done in bursts. This is the
+ * only method called if loading the document entirely in one burst.
+ *
+ * @param data - the date that replaces the content of the document
+ */
+ protected void create(DefaultStyledDocument.ElementSpec[] data)
+ {
+ // FIXME: Not implemented
+ System.out.println("create not implemented");
+ super.create(data);
+ }
+
+ /**
+ * This method creates a root element for the new document.
+ *
+ * @return the new default root
+ */
+ protected AbstractDocument.AbstractElement createDefaultRoot()
+ {
+ // FIXME: Not implemented
+ System.out.println("createDefaultRoot not implemented");
+ return super.createDefaultRoot();
+ }
+
+ /**
+ * This method returns an HTMLDocument.RunElement object attached to
+ * parent representing a run of text from p0 to p1. The run has
+ * attributes described by a.
+ *
+ * @param parent - the parent element
+ * @param a - the attributes for the element
+ * @param p0 - the beginning of the range >= 0
+ * @param p1 - the end of the range >= p0
+ * @return the new element
+ */
+ protected Element createLeafElement(Element parent, AttributeSet a, int p0,
+ int p1)
+ {
+ // FIXME: Not implemented
+ System.out.println("createLeafElement not implemented");
+ return super.createLeafElement(parent, a, p0, p1);
+ }
+
+ /** This method returns an HTMLDocument.BlockElement object representing the
+ * attribute set a and attached to parent.
+ *
+ * @param parent - the parent element
+ * @param a - the attributes for the element
+ * @return the new element
+ */
+ protected Element createBranchElement(Element parent, AttributeSet a)
+ {
+ // FIXME: Not implemented
+ System.out.println("createBranchElement not implemented");
+ return super.createBranchElement(parent, a);
+ }
+
+ /**
+ * Updates document structure as a result of text insertion. This will happen
+ * within a write lock. This implementation simply parses the inserted content
+ * for line breaks and builds up a set of instructions for the element buffer.
+ *
+ * @param chng - a description of the document change
+ * @param attr - the attributes
+ */
+ protected void insertUpdate(AbstractDocument.DefaultDocumentEvent chng,
+ AttributeSet attr)
+ {
+ // FIXME: Not implemented
+ System.out.println("insertUpdate not implemented");
+ super.insertUpdate(chng, attr);
+ }
+
+ /**
* Returns the parser used by this HTMLDocument to insert HTML.
*
* @return the parser used by this HTMLDocument to insert HTML.
@@ -178,7 +275,7 @@
public void setBase(URL u)
{
baseURL = u;
- //TODO: also set the base of the StyleSheet
+ styleSheet.setBase(u);
}
/**
@@ -1431,4 +1528,51 @@
// FIXME: Not implemented fully, use InsertHTML* in HTMLEditorKit?
System.out.println("insertAfterStart not implemented");
}
+
+ /**
+ * This method sets the attributes associated with the paragraph containing
+ * offset. If replace is false, s is merged with existing attributes. The
+ * length argument determines how many characters are affected by the new
+ * attributes. This is often the entire paragraph.
+ *
+ * @param offset -
+ * the offset into the paragraph (must be at least 0)
+ * @param length -
+ * the number of characters affected (must be at least 0)
+ * @param s -
+ * the attributes
+ * @param replace -
+ * whether to replace existing attributes, or merge them
+ */
+ public void setParagraphAttributes(int offset, int length, AttributeSet s,
+ boolean replace)
+ {
+ // FIXME: Not implemented.
+ System.out.println("setParagraphAttributes not implemented");
+ super.setParagraphAttributes(offset, length, s, replace);
+ }
+
+ /**
+ * This method flags a change in the document.
+ *
+ * @param e - the Document event
+ */
+ protected void fireChangedUpdate(DocumentEvent e)
+ {
+ // FIXME: Not implemented.
+ System.out.println("fireChangedUpdate not implemented");
+ super.fireChangedUpdate(e);
+ }
Index: javax/swing/text/html/HTMLEditorKit.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/HTMLEditorKit.java,v
retrieving revision 1.18
diff -u -r1.18 HTMLEditorKit.java
--- javax/swing/text/html/HTMLEditorKit.java 15 Dec 2005 19:20:07 -0000 1.18
+++ javax/swing/text/html/HTMLEditorKit.java 15 Dec 2005 20:15:13 -0000
@@ -96,7 +98,7 @@
*/
public LinkController()
{
- // FIXME: Anything to do here?
+ // Nothing to do here.
}
/**
@@ -108,6 +110,10 @@
*/
public void mouseClicked(MouseEvent e)
{
+ /*
+ These MouseInputAdapter methods generate mouse appropriate events around
+ hyperlinks (entering, exiting, and activating).
+ */
// FIXME: Not implemented.
}
@@ -118,6 +124,10 @@
*/
public void mouseDragged(MouseEvent e)
{
+ /*
+ These MouseInputAdapter methods generate mouse appropriate events around
+ hyperlinks (entering, exiting, and activating).
+ */
// FIXME: Not implemented.
}
@@ -128,6 +138,10 @@
*/
public void mouseMoved(MouseEvent e)
{
+ /*
+ These MouseInputAdapter methods generate mouse appropriate events around
+ hyperlinks (entering, exiting, and activating).
+ */
// FIXME: Not implemented.
}
@@ -142,6 +156,10 @@
protected void activateLink(int pos,
JEditorPane editor)
{
+ /*
+ This method creates and fires a HyperlinkEvent if the document is an
+ instance of HTMLDocument and the href tag of the link is not null.
+ */
// FIXME: Not implemented.
}
}
@@ -286,7 +304,18 @@
String html, HTML.Tag parentTag,
HTML.Tag addTag)
{
- // FIXME: Not implemented.
+ /*
+ As its name implies, this protected method is used when HTML is inserted at a
+ boundary. (A boundary in this case is an offset in doc that exactly matches the
+ beginning offset of the parentTag.) It performs the extra work required to keep
+ the tag stack in shape and then calls insertHTML(). The editor and doc argu-
+ ments are the editor pane and document where the HTML should go. The offset
+ argument represents the cursor location or selection start in doc. The insert-
+ Element and parentTag arguments are used to calculate the proper number of
+ tag pops and pushes before inserting the HTML (via html and addTag, which are
+ passed directly to insertHTML()).
+ */
+ // FIXME: not implemented
}
/**
@@ -473,6 +502,15 @@
public static class HTMLFactory
implements ViewFactory
{
+
+ /**
+ * Constructor
+ */
+ public HTMLFactory()
+ {
+ // Do Nothing here.
+ }
+
/**
* Creates a [EMAIL PROTECTED] View} for the specified <code>Element</code>.
*
@@ -798,6 +836,9 @@
{
super();
styleContext = new StyleContext();
+ // FIXME: Should load default.css for style sheet,
+ // javax/swing/text/html/default.css
+ styleSheet = new StyleSheet();
}
/**
Index: javax/swing/text/html/StyleSheet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/StyleSheet.java,v
retrieving revision 1.1
diff -u -r1.1 StyleSheet.java
--- javax/swing/text/html/StyleSheet.java 15 Dec 2005 19:20:07 -0000 1.1
+++ javax/swing/text/html/StyleSheet.java 15 Dec 2005 20:15:13 -0000
@@ -219,15 +219,25 @@
styleSheet = null;
else
{
- StyleSheet[] tmp = new StyleSheet[styleSheet.length - 1];
- int j = 0;
for (int i = 0; i < styleSheet.length; i++)
{
StyleSheet curr = styleSheet[i];
- if (!curr.equals(ss))
+ if (curr.equals(ss))
{
- tmp[j] = curr;
- j++;
+ StyleSheet[] tmp = new StyleSheet[styleSheet.length - 1];
+ if (i != 0 && i != (styleSheet.length - 1))
+ {
+ System.arraycopy(styleSheet, 0, tmp, 0, i);
+ System.arraycopy(styleSheet, i + 1, tmp, i,
+ styleSheet.length - i - 1);
+ }
+ else if (i == 0)
+ System.arraycopy(styleSheet, 1, tmp, 0, styleSheet.length - 1);
+ else
+ System.arraycopy(styleSheet, 0, tmp, 0, styleSheet.length - 1);
+
+ styleSheet = tmp;
+ break;
}
}
}
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches