diff options
author | Roman Kennke <roman@kennke.org> | 2006-11-30 19:38:04 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-11-30 19:38:04 +0000 |
commit | 73ee7fab7219cb0edb4ded57f73dea804846d6b2 (patch) | |
tree | b498c8e2d6b7daa2127102e318928ac30866135f /javax/swing/text/html/HTMLEditorKit.java | |
parent | 5a7b622274d47160f2e755b7dbb7af2999196a51 (diff) | |
download | classpath-73ee7fab7219cb0edb4ded57f73dea804846d6b2.tar.gz |
2006-11-30 Roman Kennke <kennke@aicas.com>
* javax/swing/text/html/FormSubmitEvent.java: New class.
* javax/swing/text/html/FormView.java
(SubmitThread): New class for submitting data in a separate thread.
(actionPerformed): Fetch the actual for data.
(addData): New helper method.
(getElementFormData): New helper method.
(getFormData): New helper method.
(getInputFormData): New helper method.
(submitData): Implemented.
* javax/swing/text/html/FrameView.java
(createComponent): Add this as hyperlink listener.
Set the target document as frame document.
(getTopEditorPane): New helper method.
(hyperlinkUpdate): Implementation of the HyperlinkListener interface.
(handleHyperlinkEvent): New helper method.
(handleFormSubmitEvent): New helper method.
* javax/swing/text/html/HTMLDocument.java
(HTMLReader.BaseAction.start): Track the base target.
(HTMLReader.BaseAction.end): Removed.
(baseTarget): New field.
(frameDocument): New field.
(getBaseTarget): New property accessor.
(isFrameDocument): New property accessor.
(processHTMLFrameHyperlinkEvent): Implemented.
(setFrameDocument): New property accessor.
(updateFrame): New helper method.
(updateFrameSet): New helper method.
* javax/swing/text/html/HTMLEditorKit.java
(LinkController.createHyperlinkEvent): Handle frame documents.
(autoFormSubmission): New field.
(HTMLEditorKit): Set autoFormSubmission to true.
(isAutoFormSubmission): New property accessor.
(setAutoFormSubmission): New property accessor.
Diffstat (limited to 'javax/swing/text/html/HTMLEditorKit.java')
-rw-r--r-- | javax/swing/text/html/HTMLEditorKit.java | 70 |
1 files changed, 65 insertions, 5 deletions
diff --git a/javax/swing/text/html/HTMLEditorKit.java b/javax/swing/text/html/HTMLEditorKit.java index 3f55e2dac..78b5df99f 100644 --- a/javax/swing/text/html/HTMLEditorKit.java +++ b/javax/swing/text/html/HTMLEditorKit.java @@ -243,10 +243,25 @@ public class HTMLEditorKit { url = null; } - // TODO: Handle frame documents and target here. - HyperlinkEvent ev = - new HyperlinkEvent(editor, HyperlinkEvent.EventType.ACTIVATED, url, - href, el); + HyperlinkEvent ev; + if (doc.isFrameDocument()) + { + String target = null; + if (anchor != null) + target = (String) anchor.getAttribute(HTML.Attribute.TARGET); + if (target == null || target.equals("")) + target = doc.getBaseTarget(); + if (target == null || target.equals("")) + target = "_self"; + ev = new HTMLFrameHyperlinkEvent(editor, + HyperlinkEvent.EventType.ACTIVATED, + url, href, el, target); + } + else + { + ev = new HyperlinkEvent(editor, HyperlinkEvent.EventType.ACTIVATED, + url, href, el); + } return ev; } } @@ -1065,13 +1080,22 @@ public class HTMLEditorKit /** The editor pane used. */ JEditorPane editorPane; - + + /** + * Whether or not the editor kit handles form submissions. + * + * @see #isAutoFormSubmission() + * @see #setAutoFormSubmission(boolean) + */ + private boolean autoFormSubmission; + /** * Constructs an HTMLEditorKit, creates a StyleContext, and loads the style sheet. */ public HTMLEditorKit() { linkController = new LinkController(); + autoFormSubmission = true; } /** @@ -1415,4 +1439,40 @@ public class HTMLEditorKit { styleSheet = s; } + + /** + * Returns <code>true</code> when forms should be automatically submitted + * by the editor kit. Set this to <code>false</code> when you want to + * intercept form submission. In this case you'd want to listen for + * hyperlink events on the document and handle FormSubmitEvents specially. + * + * The default is <code>true</code>. + * + * @return <code>true</code> when forms should be automatically submitted + * by the editor kit, <code>false</code> otherwise + * + * @since 1.5 + * + * @see #setAutoFormSubmission(boolean) + * @see FormSubmitEvent + */ + public boolean isAutoFormSubmission() + { + return autoFormSubmission; + } + + /** + * Sets whether or not the editor kit should automatically submit forms. + * + * @param auto <code>true</code> when the editor kit should handle form + * submission, <code>false</code> otherwise + * + * @since 1.5 + * + * @see #isAutoFormSubmission() + */ + public void setAutoFormSubmission(boolean auto) + { + autoFormSubmission = auto; + } } |