net.ontopia.topicmaps.nav2.utils
Class TreeWidget

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

public class TreeWidget
extends java.lang.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

Nested Class Summary
protected  class TreeWidget.UniversalSet
           
 
Field Summary
protected  java.util.Collection ancestors
           
protected static int CLOSE
           
protected static int CLOSE_ALL
           
protected  NavigatorPageIF context
           
protected static int EXPAND_ALL
           
protected  java.lang.String imageurl
           
protected  java.util.Map map
           
protected  java.lang.String nodeFrame
           
protected  java.lang.String nodepage
           
protected static int OPEN
           
protected  java.util.Set openNodes
           
protected  java.lang.String ownpage
           
protected  QueryProcessorIF processor
           
protected  ParsedQueryIF query
           
protected  java.lang.String staticurl
           
protected  TopicMapIF topicmap
           
protected  java.lang.String topquery
           
protected static int WINDOW_SIZE
           
protected  int windowSize
           
 
Constructor Summary
TreeWidget()
          PUBLIC: Sets up the widget ready for use.
TreeWidget(TopicMapIF topicmap, java.lang.String query, java.lang.String topquery, java.lang.String ownpage, java.lang.String nodepage)
          PUBLIC: Sets up the widget ready for use.
 
Method Summary
protected  TopicTreeNode buildTree()
           
protected  void endRender(java.io.Writer out)
          PUBLIC: Called after the tree has been rendered.
protected  QueryResultIF getChildren(TopicIF topic)
           
protected  java.lang.String getId(TopicIF topic)
           
protected  TMObjectIF getObjectById(java.lang.String id)
           
protected  TopicIF getTopic(java.lang.String id)
           
protected  void initializeContext(javax.servlet.http.HttpServletRequest request)
           
protected  java.lang.String list(java.util.Set nodes)
           
protected  java.lang.String makeNodeUrl(TopicTreeNode node)
          PUBLIC: Produces the URL to the given node.
protected  void parseQueries()
           
protected  void process(TopicTreeNode parent)
           
protected  void renderAdditionalOnBottomExpandCloseLine(java.io.Writer out, int topline)
          PUBLIC: Performs any additional rendering on the bottom line of the open-all and close-all buttons.
protected  void renderAdditionalOnTopExpandCloseLine(java.io.Writer out, int topline)
          PUBLIC: Performs any additional rendering on the top line of the open-all and close-all buttons.
protected  void renderBackButton(java.io.Writer out, int topline)
          PUBLIC: Renders the back button at the top/bottom of the form.
protected  void renderCloseAllButton(java.io.Writer out, int topline)
          PUBLIC: Renders the close all button at the top/bottom of the form.
protected  void renderExpandAllButton(java.io.Writer out, int topline)
          PUBLIC: Renders the expand all button at the top/bottom of the form.
protected  void renderForwardButton(java.io.Writer out, int topline)
          PUBLIC: Renders the close all button at the top/bottom of the form.
protected  void renderNode(TopicTreeNode node, java.io.Writer out)
          PUBLIC: This method renders the tree node, including its link, but not the button in front of the node.
protected  void renderNodeButton(int topline, int level, int action, java.lang.String id, java.io.Writer out)
          PUBLIC: Renders the +/- button in front of the node.
protected  void renderTree(TopicTreeNode node, int topline, java.io.Writer writer)
           
 void run(javax.servlet.http.HttpServletRequest request, java.io.Writer writer)
          PUBLIC: Runs the widget, producing the output.
 void run(javax.servlet.jsp.PageContext ctxt, java.io.Writer writer)
          PUBLIC: Runs the widget, producing the output.
 void setAddAnchor(boolean addAnchor)
          PUBLIC: If set to true the widget will add anchors on all links that open/close nodes in the tree.
 void setImageUrl(java.lang.String imageurl)
          PUBLIC: The URL at which the graphics used by the widget are found.
 void setNodeFrame(java.lang.String nodeFrame)
          PUBLIC: The name of the HTML frame in which to open links to nodes.
 void setNodePageUrl(java.lang.String nodePageUrl)
          PUBLIC: The URL of of the page that shows the nodes.
 void setNodeQueryString(java.lang.String nodeQuery)
          PUBLIC: Sets the tolog query that given a node generates its children.
 void setOwnPageUrl(java.lang.String ownPageUrl)
          PUBLIC: The URL of the page the widget is on.
 void setTopicMap(TopicMapIF topicmap)
          PUBLIC: Sets the topic map used by the widget.
 void setTopQueryString(java.lang.String topQuery)
          PUBLIC: Sets the tolog query that generates the list of top nodes.
 void setWidgetName(java.lang.String name)
          PUBLIC: The name of the session key in which the set of open nodes is stored.
 void setWindowSize(int windowSize)
          PUBLIC: Sets the maximum number of nodes displayed by the widget at once.
