< prev index next >
src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java
Print this page
*** 66,76 ****
* is to edit them. Additionally, users don't like to be presented
* with an excessive amount of structure editing, so using traditional
* text editing gestures is preferred over using the HTML structure
* exactly as defined in the HTML document.
* <p>
! * The modeling of HTML is provided by the class <code>HTMLDocument</code>.
* Its documentation describes the details of how the HTML is modeled.
* The editing support leverages heavily off of the text package.
*
* <dt>
* Extendable/Scalable
--- 66,76 ----
* is to edit them. Additionally, users don't like to be presented
* with an excessive amount of structure editing, so using traditional
* text editing gestures is preferred over using the HTML structure
* exactly as defined in the HTML document.
* <p>
! * The modeling of HTML is provided by the class {@code HTMLDocument}.
* Its documentation describes the details of how the HTML is modeled.
* The editing support leverages heavily off of the text package.
*
* <dt>
* Extendable/Scalable
*** 99,109 ****
* <li>
* The default view of the models are provided as a hierarchy of
* View implementations, so one can easily customize how a particular
* element is displayed or add capabilities for new kinds of elements
* by providing new View implementations. The default set of views
! * are provided by the <code>HTMLFactory</code> class. This can
* be easily changed by subclassing or replacing the HTMLFactory
* and reimplementing the getViewFactory method to return the alternative
* factory.
* <li>
* The View implementations work primarily off of CSS attributes,
--- 99,109 ----
* <li>
* The default view of the models are provided as a hierarchy of
* View implementations, so one can easily customize how a particular
* element is displayed or add capabilities for new kinds of elements
* by providing new View implementations. The default set of views
! * are provided by the {@code HTMLFactory} class. This can
* be easily changed by subclassing or replacing the HTMLFactory
* and reimplementing the getViewFactory method to return the alternative
* factory.
* <li>
* The View implementations work primarily off of CSS attributes,
*** 118,134 ****
* <dt>
* Asynchronous Loading
* <dd>
* Larger documents involve a lot of parsing and take some time
* to load. By default, this kit produces documents that will be
! * loaded asynchronously if loaded using <code>JEditorPane.setPage</code>.
* This is controlled by a property on the document. The method
* {@link #createDefaultDocument createDefaultDocument} can
* be overriden to change this. The batching of work is done
! * by the <code>HTMLDocument.HTMLReader</code> class. The actual
! * work is done by the <code>DefaultStyledDocument</code> and
! * <code>AbstractDocument</code> classes in the text package.
*
* <dt>
* Customization from current LAF
* <dd>
* HTML provides a well known set of features without exactly
--- 118,134 ----
* <dt>
* Asynchronous Loading
* <dd>
* Larger documents involve a lot of parsing and take some time
* to load. By default, this kit produces documents that will be
! * loaded asynchronously if loaded using {@code JEditorPane.setPage}.
* This is controlled by a property on the document. The method
* {@link #createDefaultDocument createDefaultDocument} can
* be overriden to change this. The batching of work is done
! * by the {@code HTMLDocument.HTMLReader} class. The actual
! * work is done by the {@code DefaultStyledDocument} and
! * {@code AbstractDocument} classes in the text package.
*
* <dt>
* Customization from current LAF
* <dd>
* HTML provides a well known set of features without exactly
*** 136,146 ****
* mechanism for its look-and-feel implementations. It is desirable
* for the look-and-feel to feed display characteristics into the
* HTML views. An user with poor vision for example would want
* high contrast and larger than typical fonts.
* <p>
! * The support for this is provided by the <code>StyleSheet</code>
* class. The presentation of the HTML can be heavily influenced
* by the setting of the StyleSheet property on the EditorKit.
*
* <dt>
* Not lossy
--- 136,146 ----
* mechanism for its look-and-feel implementations. It is desirable
* for the look-and-feel to feed display characteristics into the
* HTML views. An user with poor vision for example would want
* high contrast and larger than typical fonts.
* <p>
! * The support for this is provided by the {@code StyleSheet}
* class. The presentation of the HTML can be heavily influenced
* by the setting of the StyleSheet property on the EditorKit.
*
* <dt>
* Not lossy
*** 174,184 ****
}
/**
* Get the MIME type of the data that this
* kit represents support for. This kit supports
! * the type <code>text/html</code>.
*
* @return the type
*/
public String getContentType() {
return "text/html";
--- 174,184 ----
}
/**
* Get the MIME type of the data that this
* kit represents support for. This kit supports
! * the type {@code text/html}.
*
* @return the type
*/
public String getContentType() {
return "text/html";
*** 229,239 ****
}
return p;
}
/**
! * Inserts content from the given stream. If <code>doc</code> is
* an instance of HTMLDocument, this will read
* HTML 3.2 text. Inserting HTML into a non-empty document must be inside
* the body Element, if you do not insert into the body an exception will
* be thrown. When inserting into a non-empty document all tags outside
* of the body (head, title) will be dropped.
--- 229,239 ----
}
return p;
}
/**
! * Inserts content from the given stream. If {@code doc} is
* an instance of HTMLDocument, this will read
* HTML 3.2 text. Inserting HTML into a non-empty document must be inside
* the body Element, if you do not insert into the body an exception will
* be thrown. When inserting into a non-empty document all tags outside
* of the body (head, title) will be dropped.
*** 443,457 ****
public Action[] getActions() {
return TextAction.augmentList(super.getActions(), defaultActions);
}
/**
! * Copies the key/values in <code>element</code>s AttributeSet into
! * <code>set</code>. This does not copy component, icon, or element
* names attributes. Subclasses may wish to refine what is and what
* isn't copied here. But be sure to first remove all the attributes that
! * are in <code>set</code>.<p>
* This is called anytime the caret moves over a different location.
*
*/
protected void createInputAttributes(Element element,
MutableAttributeSet set) {
--- 443,457 ----
public Action[] getActions() {
return TextAction.augmentList(super.getActions(), defaultActions);
}
/**
! * Copies the key/values in {@code element}s AttributeSet into
! * {@code set}. This does not copy component, icon, or element
* names attributes. Subclasses may wish to refine what is and what
* isn't copied here. But be sure to first remove all the attributes that
! * are in {@code set}.<p>
* This is called anytime the caret moves over a different location.
*
*/
protected void createInputAttributes(Element element,
MutableAttributeSet set) {
*** 555,565 ****
return linkCursor;
}
/**
* Indicates whether an html form submission is processed automatically
! * or only <code>FormSubmitEvent</code> is fired.
*
* @return true if html form submission is processed automatically,
* false otherwise.
*
* @see #setAutoFormSubmission
--- 555,565 ----
return linkCursor;
}
/**
* Indicates whether an html form submission is processed automatically
! * or only {@code FormSubmitEvent} is fired.
*
* @return true if html form submission is processed automatically,
* false otherwise.
*
* @see #setAutoFormSubmission
*** 569,579 ****
return isAutoFormSubmission;
}
/**
* Specifies if an html form submission is processed
! * automatically or only <code>FormSubmitEvent</code> is fired.
* By default it is set to true.
*
* @param isAuto if {@code true}, html form submission is processed automatically.
*
* @see #isAutoFormSubmission()
--- 569,579 ----
return isAutoFormSubmission;
}
/**
* Specifies if an html form submission is processed
! * automatically or only {@code FormSubmitEvent} is fired.
* By default it is set to true.
*
* @param isAuto if {@code true}, html form submission is processed automatically.
*
* @see #isAutoFormSubmission()
*** 810,821 ****
}
return null;
}
/**
! * Returns true if the View representing <code>e</code> contains
! * the location <code>x</code>, <code>y</code>. <code>offset</code>
* gives the offset into the Document to check for.
*/
private boolean doesElementContainLocation(JEditorPane editor,
Element e, int offset,
int x, int y) {
--- 810,821 ----
}
return null;
}
/**
! * Returns true if the View representing {@code e} contains
! * the location {@code x}, {@code y}. {@code offset}
* gives the offset into the Document to check for.
*/
private boolean doesElementContainLocation(JEditorPane editor,
Element e, int offset,
int x, int y) {
*** 857,868 ****
}
/**
* Calls linkActivated on the associated JEditorPane
* if the given position represents a link. If this was the result
! * of a mouse click, <code>x</code> and
! * <code>y</code> will give the location of the mouse, otherwise
* they will be {@literal <} 0.
*
* @param pos the position
* @param html the editor pane
*/
--- 857,868 ----
}
/**
* Calls linkActivated on the associated JEditorPane
* if the given position represents a link. If this was the result
! * of a mouse click, {@code x} and
! * {@code y} will give the location of the mouse, otherwise
* they will be {@literal <} 0.
*
* @param pos the position
* @param html the editor pane
*/
*** 900,910 ****
}
}
/**
* Creates and returns a new instance of HyperlinkEvent. If
! * <code>hdoc</code> is a frame document a HTMLFrameHyperlinkEvent
* will be created.
*/
HyperlinkEvent createHyperlinkEvent(JEditorPane html,
HTMLDocument hdoc, String href,
AttributeSet anchor,
--- 900,910 ----
}
}
/**
* Creates and returns a new instance of HyperlinkEvent. If
! * {@code hdoc} is a frame document a HTMLFrameHyperlinkEvent
* will be created.
*/
HyperlinkEvent createHyperlinkEvent(JEditorPane html,
HTMLDocument hdoc, String href,
AttributeSet anchor,
*** 1003,1013 ****
}
/**
* The result of parsing drives these callback methods.
* The open and close actions should be balanced. The
! * <code>flush</code> method will be the last method
* called, to give the receiver a chance to flush any
* pending data into the document.
* <p>Refer to DocumentParser, the default parser used, for further
* information on the contents of the AttributeSets, the positions, and
* other info.
--- 1003,1013 ----
}
/**
* The result of parsing drives these callback methods.
* The open and close actions should be balanced. The
! * {@code flush} method will be the last method
* called, to give the receiver a chance to flush any
* pending data into the document.
* <p>Refer to DocumentParser, the default parser used, for further
* information on the contents of the AttributeSets, the positions, and
* other info.
*** 1098,1108 ****
public void handleError(String errorMsg, int pos) {
}
/**
* This is invoked after the stream has been parsed, but before
! * <code>flush</code>. <code>eol</code> will be one of \n, \r
* or \r\n, which ever is encountered the most in parsing the
* stream.
*
* @param eol value of eol
*
--- 1098,1108 ----
public void handleError(String errorMsg, int pos) {
}
/**
* This is invoked after the stream has been parsed, but before
! * {@code flush}. {@code eol} will be one of \n, \r
* or \r\n, which ever is encountered the most in parsing the
* stream.
*
* @param eol value of eol
*
*** 1575,1585 ****
super(name);
}
/**
* @param e the JEditorPane
! * @return HTMLDocument of <code>e</code>.
*/
protected HTMLDocument getHTMLDocument(JEditorPane e) {
Document d = e.getDocument();
if (d instanceof HTMLDocument) {
return (HTMLDocument) d;
--- 1575,1585 ----
super(name);
}
/**
* @param e the JEditorPane
! * @return HTMLDocument of {@code e}.
*/
protected HTMLDocument getHTMLDocument(JEditorPane e) {
Document d = e.getDocument();
if (d instanceof HTMLDocument) {
return (HTMLDocument) d;
*** 1587,1613 ****
throw new IllegalArgumentException("document must be HTMLDocument");
}
/**
* @param e the JEditorPane
! * @return HTMLEditorKit for <code>e</code>.
*/
protected HTMLEditorKit getHTMLEditorKit(JEditorPane e) {
EditorKit k = e.getEditorKit();
if (k instanceof HTMLEditorKit) {
return (HTMLEditorKit) k;
}
throw new IllegalArgumentException("EditorKit must be HTMLEditorKit");
}
/**
! * Returns an array of the Elements that contain <code>offset</code>.
* The first elements corresponds to the root.
*
* @param doc an instance of HTMLDocument
* @param offset value of offset
! * @return an array of the Elements that contain <code>offset</code>
*/
protected Element[] getElementsAt(HTMLDocument doc, int offset) {
return getElementsAt(doc.getDefaultRootElement(), offset, 0);
}
--- 1587,1613 ----
throw new IllegalArgumentException("document must be HTMLDocument");
}
/**
* @param e the JEditorPane
! * @return HTMLEditorKit for {@code e}.
*/
protected HTMLEditorKit getHTMLEditorKit(JEditorPane e) {
EditorKit k = e.getEditorKit();
if (k instanceof HTMLEditorKit) {
return (HTMLEditorKit) k;
}
throw new IllegalArgumentException("EditorKit must be HTMLEditorKit");
}
/**
! * Returns an array of the Elements that contain {@code offset}.
* The first elements corresponds to the root.
*
* @param doc an instance of HTMLDocument
* @param offset value of offset
! * @return an array of the Elements that contain {@code offset}
*/
protected Element[] getElementsAt(HTMLDocument doc, int offset) {
return getElementsAt(doc.getDefaultRootElement(), offset, 0);
}
*** 1627,1640 ****
return retValue;
}
/**
* Returns number of elements, starting at the deepest leaf, needed
! * to get to an element representing <code>tag</code>. This will
! * return -1 if no elements is found representing <code>tag</code>,
! * or 0 if the parent of the leaf at <code>offset</code> represents
! * <code>tag</code>.
*
* @param doc an instance of HTMLDocument
* @param offset an offset to start from
* @param tag tag to represent
* @return number of elements
--- 1627,1640 ----
return retValue;
}
/**
* Returns number of elements, starting at the deepest leaf, needed
! * to get to an element representing {@code tag}. This will
! * return -1 if no elements is found representing {@code tag},
! * or 0 if the parent of the leaf at {@code offset} represents
! * {@code tag}.
*
* @param doc an instance of HTMLDocument
* @param offset an offset to start from
* @param tag tag to represent
* @return number of elements
*** 1653,1664 ****
}
return depth;
}
/**
! * Returns the deepest element at <code>offset</code> matching
! * <code>tag</code>.
*
* @param doc an instance of HTMLDocument
* @param offset the specified offset >= 0
* @param tag an instance of HTML.Tag
*
--- 1653,1664 ----
}
return depth;
}
/**
! * Returns the deepest element at {@code offset} matching
! * {@code tag}.
*
* @param doc an instance of HTMLDocument
* @param offset the specified offset >= 0
* @param tag an instance of HTML.Tag
*
*** 1871,1883 ****
insertHTML(editor, doc, offset, html, pops, pushes, addTag);
}
}
/**
! * If there is an Element with name <code>tag</code> at
! * <code>offset</code>, this will invoke either insertAtBoundary
! * or <code>insertHTML</code>. This returns true if there is
* a match, and one of the inserts is invoked.
*/
/*protected*/
boolean insertIntoTag(JEditorPane editor, HTMLDocument doc,
int offset, HTML.Tag tag, HTML.Tag addTag) {
--- 1871,1883 ----
insertHTML(editor, doc, offset, html, pops, pushes, addTag);
}
}
/**
! * If there is an Element with name {@code tag} at
! * {@code offset}, this will invoke either insertAtBoundary
! * or {@code insertHTML}. This returns true if there is
* a match, and one of the inserts is invoked.
*/
/*protected*/
boolean insertIntoTag(JEditorPane editor, HTMLDocument doc,
int offset, HTML.Tag tag, HTML.Tag addTag) {
*** 2326,2336 ****
}
/*
* If possible acquires a lock on the Document. If a lock has been
* obtained a key will be retured that should be passed to
! * <code>unlock</code>.
*/
private Object lock(JEditorPane editor) {
Document document = editor.getDocument();
if (document instanceof AbstractDocument) {
--- 2326,2336 ----
}
/*
* If possible acquires a lock on the Document. If a lock has been
* obtained a key will be retured that should be passed to
! * {@code unlock}.
*/
private Object lock(JEditorPane editor) {
Document document = editor.getDocument();
if (document instanceof AbstractDocument) {
*** 2339,2349 ****
}
return null;
}
/*
! * Releases a lock previously obtained via <code>lock</code>.
*/
private void unlock(Object key) {
if (key != null) {
((AbstractDocument)key).readUnlock();
}
--- 2339,2349 ----
}
return null;
}
/*
! * Releases a lock previously obtained via {@code lock}.
*/
private void unlock(Object key) {
if (key != null) {
((AbstractDocument)key).readUnlock();
}
< prev index next >