javax.swing.text.html

Class HTMLEditorKit.InsertHTMLTextAction

public static class HTMLEditorKit.InsertHTMLTextAction extends HTMLEditorKit.HTMLTextAction

This class is used to insert a string of HTML into an existing document. At least 2 HTML.Tags need to be supplied. The first Tag (parentTag) identifies the parent in the document to add the elements to. The second, (addTag), identifies that the first tag should be added to the document as seen in the string. The parser will generate all appropriate (opening/closing tags_ even if they are not in the HTML string passed in.
Field Summary
protected HTML.TagaddTag
Tag in HTML to start adding tags from.
protected HTML.TagalternateAddTag
Alternate tag in HTML to start adding tags from if parentTag is not found and alternateParentTag is not found.
protected HTML.TagalternateParentTag
Alternate tag to check if parentTag is not found.
protected Stringhtml
HTML to insert.
protected HTML.TagparentTag
Tag to check for in the document.
Constructor Summary
InsertHTMLTextAction(String name, String html, HTML.Tag parentTag, HTML.Tag addTag)
Initializes all fields.
InsertHTMLTextAction(String name, String html, HTML.Tag parentTag, HTML.Tag addTag, HTML.Tag alternateParentTag, HTML.Tag alternateAddTag)
Initializes all fields and calls super
Method Summary
voidactionPerformed(ActionEvent ae)
Inserts the HTML.
protected voidinsertAtBoundary(JEditorPane editor, HTMLDocument doc, int offset, Element insertElement, String html, HTML.Tag parentTag, HTML.Tag addTag)
Invoked when inserting at a boundary.
protected voidinsertAtBoundry(JEditorPane editor, HTMLDocument doc, int offset, Element insertElement, String html, HTML.Tag parentTag, HTML.Tag addTag)
Invoked when inserting at a boundary.
protected voidinsertHTML(JEditorPane editor, HTMLDocument doc, int offset, String html, int popDepth, int pushDepth, HTML.Tag addTag)
HTMLEditorKit.insertHTML is called.

Field Detail

addTag

protected HTML.Tag addTag
Tag in HTML to start adding tags from.

alternateAddTag

protected HTML.Tag alternateAddTag
Alternate tag in HTML to start adding tags from if parentTag is not found and alternateParentTag is not found.

alternateParentTag

protected HTML.Tag alternateParentTag
Alternate tag to check if parentTag is not found.

html

protected String html
HTML to insert.

parentTag

protected HTML.Tag parentTag
Tag to check for in the document.

Constructor Detail

InsertHTMLTextAction

public InsertHTMLTextAction(String name, String html, HTML.Tag parentTag, HTML.Tag addTag)
Initializes all fields.

Parameters: name - the name of the document. html - the html to insert parentTag - the parent tag to check for addTag - the tag to start adding from

InsertHTMLTextAction

public InsertHTMLTextAction(String name, String html, HTML.Tag parentTag, HTML.Tag addTag, HTML.Tag alternateParentTag, HTML.Tag alternateAddTag)
Initializes all fields and calls super

Parameters: name - the name of the document. html - the html to insert parentTag - the parent tag to check for addTag - the tag to start adding from alternateParentTag - the alternate parent tag alternateAddTag - the alternate add tag

Method Detail

actionPerformed

public void actionPerformed(ActionEvent ae)
Inserts the HTML.

Parameters: ae - the action performed

insertAtBoundary

protected void insertAtBoundary(JEditorPane editor, HTMLDocument doc, int offset, Element insertElement, String html, HTML.Tag parentTag, HTML.Tag addTag)
Invoked when inserting at a boundary. Determines the number of pops, and then the number of pushes that need to be performed. The it calls insertHTML.

Parameters: editor - the editor to use to get the editorkit doc - the Document to insert the HTML into. offset - where to begin inserting the HTML. insertElement - the element to insert html - the html to insert parentTag - the parent tag addTag - the first tag

insertAtBoundry

protected void insertAtBoundry(JEditorPane editor, HTMLDocument doc, int offset, Element insertElement, String html, HTML.Tag parentTag, HTML.Tag addTag)

Deprecated: as of v1.3, use insertAtBoundary

Invoked when inserting at a boundary. Determines the number of pops, and then the number of pushes that need to be performed. The it calls insertHTML.

Parameters: editor - the editor to use to get the editorkit doc - the Document to insert the HTML into. offset - where to begin inserting the HTML. insertElement - the element to insert html - the html to insert parentTag - the parent tag addTag - the first tag

insertHTML

protected void insertHTML(JEditorPane editor, HTMLDocument doc, int offset, String html, int popDepth, int pushDepth, HTML.Tag addTag)
HTMLEditorKit.insertHTML is called. If an exception is thrown, it is wrapped in a RuntimeException and thrown.

Parameters: editor - the editor to use to get the editorkit doc - the Document to insert the HTML into. offset - where to begin inserting the HTML. html - the String to insert popDepth - the number of ElementSpec.EndTagTypes to generate before inserting pushDepth - the number of ElementSpec.StartTagTypes with a direction of ElementSpec.JoinNextDirection that should be generated before addTag - the first tag to start inserting into document