Package net.ontopia.topicmaps.nav2.utils
Class TreeWidget
java.lang.Object
net.ontopia.topicmaps.nav2.utils.TreeWidget
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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Collectionprotected static final intprotected static final intprotected NavigatorPageIFprotected static final intprotected Stringprotected Mapprotected Stringprotected Stringprotected static final intprotected Setprotected Stringprotected QueryProcessorIFprotected ParsedQueryIFprotected Stringprotected TopicMapIFprotected Stringprotected static final intprotected int -
Constructor Summary
ConstructorsConstructorDescriptionPUBLIC: Sets up the widget ready for use.TreeWidget(TopicMapIF topicmap, String query, String topquery, String ownpage, String nodepage) PUBLIC: Sets up the widget ready for use. -
Method Summary
Modifier and TypeMethodDescriptionprotected TopicTreeNodeprotected voidPUBLIC: Called after the tree has been rendered.protected QueryResultIFgetChildren(TopicIF topic) protected Stringprotected TMObjectIFgetObjectById(String id) protected TopicIFprotected voidinitializeContext(javax.servlet.http.HttpServletRequest request) protected Stringprotected StringmakeNodeUrl(TopicTreeNode node) PUBLIC: Produces the URL to the given node.protected voidprotected voidprocess(TopicTreeNode parent) protected voidrenderAdditionalOnBottomExpandCloseLine(Writer out, int topline) PUBLIC: Performs any additional rendering on the bottom line of the open-all and close-all buttons.protected voidrenderAdditionalOnTopExpandCloseLine(Writer out, int topline) PUBLIC: Performs any additional rendering on the top line of the open-all and close-all buttons.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.protected voidrenderTree(TopicTreeNode node, int topline, Writer writer) voidPUBLIC: Runs the widget, producing the output.voidPUBLIC: Runs the widget, producing the output.voidsetAddAnchor(boolean addAnchor) PUBLIC: If set to true the widget will add anchors on all links that open/close nodes in the tree.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.voidsetNodeQueryString(String nodeQuery) PUBLIC: Sets the tolog query that given a node generates its children.voidsetOwnPageUrl(String ownPageUrl) PUBLIC: The URL of the page the widget is on.voidsetTopicMap(TopicMapIF topicmap) PUBLIC: Sets the topic map used by the widget.voidsetTopQueryString(String topQuery) PUBLIC: Sets the tolog query that generates the list of top nodes.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.protected intwriteNode(TopicTreeNode node, int topline, Writer writer, int level, int lineno, boolean indoc)
-
Field Details
-
OPEN
protected static final int OPEN- See Also:
-
CLOSE
protected static final int CLOSE- See Also:
-
EXPAND_ALL
protected static final int EXPAND_ALL- See Also:
-
CLOSE_ALL
protected static final int CLOSE_ALL- See Also:
-
WINDOW_SIZE
protected static final int WINDOW_SIZE- See Also:
-
processor
-
nodepage
-
staticurl
-
openNodes
-
imageurl
-
windowSize
protected int windowSize -
context
-
ancestors
-
query
-
topicmap
-
map
-
topquery
-
ownpage
-
nodeFrame
-
-
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: Sets the topic map used by the widget. -
setWidgetName
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: Sets the tolog query that generates the list of top nodes. Make sure the query produces a 1-column result. -
setNodeQueryString
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: 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: The URL of of the page that shows the nodes. -
setImageUrl
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: 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. -
run
public void run(javax.servlet.http.HttpServletRequest request, Writer writer) throws IOException, InvalidQueryException, NavigatorRuntimeException PUBLIC: Runs the widget, producing the output.- Throws:
IOExceptionInvalidQueryExceptionNavigatorRuntimeException- Since:
- 2.2.1
-
parseQueries
- Throws:
InvalidQueryException
-
initializeContext
protected void initializeContext(javax.servlet.http.HttpServletRequest request) -
buildTree
- Throws:
InvalidQueryException
-
getChildren
- Throws:
InvalidQueryException
-
process
- Throws:
InvalidQueryException
-
renderTree
- Throws:
IOException
-
writeNode
protected int writeNode(TopicTreeNode node, int topline, Writer writer, int level, int lineno, boolean indoc) throws IOException - Throws:
IOException
-
getId
-
getObjectById
-
getTopic
-
list
-
toString
-
renderNode
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
PUBLIC: Renders the back button at the top/bottom of the form.- Throws:
IOException
-
renderExpandAllButton
PUBLIC: Renders the expand all button at the top/bottom of the form.- Throws:
IOException
-
renderCloseAllButton
PUBLIC: Renders the close all button at the top/bottom of the form.- Throws:
IOException
-
renderForwardButton
PUBLIC: Renders the close all button at the top/bottom of the form.- Throws:
IOException
-
renderAdditionalOnTopExpandCloseLine
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
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
PUBLIC: Called before rendering of the tree begins.- Throws:
IOException
-
endRender
PUBLIC: Called after the tree has been rendered.- Throws:
IOException
-
makeNodeUrl
PUBLIC: Produces the URL to the given node.- Since:
- 3.0
-