|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.lobobrowser.html.test.SimpleHtmlRendererContext
public class SimpleHtmlRendererContext
The SimpleHtmlRendererContext class implements
the HtmlRendererContext interface.
Note that this class provides rudimentary implementations
of most callback methods. Overridding some of the methods
in this class will usually be necessary in a professional application.
A simple way to load a URL into the HtmlPanel of the
renderer context is to invoke navigate(String).
| Field Summary | |
|---|---|
protected java.net.URLConnection |
currentConnection
The connection currently opened by openSync() if any. |
| Constructor Summary | |
|---|---|
SimpleHtmlRendererContext(HtmlPanel contextComponent)
Deprecated. Use constructor that takes HtmlPanel and UserAgentContext |
|
SimpleHtmlRendererContext(HtmlPanel contextComponent,
HtmlRendererContext parentRcontext)
Constructs a SimpleHtmlRendererContext that is a child of another . |
|
SimpleHtmlRendererContext(HtmlPanel contextComponent,
UserAgentContext ucontext)
Constructs a SimpleHtmlRendererContext. |
|
| Method Summary | |
|---|---|
void |
alert(java.lang.String message)
Opens a simple message dialog. |
void |
back()
It should navigate back one page. |
void |
blur()
It should give up focus on the current browser window. |
void |
close()
It should close the current browser window. |
boolean |
confirm(java.lang.String message)
Opens a simple confirmation window. |
BrowserFrame |
createBrowserFrame()
Creates a BrowserFrame instance. |
protected HTMLDocumentImpl |
createDocument(org.xml.sax.InputSource inputSource)
Creates a blank document instance. |
void |
error(java.lang.String message)
|
void |
error(java.lang.String message,
java.lang.Throwable throwable)
|
void |
focus()
It should request focus for the current browser window. |
void |
forward()
Goes forward one page. |
java.lang.String |
getCurrentURL()
Gets the current URL in history. |
java.lang.String |
getDefaultStatus()
Should return true if and only if the current browser window is closed. |
protected java.lang.String |
getDocumentCharset(java.net.URLConnection connection)
This method is invoked by submitForm(String, URL, String, String, FormInput[])
to determine the charset of a document. |
org.w3c.dom.html2.HTMLCollection |
getFrames()
Gets a collection of current document frames, by querying the document currently held by the local HtmlPanel
instance. |
int |
getHistoryLength()
Gets the number of pages in the history list. |
HtmlObject |
getHtmlObject(org.w3c.dom.html2.HTMLElement element)
Returns null. |
HtmlPanel |
getHtmlPanel()
|
java.lang.String |
getName()
It should return the name of the browser window, if this renderer context is for the top frame in the window. |
java.lang.String |
getNextURL()
Gets the next URL in the history. |
HtmlRendererContext |
getOpener()
Gets the opener of the frame/window in the current context. |
HtmlRendererContext |
getParent()
Gets the parent of the frame/window in the current context. |
java.lang.String |
getPreviousURL()
Gets the previous URL in the history. |
protected java.net.Proxy |
getProxy()
Gets the connection proxy used in navigate(URL, String). |
java.lang.String |
getSourceCode()
Gets the source code of the current HTML document. |
java.lang.String |
getStatus()
Gets the window status text. |
HtmlRendererContext |
getTop()
Gets the top-most browser frame/window. |
UserAgentContext |
getUserAgentContext()
If a UserAgentContext instance
was provided in the constructor, then that instance is returned. |
void |
goToHistoryURL(java.lang.String url)
Navigates to a URL in the history list. |
boolean |
isClosed()
Should return true if and only if the current browser window is closed. |
boolean |
isImageLoadingEnabled()
This method should return true if and only if image loading needs to be enabled. |
protected boolean |
isNavigationAsynchronous()
Indicates whether navigation (via submitForm(String, URL, String, String, FormInput[])) should be asynchronous. |
boolean |
isVisitedLink(org.w3c.dom.html2.HTMLLinkElement link)
Should be overridden to return true if the link has been visited. |
void |
linkClicked(org.w3c.dom.html2.HTMLElement linkNode,
java.net.URL url,
java.lang.String target)
Implements the link click handler by invoking navigate(URL, String). |
void |
moveInHistory(int offset)
Navigates the history according to the given offset. |
void |
navigate(java.lang.String fullURL)
Convenience method provided to allow loading a document into the renderer. |
void |
navigate(java.net.URL href,
java.lang.String target)
Implements simple navigation with incremental rendering by invoking submitForm(String, URL, String, String, FormInput[])
with a GET request method. |
boolean |
onContextMenu(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
This method must be overridden to implement a context menu. |
boolean |
onDoubleClick(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
This method is called when there's a mouse double-click on an element. |
boolean |
onMouseClick(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
This method is called when there's a mouse click on an element. |
void |
onMouseOut(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
This method can be overridden to receive notifications when the mouse leaves an element. |
void |
onMouseOver(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
This method can be overridden to receive notifications when the mouse first enters an element. |
HtmlRendererContext |
open(java.lang.String url,
java.lang.String windowName,
java.lang.String windowFeatures,
boolean replace)
Deprecated. Use open(URL, String, String, boolean). |
HtmlRendererContext |
open(java.net.URL url,
java.lang.String windowName,
java.lang.String windowFeatures,
boolean replace)
It should open a new browser window. |
java.lang.String |
prompt(java.lang.String message,
java.lang.String inputDefault)
Shows a simple prompt dialog. |
void |
reload()
Implements reload as navigation to current URL. |
void |
resizeBy(int byWidth,
int byHeight)
Resizes the window. |
void |
resizeTo(int width,
int height)
Resizes the window. |
void |
scroll(int x,
int y)
Changes the origin of the HTML block's scrollable area according to the position given. |
void |
scrollBy(int x,
int y)
Scrolls the client area. |
void |
setDefaultStatus(java.lang.String message)
|
void |
setOpener(HtmlRendererContext opener)
Sets the context that opened the current frame/window. |
void |
setStatus(java.lang.String message)
Sets the window status text. |
void |
submitForm(java.lang.String method,
java.net.URL action,
java.lang.String target,
java.lang.String enctype,
FormInput[] formInputs)
Implements simple navigation and form submission with incremental rendering and target processing, including frame lookup. |
protected void |
submitFormSync(java.lang.String method,
java.net.URL action,
java.lang.String target,
java.lang.String enctype,
FormInput[] formInputs)
Submits a form and/or navigates by making a synchronous request. |
void |
warn(java.lang.String message)
|
void |
warn(java.lang.String message,
java.lang.Throwable throwable)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.net.URLConnection currentConnection
| Constructor Detail |
|---|
public SimpleHtmlRendererContext(HtmlPanel contextComponent)
HtmlPanel and UserAgentContext
contextComponent - The component that will render HTML.
public SimpleHtmlRendererContext(HtmlPanel contextComponent,
UserAgentContext ucontext)
contextComponent - The component that will render HTML.SimpleUserAgentContext
public SimpleHtmlRendererContext(HtmlPanel contextComponent,
HtmlRendererContext parentRcontext)
HtmlRendererContext.
contextComponent - The component that will render HTML.parentRcontext - The parent's renderer context.| Method Detail |
|---|
public HtmlPanel getHtmlPanel()
public java.lang.String getSourceCode()
public org.w3c.dom.html2.HTMLCollection getFrames()
HtmlPanel
instance.
getFrames in interface HtmlRendererContextpublic void reload()
reload in interface HtmlRendererContext
public void linkClicked(org.w3c.dom.html2.HTMLElement linkNode,
java.net.URL url,
java.lang.String target)
navigate(URL, String).
linkClicked in interface HtmlRendererContextlinkNode - The HTML node that was clicked.url - The destination URL.target - Same as the target attribute in the HTML anchor tag, i.e. _top, _blank, etc.protected java.net.Proxy getProxy()
navigate(URL, String).
This implementation calls SimpleUserAgentContext.getProxy()
if getUserAgentContext() returns an instance assignable to SimpleUserAgentContext.
The method may be overridden to provide a different proxy setting.
public void navigate(java.net.URL href,
java.lang.String target)
submitForm(String, URL, String, String, FormInput[])
with a GET request method.
navigate in interface HtmlRendererContexthref - The destination URL.target - Same as the target attribute in the HTML anchor tag, i.e. _top, _blank, etc.
public void navigate(java.lang.String fullURL)
throws java.net.MalformedURLException
fullURL - The absolute URL of the document.
java.net.MalformedURLExceptionnavigate(URL, String)
public void submitForm(java.lang.String method,
java.net.URL action,
java.lang.String target,
java.lang.String enctype,
FormInput[] formInputs)
Notes:
getDocumentCharset(URLConnection).
application/x-www-form-urlencoded.
isNavigationAsynchronous().
submitForm in interface HtmlRendererContextmethod - The request method, GET or POST.action - The destination URL.target - Same as the target attribute in the FORM tag, i.e. _blank, _top, etc.enctype - The encoding type.formInputs - An array of FormInput instances.navigate(URL, String)protected boolean isNavigationAsynchronous()
submitForm(String, URL, String, String, FormInput[])) should be asynchronous.
This overridable implementation returns true.
protected void submitFormSync(java.lang.String method,
java.net.URL action,
java.lang.String target,
java.lang.String enctype,
FormInput[] formInputs)
throws java.io.IOException,
org.xml.sax.SAXException
submitForm(String, URL, String, String, FormInput[]).
method - The request method.action - The action URL.target - The target identifier.enctype - The encoding type.formInputs - The form inputs.
java.io.IOException
org.xml.sax.SAXExceptionsubmitForm(String, URL, String, String, FormInput[])
protected HTMLDocumentImpl createDocument(org.xml.sax.InputSource inputSource)
throws java.io.IOException,
org.xml.sax.SAXException
inputSource - The document input source.
java.io.IOException
org.xml.sax.SAXExceptionprotected java.lang.String getDocumentCharset(java.net.URLConnection connection)
submitForm(String, URL, String, String, FormInput[])
to determine the charset of a document. The charset is determined by looking
at the Content-Type header.
connection - A URL connection.public void alert(java.lang.String message)
alert in interface HtmlRendererContextmessage - Message shown by the dialog.public void blur()
blur in interface HtmlRendererContextpublic void close()
close in interface HtmlRendererContextpublic boolean confirm(java.lang.String message)
confirm in interface HtmlRendererContextmessage - The message shown by the confirmation dialog.
public void focus()
focus in interface HtmlRendererContext
public final HtmlRendererContext open(java.lang.String url,
java.lang.String windowName,
java.lang.String windowFeatures,
boolean replace)
open(URL, String, String, boolean).
HtmlRendererContext
open in interface HtmlRendererContexturl - The URL to be rendered.windowName - The name of the new window.windowFeatures - The features of the new window (same as in Javascript open method).
HtmlRendererContext instance.
public HtmlRendererContext open(java.net.URL url,
java.lang.String windowName,
java.lang.String windowFeatures,
boolean replace)
open in interface HtmlRendererContexturl - The requested URL.windowName - A window identifier.windowFeatures - Window features specified in a format equivalent to
that of window.open() in Javascript.replace - Whether an existing window with the same name should be replaced.
HtmlRendererContext instance.
public java.lang.String prompt(java.lang.String message,
java.lang.String inputDefault)
prompt in interface HtmlRendererContextmessage - The message shown by the dialog.inputDefault - The default input value.
public void scroll(int x,
int y)
This method may be called outside of the GUI thread. The operation is scheduled immediately in that thread as needed.
scroll in interface HtmlRendererContextx - The new x coordinate for the origin.y - The new y coordinate for the origin.
public void scrollBy(int x,
int y)
HtmlRendererContext
scrollBy in interface HtmlRendererContextx - Horizontal pixels to scroll.y - Vertical pixels to scroll.public boolean isClosed()
isClosed in interface HtmlRendererContextpublic java.lang.String getDefaultStatus()
getDefaultStatus in interface HtmlRendererContextpublic java.lang.String getName()
getName in interface HtmlRendererContextpublic HtmlRendererContext getParent()
HtmlRendererContext
getParent in interface HtmlRendererContextpublic HtmlRendererContext getOpener()
HtmlRendererContext
getOpener in interface HtmlRendererContextpublic void setOpener(HtmlRendererContext opener)
HtmlRendererContext
setOpener in interface HtmlRendererContextopener - A HtmlRendererContext.public java.lang.String getStatus()
HtmlRendererContext
getStatus in interface HtmlRendererContextpublic void setStatus(java.lang.String message)
HtmlRendererContext
setStatus in interface HtmlRendererContextmessage - A string.public HtmlRendererContext getTop()
HtmlRendererContext
getTop in interface HtmlRendererContextpublic BrowserFrame createBrowserFrame()
HtmlRendererContextBrowserFrame instance.
createBrowserFrame in interface HtmlRendererContext
public void warn(java.lang.String message,
java.lang.Throwable throwable)
public void error(java.lang.String message,
java.lang.Throwable throwable)
public void warn(java.lang.String message)
public void error(java.lang.String message)
public HtmlObject getHtmlObject(org.w3c.dom.html2.HTMLElement element)
null. This method should be overridden
to provide OBJECT, EMBED or APPLET functionality.
getHtmlObject in interface HtmlRendererContextelement - The DOM element for the object, which may
either represent an OBJECT, EMBED or an APPLET tag.
null
if they have any problems producing a HtmlObject instance.
This is particularly true of OBJECT tags, where inner HTML of
the tag must be rendered if the OBJECT content cannot be handled.public void setDefaultStatus(java.lang.String message)
setDefaultStatus in interface HtmlRendererContextpublic UserAgentContext getUserAgentContext()
UserAgentContext instance
was provided in the constructor, then that instance is returned.
Otherwise, an instance of SimpleUserAgentContext is
created and returned.
The context returned by this method is used by local request facilities and other parts of the renderer.
getUserAgentContext in interface HtmlRendererContextpublic boolean isVisitedLink(org.w3c.dom.html2.HTMLLinkElement link)
isVisitedLink in interface HtmlRendererContext
public boolean onContextMenu(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
onContextMenu in interface HtmlRendererContextelement - The narrowest element enclosing the mouse location.event - The mouse event.
public void onMouseOut(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
onMouseOut in interface HtmlRendererContextelement - The element that the mouse has just exited.event - The mouse event.
public void onMouseOver(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
onMouseOver in interface HtmlRendererContextelement - The element that the mouse has just entered.event - The mouse event.public boolean isImageLoadingEnabled()
HtmlRendererContext
isImageLoadingEnabled in interface HtmlRendererContext
public boolean onDoubleClick(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
HtmlRendererContext
onDoubleClick in interface HtmlRendererContextelement - The narrowest element enclosing the mouse location.event - The mouse event.
public boolean onMouseClick(org.w3c.dom.html2.HTMLElement element,
java.awt.event.MouseEvent event)
HtmlRendererContext
onMouseClick in interface HtmlRendererContextelement - The narrowest element enclosing the mouse location.event - The mouse event.
public void resizeBy(int byWidth,
int byHeight)
HtmlRendererContext
resizeBy in interface HtmlRendererContextbyWidth - The number of pixels to resize the width by.byHeight - The number of pixels to resize the height by.
public void resizeTo(int width,
int height)
HtmlRendererContext
resizeTo in interface HtmlRendererContextwidth - The new width.height - The new height.public void back()
back in interface HtmlRendererContextpublic void forward()
HtmlRendererContext
forward in interface HtmlRendererContextpublic java.lang.String getCurrentURL()
HtmlRendererContext
getCurrentURL in interface HtmlRendererContextpublic int getHistoryLength()
HtmlRendererContext
getHistoryLength in interface HtmlRendererContextpublic java.lang.String getNextURL()
HtmlRendererContext
getNextURL in interface HtmlRendererContextpublic java.lang.String getPreviousURL()
HtmlRendererContext
getPreviousURL in interface HtmlRendererContextpublic void goToHistoryURL(java.lang.String url)
HtmlRendererContext
goToHistoryURL in interface HtmlRendererContextpublic void moveInHistory(int offset)
HtmlRendererContext
moveInHistory in interface HtmlRendererContextoffset - A positive or negative number. -1 is
equivalent to HtmlRendererContext.back(). +1 is
equivalent to HtmlRendererContext.forward().
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||