Package org.lobobrowser.html
Interface HtmlRendererContext
-
- All Known Implementing Classes:
AbstractHtmlRendererContext,SimpleHtmlRendererContext
public interface HtmlRendererContextTheHtmlRendererContextinterface must be implemented in order to use the Cobra HTML renderer. An instance of this interface will be called back whenever the renderer needs to perform an action that it is not designed to know how to perform on its own, e.g. opening a browser window or a context menu. In many ways this interface parallers the JavascriptWindowclass (which in reality represents a browser frame, not a window).A simple implementation of this interface is provided in
SimpleHtmlRendererContext.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidalert(java.lang.String message)Opens an alert dialog.voidback()Goes to the previous page in the browser's history.voidblur()Relinquishes focus.voidclose()Closes the browser window, provided this is allowed for the current context.booleanconfirm(java.lang.String message)Opens a confirmation dialog.BrowserFramecreateBrowserFrame()Creates aBrowserFrameinstance.voidfocus()Requests focus for the current window.voidforward()Goes forward one page.java.lang.StringgetCurrentURL()Gets the current URL in history.java.lang.StringgetDefaultStatus()HTMLCollectiongetFrames()Gets a collection of frames from the document currently in the context.intgetHistoryLength()Gets the number of pages in the history list.HtmlObjectgetHtmlObject(HTMLElement element)Gets aHtmlObjectinstance that implements a OBJECT tag from HTML.java.lang.StringgetName()Gets the window name.java.lang.StringgetNextURL()Gets the next URL in the history.HtmlRendererContextgetOpener()Gets the opener of the frame/window in the current context.HtmlRendererContextgetParent()Gets the parent of the frame/window in the current context.java.lang.StringgetPreviousURL()Gets the previous URL in the history.java.lang.StringgetStatus()Gets the window status text.HtmlRendererContextgetTop()Gets the top-most browser frame/window.UserAgentContextgetUserAgentContext()Gets the user agent context.voidgoToHistoryURL(java.lang.String url)Navigates to a URL in the history list.booleanisClosed()Gets a value indicating if the window is closed.booleanisImageLoadingEnabled()This method should return true if and only if image loading needs to be enabled.booleanisVisitedLink(HTMLLinkElement link)It should return true if the link provided has been visited.voidlinkClicked(HTMLElement linkNode, java.net.URL url, java.lang.String target)Performs a link click.voidmoveInHistory(int offset)Navigates the history according to the given offset.voidnavigate(java.net.URL url, java.lang.String target)Navigates to the location given.booleanonContextMenu(HTMLElement element, java.awt.event.MouseEvent event)This method is called when a visual element is right-clicked.booleanonDoubleClick(HTMLElement element, java.awt.event.MouseEvent event)This method is called when there's a mouse double-click on an element.booleanonMouseClick(HTMLElement element, java.awt.event.MouseEvent event)This method is called when there's a mouse click on an element.voidonMouseOut(HTMLElement element, java.awt.event.MouseEvent event)This method is called when the mouse no longer hovers a given element.voidonMouseOver(HTMLElement element, java.awt.event.MouseEvent event)This method is called when the mouse first hovers over an element.HtmlRendererContextopen(java.lang.String absoluteUrl, java.lang.String windowName, java.lang.String windowFeatures, boolean replace)Deprecated.Useopen(URL, String, String, boolean)instead.HtmlRendererContextopen(java.net.URL url, java.lang.String windowName, java.lang.String windowFeatures, boolean replace)Opens a separate browser window and renders a URL.java.lang.Stringprompt(java.lang.String message, java.lang.String inputDefault)Shows a prompt dialog.voidreload()Reloads the current document.voidresizeBy(int byWidth, int byHeight)Resizes the window.voidresizeTo(int width, int height)Resizes the window.voidscroll(int x, int y)Scrolls the client area.voidscrollBy(int x, int y)Scrolls the client area.voidsetDefaultStatus(java.lang.String value)voidsetOpener(HtmlRendererContext opener)Sets the context that opened the current frame/window.voidsetStatus(java.lang.String message)Sets the window status text.voidsubmitForm(java.lang.String method, java.net.URL action, java.lang.String target, java.lang.String enctype, FormInput[] formInputs)Submits a HTML form.
-
-
-
Method Detail
-
navigate
void navigate(java.net.URL url, java.lang.String target)Navigates to the location given. Implementations should retrieve the URL content, parse it and render it.- Parameters:
url- The destination URL.target- Same as the target attribute in the HTML anchor tag, i.e. _top, _blank, etc.
-
linkClicked
void linkClicked(HTMLElement linkNode, java.net.URL url, java.lang.String target)
Performs a link click. Implementations should invokenavigate(URL, String).- Parameters:
linkNode- 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.
-
getFrames
HTMLCollection getFrames()
Gets a collection of frames from the document currently in the context.
-
submitForm
void submitForm(java.lang.String method, java.net.URL action, java.lang.String target, java.lang.String enctype, FormInput[] formInputs)Submits a HTML form. Note that when the the method is "GET", parameters are still expected to be part offormInputs.- Parameters:
method- 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 ofFormInputinstances.
-
createBrowserFrame
BrowserFrame createBrowserFrame()
Creates aBrowserFrameinstance.
-
getUserAgentContext
UserAgentContext getUserAgentContext()
Gets the user agent context.
-
getHtmlObject
HtmlObject getHtmlObject(HTMLElement element)
Gets aHtmlObjectinstance that implements a OBJECT tag from HTML.- Parameters:
element- The DOM element for the object, which may either represent an OBJECT, EMBED or an APPLET tag.- Returns:
- Implementations of this method must return
nullif they have any problems producing aHtmlObjectinstance. This is particularly true of OBJECT tags, where inner HTML of the tag must be rendered if the OBJECT content cannot be handled.
-
onContextMenu
boolean onContextMenu(HTMLElement element, java.awt.event.MouseEvent event)
This method is called when a visual element is right-clicked.- Parameters:
element- The narrowest element enclosing the mouse location.event- The mouse event.- Returns:
- The method should return true to continue propagating the event, or false to stop propagating it.
-
onMouseClick
boolean onMouseClick(HTMLElement element, java.awt.event.MouseEvent event)
This method is called when there's a mouse click on an element.- Parameters:
element- The narrowest element enclosing the mouse location.event- The mouse event.- Returns:
- The method should return true to continue propagating the event, or false to stop propagating it.
-
onDoubleClick
boolean onDoubleClick(HTMLElement element, java.awt.event.MouseEvent event)
This method is called when there's a mouse double-click on an element.- Parameters:
element- The narrowest element enclosing the mouse location.event- The mouse event.- Returns:
- The method should return true to continue propagating the event, or false to stop propagating it.
-
onMouseOver
void onMouseOver(HTMLElement element, java.awt.event.MouseEvent event)
This method is called when the mouse first hovers over an element.- Parameters:
element- The element that the mouse has just entered.event- The mouse event.
-
onMouseOut
void onMouseOut(HTMLElement element, java.awt.event.MouseEvent event)
This method is called when the mouse no longer hovers a given element.- Parameters:
element- The element that the mouse has just exited.event- The mouse event.
-
isImageLoadingEnabled
boolean isImageLoadingEnabled()
This method should return true if and only if image loading needs to be enabled.
-
alert
void alert(java.lang.String message)
Opens an alert dialog.- Parameters:
message- Message shown by the dialog.
-
back
void back()
Goes to the previous page in the browser's history.
-
blur
void blur()
Relinquishes focus.
-
close
void close()
Closes the browser window, provided this is allowed for the current context.
-
confirm
boolean confirm(java.lang.String message)
Opens a confirmation dialog.- Parameters:
message- The message shown by the confirmation dialog.- Returns:
- True if the user selects YES.
-
focus
void focus()
Requests focus for the current window.
-
open
HtmlRendererContext open(java.lang.String absoluteUrl, java.lang.String windowName, java.lang.String windowFeatures, boolean replace)
Deprecated.Useopen(URL, String, String, boolean)instead.Opens a separate browser window and renders a URL.- Parameters:
absoluteUrl- 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).replace-- Returns:
- A new
HtmlRendererContextinstance.
-
open
HtmlRendererContext open(java.net.URL url, java.lang.String windowName, java.lang.String windowFeatures, boolean replace)
Opens a separate browser window and renders a URL.- Parameters:
url- 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).replace-- Returns:
- A new
HtmlRendererContextinstance.
-
prompt
java.lang.String prompt(java.lang.String message, java.lang.String inputDefault)Shows a prompt dialog.- Parameters:
message- The message shown by the dialog.inputDefault- The default input value.- Returns:
- The user's input value.
-
scroll
void scroll(int x, int y)Scrolls the client area.- Parameters:
x- Document's x coordinate.y- Document's y coordinate.
-
scrollBy
void scrollBy(int x, int y)Scrolls the client area.- Parameters:
x- Horizontal pixels to scroll.y- Vertical pixels to scroll.
-
resizeTo
void resizeTo(int width, int height)Resizes the window.- Parameters:
width- The new width.height- The new height.
-
resizeBy
void resizeBy(int byWidth, int byHeight)Resizes the window.- Parameters:
byWidth- The number of pixels to resize the width by.byHeight- The number of pixels to resize the height by.
-
isClosed
boolean isClosed()
Gets a value indicating if the window is closed.
-
getDefaultStatus
java.lang.String getDefaultStatus()
-
setDefaultStatus
void setDefaultStatus(java.lang.String value)
-
getName
java.lang.String getName()
Gets the window name.
-
getParent
HtmlRendererContext getParent()
Gets the parent of the frame/window in the current context.
-
getOpener
HtmlRendererContext getOpener()
Gets the opener of the frame/window in the current context.
-
setOpener
void setOpener(HtmlRendererContext opener)
Sets the context that opened the current frame/window.- Parameters:
opener- AHtmlRendererContext.
-
getStatus
java.lang.String getStatus()
Gets the window status text.
-
setStatus
void setStatus(java.lang.String message)
Sets the window status text.- Parameters:
message- A string.
-
getTop
HtmlRendererContext getTop()
Gets the top-most browser frame/window.
-
isVisitedLink
boolean isVisitedLink(HTMLLinkElement link)
It should return true if the link provided has been visited.
-
reload
void reload()
Reloads the current document.
-
getHistoryLength
int getHistoryLength()
Gets the number of pages in the history list.
-
getCurrentURL
java.lang.String getCurrentURL()
Gets the current URL in history.
-
getNextURL
java.lang.String getNextURL()
Gets the next URL in the history.
-
getPreviousURL
java.lang.String getPreviousURL()
Gets the previous URL in the history.
-
forward
void forward()
Goes forward one page.
-
moveInHistory
void moveInHistory(int offset)
Navigates the history according to the given offset.
-
goToHistoryURL
void goToHistoryURL(java.lang.String url)
Navigates to a URL in the history list.
-
-