protected  void startRender(java.io.Writer out)
          PUBLIC: Called before rendering of the tree begins.
 java.lang.String toString(TopicIF topic)
           
protected  int writeNode(TopicTreeNode node, int topline, java.io.Writer writer, int level, int lineno, boolean indoc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN

protected static final int OPEN
See Also:
Constant Field Values

CLOSE

protected static final int CLOSE
See Also:
Constant Field Values

EXPAND_ALL

protected static final int EXPAND_ALL
See Also:
Constant Field Values

CLOSE_ALL

protected static final int CLOSE_ALL
See Also:
Constant Field Values

WINDOW_SIZE

protected static final int WINDOW_SIZE
See Also:
Constant Field Values

processor

protected QueryProcessorIF processor

nodepage

protected java.lang.String nodepage

staticurl

protected java.lang.String staticurl

openNodes

protected java.util.Set openNodes

imageurl

protected java.lang.String imageurl

windowSize

protected int windowSize

context

protected NavigatorPageIF context

ancestors

protected java.util.Collection ancestors

query

protected ParsedQueryIF query

topicmap

protected TopicMapIF topicmap

map

protected java.util.Map map

topquery

protected java.lang.String topquery

ownpage

protected java.lang.String ownpage

nodeFrame

protected java.lang.String nodeFrame
Constructor Detail

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,
                  java.lang.String query,
                  java.lang.String topquery,
                  java.lang.String ownpage,
                  java.lang.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 Detail

setTopicMap

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


setWidgetName

public void setWidgetName(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String nodePageUrl)
PUBLIC: The URL of of the page that shows the nodes.


setImageUrl

public void setImageUrl(java.lang.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(java.lang.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,
                java.io.Writer writer)
         throws java.io.IOException,
                InvalidQueryException,
                NavigatorRuntimeException
PUBLIC: Runs the widget, producing the output.

Throws:
java.io.IOException
InvalidQueryException
NavigatorRuntimeException

run

public void run(javax.servlet.http.HttpServletRequest request,
                java.io.Writer writer)
         throws java.io.IOException,
                InvalidQueryException,
                NavigatorRuntimeException
PUBLIC: Runs the widget, producing the output.

Throws:
java.io.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,
                          java.io.Writer writer)
                   throws java.io.IOException
Throws:
java.io.IOException

writeNode

protected int writeNode(TopicTreeNode node,
                        int topline,
                        java.io.Writer writer,
                        int level,
                        int lineno,
                        boolean indoc)
                 throws java.io.IOException
Throws:
java.io.IOException

getId

protected java.lang.String getId(TopicIF topic)

getObjectById

protected TMObjectIF getObjectById(java.lang.String id)

getTopic

protected TopicIF getTopic(java.lang.String id)

list

protected java.lang.String list(java.util.Set nodes)

toString

public java.lang.String toString(TopicIF topic)

renderNode

protected void renderNode(TopicTreeNode node,
                          java.io.Writer out)
                   throws java.io.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:
java.io.IOException

renderNodeButton

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

Throws:
java.io.IOException

renderBackButton

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

Throws:
java.io.IOException

renderExpandAllButton

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

Throws:
java.io.IOException

renderCloseAllButton

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

Throws:
java.io.IOException

renderForwardButton

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

Throws:
java.io.IOException

renderAdditionalOnTopExpandCloseLine

protected void renderAdditionalOnTopExpandCloseLine(java.io.Writer out,
                                                    int topline)
                                             throws java.io.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:
java.io.IOException

renderAdditionalOnBottomExpandCloseLine

protected void renderAdditionalOnBottomExpandCloseLine(java.io.Writer out,
                                                       int topline)
                                                throws java.io.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:
java.io.IOException

startRender

protected void startRender(java.io.Writer out)
                    throws java.io.IOException
PUBLIC: Called before rendering of the tree begins.

Throws:
java.io.IOException

endRender

protected void endRender(java.io.Writer out)
                  throws java.io.IOException
PUBLIC: Called after the tree has been rendered.

Throws:
java.io.IOException

makeNodeUrl

protected java.lang.String makeNodeUrl(TopicTreeNode node)
PUBLIC: Produces the URL to the given node.

Since:
3.0


Copyright © 2000-2012 Ontopia.