Class TreeWidget

java.lang.Object
net.ontopia.topicmaps.nav2.utils.TreeWidget

public class TreeWidget extends Object
PUBLIC: This class can output a nice collapsing/expanding tree view of a topic map which uses tolog queries to produce the tree. The class is configurable in various ways, and can also be subclassed to further fine-tune the rendering.
Since:
2.1
  • Field Details

  • Constructor Details

    • TreeWidget

      public TreeWidget()
      PUBLIC: Sets up the widget ready for use. The default constructor must be accompanied by the appropriate setter methods.
    • TreeWidget

      public TreeWidget(TopicMapIF topicmap, String query, String topquery, String ownpage, String nodepage)
      PUBLIC: Sets up the widget ready for use.
      Parameters:
      topicmap - The topic map being displayed.
      query - A tolog query that given a node generates its children. Use the %parent% parameter to reference the parent node in the query. Make sure the query produces a 1-column result.
      topquery - A tolog query that generates the list of top nodes. Make sure the query produces a 1-column result.
      ownpage - The URL of the page the widget is on. The widget will append request parameters in the form "a=b&c=d&e=f..."
      nodepage - The URL of of the page that shows the nodes.
  • Method Details

    • setTopicMap

      public void setTopicMap(TopicMapIF topicmap)
      PUBLIC: Sets the topic map used by the widget.
    • setWidgetName

      public void setWidgetName(String name)
      PUBLIC: The name of the session key in which the set of open nodes is stored. Using the same session key for different widgets will make them share open/closed information.
    • setTopQueryString

      public void setTopQueryString(String topQuery)
      PUBLIC: Sets the tolog query that generates the list of top nodes. Make sure the query produces a 1-column result.
    • setNodeQueryString

      public void setNodeQueryString(String nodeQuery)
      PUBLIC: Sets the tolog query that given a node generates its children. Use the %parent% parameter to reference the parent node in the query. Make sure the query produces a 1-column result.
    • setOwnPageUrl

      public void setOwnPageUrl(String ownPageUrl)
      PUBLIC: The URL of the page the widget is on. The widget will append request parameters in the form "a=b&c=d&e=f..."
    • setNodePageUrl

      public void setNodePageUrl(String nodePageUrl)
      PUBLIC: The URL of of the page that shows the nodes.
    • setImageUrl

      public void setImageUrl(String imageurl)
      PUBLIC: The URL at which the graphics used by the widget are found. The widget will produce HTML like <img src="[imageurl]spacer.gif"> to refer to the graphics.
    • setAddAnchor

      public void setAddAnchor(boolean addAnchor)
      PUBLIC: If set to true the widget will add anchors on all links that open/close nodes in the tree. The default is true.
    • setWindowSize

      public void setWindowSize(int windowSize)
      PUBLIC: Sets the maximum number of nodes displayed by the widget at once. If the number of nodes to display exceeds the maximum the widget will break the display into multiple "pages".
    • setNodeFrame

      public void setNodeFrame(String nodeFrame)
      PUBLIC: The name of the HTML frame in which to open links to nodes.
    • run

      public void run(javax.servlet.jsp.PageContext ctxt, Writer writer) throws IOException, InvalidQueryException, NavigatorRuntimeException
      PUBLIC: Runs the widget, producing the output.
      Throws:
      IOException
      InvalidQueryException
      NavigatorRuntimeException
    • run

      public void run(javax.servlet.http.HttpServletRequest request, Writer writer) throws IOException, InvalidQueryException, NavigatorRuntimeException
      PUBLIC: Runs the widget, producing the output.
      Throws:
      IOException
      InvalidQueryException
      NavigatorRuntimeException
      Since:
      2.2.1
    • parseQueries

      protected void parseQueries() throws InvalidQueryException
      Throws:
      InvalidQueryException
    • initializeContext

      protected void initializeContext(javax.servlet.http.HttpServletRequest request)
    • buildTree

      protected TopicTreeNode buildTree() throws InvalidQueryException
      Throws:
      InvalidQueryException
    • getChildren

      protected QueryResultIF getChildren(TopicIF topic) throws InvalidQueryException
      Throws:
      InvalidQueryException
    • process

      protected void process(TopicTreeNode parent) throws InvalidQueryException
      Throws:
      InvalidQueryException
    • renderTree

      protected void renderTree(TopicTreeNode node, int topline, Writer writer) throws IOException
      Throws:
      IOException
    • writeNode

      protected int writeNode(TopicTreeNode node, int topline, Writer writer, int level, int lineno, boolean indoc) throws IOException
      Throws:
      IOException
    • getId

      protected String getId(TopicIF topic)
    • getObjectById

      protected TMObjectIF getObjectById(String id)
    • getTopic

      protected TopicIF getTopic(String id)
    • list

      protected String list(Set nodes)
    • toString

      public String toString(TopicIF topic)
    • renderNode

      protected void renderNode(TopicTreeNode node, Writer out) throws IOException
      PUBLIC: This method renders the tree node, including its link, but not the button in front of the node. Intended to be overridden by applications wanting to control rendering of nodes in detail.
      Throws:
      IOException
    • renderNodeButton

      protected void renderNodeButton(int topline, int level, int action, String id, Writer out) throws IOException
      PUBLIC: Renders the +/- button in front of the node. Intended to be overridden.
      Throws:
      IOException
    • renderBackButton

      protected void renderBackButton(Writer out, int topline) throws IOException
      PUBLIC: Renders the back button at the top/bottom of the form.
      Throws:
      IOException
    • renderExpandAllButton

      protected void renderExpandAllButton(Writer out, int topline) throws IOException
      PUBLIC: Renders the expand all button at the top/bottom of the form.
      Throws:
      IOException
    • renderCloseAllButton

      protected void renderCloseAllButton(Writer out, int topline) throws IOException
      PUBLIC: Renders the close all button at the top/bottom of the form.
      Throws:
      IOException
    • renderForwardButton

      protected void renderForwardButton(Writer out, int topline) throws IOException
      PUBLIC: Renders the close all button at the top/bottom of the form.
      Throws:
      IOException
    • renderAdditionalOnTopExpandCloseLine

      protected void renderAdditionalOnTopExpandCloseLine(Writer out, int topline) throws IOException
      PUBLIC: Performs any additional rendering on the top line of the open-all and close-all buttons. Intended to be implemented by any sub-classes that need to do such additional rendering.
      Throws:
      IOException
    • renderAdditionalOnBottomExpandCloseLine

      protected void renderAdditionalOnBottomExpandCloseLine(Writer out, int topline) throws IOException
      PUBLIC: Performs any additional rendering on the bottom line of the open-all and close-all buttons. Intended to be implemented by any sub-classes that need to do such additional rendering.
      Throws:
      IOException
    • startRender

      protected void startRender(Writer out) throws IOException
      PUBLIC: Called before rendering of the tree begins.
      Throws:
      IOException
    • endRender

      protected void endRender(Writer out) throws IOException
      PUBLIC: Called after the tree has been rendered.
      Throws:
      IOException
    • makeNodeUrl

      protected String makeNodeUrl(TopicTreeNode node)
      PUBLIC: Produces the URL to the given node.
      Since:
      3.0