Package net.ontopia.topicmaps.nav2.utils
Class DynamicTreeWidget
- java.lang.Object
-
- net.ontopia.topicmaps.nav2.utils.DynamicTreeWidget
-
public class DynamicTreeWidget extends Object
EXPERIMENTAL: This class can output a nice collapsing/expanding tree view of a topic map implemented with DHTML, 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:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description protected static intCLOSEprotected static intCLOSE_ALLprotected NavigatorPageIFcontextprotected static intEXPAND_ALLprotected Stringimageurlprotected Stringnodepageprotected static intOPENprotected Stringownpageprotected QueryProcessorIFprocessorprotected Stringstaticurlprotected static intWINDOW_SIZEprotected intwindowSize
-
Constructor Summary
Constructors Constructor Description DynamicTreeWidget()PUBLIC: Sets up the widget ready for use.DynamicTreeWidget(TopicMapIF topicmap, String tablequery, String ownpage, String nodepage)PUBLIC: Sets up the widget ready for use.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidendRender(Writer out)PUBLIC: Called after the tree has been rendered.protected StringescapeName(String name)protected StringgetId(TopicIF topic)protected StringgetQualifiedId(String id)protected TopicIFgetTopic(String id)protected voidinitializeContext(javax.servlet.http.HttpServletRequest request)protected Stringlist(Set nodes)protected StringmakeNodeUrl(TopicTreeNode node)PUBLIC: Produces the URL to the given node.protected voidrenderBackButton(Writer out, int topline)PUBLIC: Renders the back button at the top/bottom of the form.protected voidrenderCloseAllButton(Writer out, int topline)PUBLIC: Renders the close all button at the top/bottom of the form.protected voidrenderExpandAllButton(Writer out, int topline)PUBLIC: Renders the expand all button at the top/bottom of the form.protected voidrenderForwardButton(Writer out, int topline)PUBLIC: Renders the close all button at the top/bottom of the form.protected voidrenderNode(TopicTreeNode node, Writer out)PUBLIC: This method renders the tree node, including its link, but not the button in front of the node.protected voidrenderNodeButton(int topline, int level, int action, String id, Writer out)PUBLIC: Renders the +/- button in front of the node.voidrun(javax.servlet.http.HttpServletRequest request, Writer writer)PUBLIC: Runs the widget, producing the output.voidrun(javax.servlet.jsp.PageContext ctxt, Writer writer)PUBLIC: Runs the widget, producing the output.voidsetChildrenComparator(Comparator childrenComparator)voidsetDebug(boolean debug)INTERNAL: Debug flag.voidsetDependentWidgets(String[] widget_names)PUBLIC: The name of the session key in which the set of open nodes is stored.voidsetImageUrl(String imageurl)PUBLIC: The URL at which the graphics used by the widget are found.voidsetNodeFrame(String nodeFrame)PUBLIC: The name of the HTML frame in which to open links to nodes.voidsetNodePageUrl(String nodePageUrl)PUBLIC: The URL of of the page that shows the nodes.voidsetOwnPageUrl(String ownPageUrl)PUBLIC: The URL of the page the widget is on.voidsetTableQuery(String tablequery)EXPERIMENTAL: The name of the HTML frame in which to open links to nodes.voidsetTableQueryString(String tablequery)PUBLIC: Sets the tolog query that generates the entire tree.voidsetTopicMap(TopicMapIF topicmap)PUBLIC: Sets the topic map used by the widget.voidsetTopQuery(String topquery)voidsetWidgetName(String name)PUBLIC: The name of the session key in which the set of open nodes is stored.voidsetWindowSize(int windowSize)PUBLIC: Sets the maximum number of nodes displayed by the widget at once.protected voidstartRender(Writer out)PUBLIC: Called before rendering of the tree begins.StringtoString(TopicIF topic)
-
-
-
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 String nodepage
-
staticurl
protected String staticurl
-
imageurl
protected String imageurl
-
windowSize
protected int windowSize
-
context
protected NavigatorPageIF context
-
ownpage
protected String ownpage
-
-
Constructor Detail
-
DynamicTreeWidget
public DynamicTreeWidget(TopicMapIF topicmap, String tablequery, String ownpage, String nodepage) throws InvalidQueryException
PUBLIC: Sets up the widget ready for use.- Parameters:
topicmap- The topic map being displayed.tablequery- A tolog query that generates the entire tree. The query must have at least two columns, where the first column contains all the parent nodes and the second column contains the children of those parents. Any further columns will be used to populate the data attribute of the tree nodes.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.- Throws:
InvalidQueryException
-
DynamicTreeWidget
public DynamicTreeWidget()
PUBLIC: Sets up the widget ready for use.
-
-
Method Detail
-
setTopicMap
public void setTopicMap(TopicMapIF topicmap)
PUBLIC: Sets the topic map used by the widget.
-
setTableQueryString
public void setTableQueryString(String tablequery)
PUBLIC: Sets the tolog query that generates the entire tree. The query must have at least two columns, where the first column contains all the parent nodes and the second column contains the children of those parents. Any further columns will be used to populate the data attribute of the tree nodes.
-
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.
-
setDebug
public void setDebug(boolean debug)
INTERNAL: Debug flag. Used only for debugging purposes.
-
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.
-
setDependentWidgets
public void setDependentWidgets(String[] widget_names)
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.
-
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.
-
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, NavigatorRuntimeExceptionPUBLIC: Runs the widget, producing the output.
-
setTableQuery
public void setTableQuery(String tablequery)
EXPERIMENTAL: The name of the HTML frame in which to open links to nodes.- Since:
- 2.0.3
-
setChildrenComparator
public void setChildrenComparator(Comparator childrenComparator)
-
setTopQuery
public void setTopQuery(String topquery)
-
run
public void run(javax.servlet.http.HttpServletRequest request, Writer writer) throws IOException, InvalidQueryException, NavigatorRuntimeExceptionPUBLIC: Runs the widget, producing the output.- Throws:
IOExceptionInvalidQueryExceptionNavigatorRuntimeException- Since:
- 2.2.1
-
initializeContext
protected void initializeContext(javax.servlet.http.HttpServletRequest request)
-
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 IOExceptionPUBLIC: 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
-
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.
-
-