Package org.xhtmlrenderer.demo.browser
Class PanelManager
java.lang.Object
org.xhtmlrenderer.swing.DelegatingUserAgent
org.xhtmlrenderer.demo.browser.PanelManager
- All Implemented Interfaces:
DocumentListener
,UserAgentCallback
PanelManager is a UserAgentCallback responsible for the Browser's resource (XML, image, CSS) lookup. Most of the
power is in the NaiveUserAgent; the PanelManager adds support for the demo:, file: and demoNav: protocols,
and keeps track of the history of visited links. There is always a "current" link, and one can use the
getBack()
, getForward()
and hasForward()
methods to navigate within the history.
As a NaiveUserAgent, the PanelManager is also a DocumentListener, but must be added to the source of document
events (like a RootPanel subclass).-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBack()
Returns the "previous" URI in the history of visiting URIs.Returns the "next" URI in the history of visiting URIs.private XMLResource
Used internally when a document can't be loaded--returns XHTML as an XMLResource indicating that fact.@NonNull XMLResource
getXMLResource
(String uri) Retrieves the XML located at the given URI.boolean
hasBack()
Returns true if there are visited URIs in history "before" the pointer the current URI.boolean
Returns true if there are visited URIs in history "after" the pointer the current URI.boolean
Returns true if the link has been visited by the user in this session.@Nullable String
resolveURI
(@Nullable String uri) Resolves the URI; if absolute, leaves as is, if relative, returns an absolute URI based on the baseUrl for the agent.void
setBaseURL
(@Nullable String url) URL relative to which URIs are resolved.Methods inherited from class org.xhtmlrenderer.swing.DelegatingUserAgent
clearImageCache, documentLoaded, documentStarted, getBaseURL, getBinaryResource, getCSSResource, getImageResource, onLayoutException, onRenderException, resolveAndOpenStream, setImageResourceLoader, setRepaintListener, shrinkImageCache
-
Field Details
-
index
private int index -
history
-
-
Constructor Details
-
PanelManager
public PanelManager()
-
-
Method Details
-
resolveURI
Description copied from class:DelegatingUserAgent
Resolves the URI; if absolute, leaves as is, if relative, returns an absolute URI based on the baseUrl for the agent.- Specified by:
resolveURI
in interfaceUserAgentCallback
- Overrides:
resolveURI
in classDelegatingUserAgent
- Parameters:
uri
- A URI, possibly relative.- Returns:
- A URI as String, resolved, or null if there was an exception (for example if the URI is malformed).
-
getXMLResource
Description copied from class:DelegatingUserAgent
Retrieves the XML located at the given URI. It's assumed the URI does point to XML--the URI will be accessed (using java.io or java.net), opened, read and then passed into the XML parser (XMLReader) configured for Flying Saucer. The result is packed up into an XMLResource for later consumption.- Specified by:
getXMLResource
in interfaceUserAgentCallback
- Overrides:
getXMLResource
in classDelegatingUserAgent
- Parameters:
uri
- Location of the XML source.- Returns:
- An XMLResource containing the image.
-
getNotFoundDocument
Used internally when a document can't be loaded--returns XHTML as an XMLResource indicating that fact.- Parameters:
uri
- The URI which could not be loaded.- Returns:
- An XMLResource containing XML which about the failure.
-
isVisited
Returns true if the link has been visited by the user in this session. Visit tracking is not persisted.- Specified by:
isVisited
in interfaceUserAgentCallback
- Overrides:
isVisited
in classDelegatingUserAgent
- Parameters:
uri
- A URI which might have been visited.- Returns:
- Always false; visits are not tracked in the NaiveUserAgent.
-
setBaseURL
Description copied from class:DelegatingUserAgent
URL relative to which URIs are resolved.- Specified by:
setBaseURL
in interfaceUserAgentCallback
- Overrides:
setBaseURL
in classDelegatingUserAgent
- Parameters:
url
- A URI which anchors other, possibly relative URIs.
-
getForward
Returns the "next" URI in the history of visiting URIs. Advances the URI tracking (as if browser "forward" was used). -
getBack
Returns the "previous" URI in the history of visiting URIs. Moves the URI tracking back (as if browser "back" was used). -
hasForward
public boolean hasForward()Returns true if there are visited URIs in history "after" the pointer the current URI. This would be the case if multiple URIs were visited and the getBack() had been called at least once. -
hasBack
public boolean hasBack()Returns true if there are visited URIs in history "before" the pointer the current URI. This would be the case if multiple URIs were visited and the current URI pointer was not at the beginning of the visited URI list.
-