Class PanelManager

java.lang.Object
org.xhtmlrenderer.swing.DelegatingUserAgent
org.xhtmlrenderer.demo.browser.PanelManager
All Implemented Interfaces:
DocumentListener, UserAgentCallback

public class PanelManager extends DelegatingUserAgent
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 Details

    • index

      private int index
    • history

      private final List<String> history
  • Constructor Details

    • PanelManager

      public PanelManager()
  • Method Details

    • resolveURI

      @CheckReturnValue public @Nullable String resolveURI(@Nullable String uri)
      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 interface UserAgentCallback
      Overrides:
      resolveURI in class DelegatingUserAgent
      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

      public @NonNull XMLResource getXMLResource(String uri)
      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 interface UserAgentCallback
      Overrides:
      getXMLResource in class DelegatingUserAgent
      Parameters:
      uri - Location of the XML source.
      Returns:
      An XMLResource containing the image.
    • getNotFoundDocument

      private XMLResource getNotFoundDocument(String uri)
      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

      public boolean isVisited(@Nullable String uri)
      Returns true if the link has been visited by the user in this session. Visit tracking is not persisted.
      Specified by:
      isVisited in interface UserAgentCallback
      Overrides:
      isVisited in class DelegatingUserAgent
      Parameters:
      uri - A URI which might have been visited.
      Returns:
      Always false; visits are not tracked in the NaiveUserAgent.
    • setBaseURL

      public void setBaseURL(@Nullable String url)
      Description copied from class: DelegatingUserAgent
      URL relative to which URIs are resolved.
      Specified by:
      setBaseURL in interface UserAgentCallback
      Overrides:
      setBaseURL in class DelegatingUserAgent
      Parameters:
      url - A URI which anchors other, possibly relative URIs.
    • getForward

      public String getForward()
      Returns the "next" URI in the history of visiting URIs. Advances the URI tracking (as if browser "forward" was used).
    • getBack

      public String 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.