wicket.markup.html.tree
Class Tree

java.lang.Object
  extended bywicket.Component
      extended bywicket.MarkupContainer
          extended bywicket.markup.html.WebMarkupContainer
              extended bywicket.markup.html.panel.Panel
                  extended bywicket.markup.html.tree.AbstractTree
                      extended bywicket.markup.html.tree.Tree
All Implemented Interfaces:
java.util.EventListener, java.io.Serializable, javax.swing.event.TreeModelListener

public abstract class Tree
extends AbstractTree
implements javax.swing.event.TreeModelListener

An tree that renders as a flat (not-nested) list, using spacers for indentation and nodes at the end of one row.

The visible tree rows are put in one flat list. For each row, a list is constructed with fillers, that can be used to create indentation. After the fillers, the actual node content is put.

Author:
Eelco Hillenius
See Also:
Serialized Form

Nested Class Summary
protected  class Tree.DefaultNodePanel
          The default node panel.
protected  class Tree.NodePanel
          A panel for a tree node.
 
Nested classes inherited from class wicket.Component
Component.ComponentModelChange, Component.IVisitor, Component.VisibilityChange
 
Field Summary
static java.lang.String JUNCTION_IMAGE_NAME
          Name of the junction image component; value = 'junctionImage'.
static java.lang.String NODE_IMAGE_NAME
          Name of the node image component; value = 'nodeImage'.
 
Fields inherited from class wicket.Component
FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4
 
Constructor Summary
Tree(java.lang.String componentName, javax.swing.tree.TreeModel model)
          Constructor.
Tree(java.lang.String componentName, TreeState treeState)
          Construct using the given tree state that holds the model to be used as the tree model.
 
Method Summary
protected  wicket.markup.html.tree.Tree.TreePathsListView createTreePathsListView()
          Creates the tree paths list view.
protected  boolean equals(javax.swing.tree.TreePath path, javax.swing.tree.TreePath selectedPath)
          Returns whether the path and the selected path are equal.
protected  Image getJunctionImage(javax.swing.tree.DefaultMutableTreeNode node)
          Get image for a junction; used by method createExpandCollapseLink.
protected  Image getNodeImage(javax.swing.tree.DefaultMutableTreeNode node)
          Get image for a node; used by method createNodeLink.
protected  java.lang.String getNodeLabel(javax.swing.tree.DefaultMutableTreeNode node)
          Gets the label of the node that is used for the node link.
 boolean getOptimizeItemRemoval()
          Gets whether item removal should be optimized.
protected  void internalOnBeginRequest()
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
protected  void junctionLinkClicked(javax.swing.tree.DefaultMutableTreeNode node)
          Handler that is called when a junction link is clicked; this implementation sets the expanded state to one that corresponds with the node selection.
protected  Tree.NodePanel newNodePanel(java.lang.String panelId, javax.swing.tree.DefaultMutableTreeNode node)
          Create a new panel for a tree node.
protected  void nodeLinkClicked(javax.swing.tree.DefaultMutableTreeNode node)
          Handler that is called when a node link is clicked; this implementation sets the expanded state just as a click on a junction would do.
 void setOptimizeItemRemoval(boolean optimizeItemRemoval)
          Sets whether item removal should be optimized.
 void treeNodesChanged(javax.swing.event.TreeModelEvent e)
           
 void treeNodesInserted(javax.swing.event.TreeModelEvent e)
           
 void treeNodesRemoved(javax.swing.event.TreeModelEvent e)
           
 void treeStructureChanged(javax.swing.event.TreeModelEvent e)
           
 
Methods inherited from class wicket.markup.html.tree.AbstractTree
getTreeState, isExpanded, isExpanded, isRootVisible, newTreeState, newTreeState, setExpandedState, setExpandedState, setRootVisible, setSelected, setTreeState, toString
 
Methods inherited from class wicket.markup.html.panel.Panel
onRender
 
Methods inherited from class wicket.markup.html.WebMarkupContainer
getMarkupType
 
Methods inherited from class wicket.MarkupContainer
add, autoAdd, contains, findMarkupStream, get, getMarkupStream, internalAdd, internalBeginRequest, internalEndRequest, iterator, onComponentTagBody, remove, removeAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, visitChildren, visitChildren
 
Methods inherited from class wicket.Component
add, addStateChange, checkComponentTag, checkComponentTagAttribute, debug, detachModel, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getApplicationPages, getApplicationSettings, getClassRelativePath, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getId, getLocale, getLocalizer, getModel, getModelObject, getModelObjectAsString, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResource, getResponse, getSession, getString, getString, getString, getStyle, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnEndRequest, internalOnModelChanged, internalOnModelChanging, isAncestorOf, isVersioned, isVisible, isVisibleInHierarchy, modelChanged, modelChanging, newPage, newPage, onBeginRequest, onComponentTag, onEndRequest, onModelChanged, onModelChanging, onSessionAttach, redirectTo, remove, render, renderComponent, renderComponentTag, rendered, replaceComponentTagBody, sameRootModel, sameRootModel, setFlag, setModelObject, setRedirect, setRenderBodyOnly, setResponsePage, setShouldEscapeModelStrings, setVersioned, setVisible, urlFor, visitParents, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JUNCTION_IMAGE_NAME

public static final java.lang.String JUNCTION_IMAGE_NAME
Name of the junction image component; value = 'junctionImage'.

See Also:
Constant Field Values

NODE_IMAGE_NAME

public static final java.lang.String NODE_IMAGE_NAME
Name of the node image component; value = 'nodeImage'.

See Also:
Constant Field Values
Constructor Detail

Tree

public Tree(java.lang.String componentName,
            javax.swing.tree.TreeModel model)
Constructor.

Parameters:
componentName - The name of this container
model - the underlying tree model

Tree

public Tree(java.lang.String componentName,
            TreeState treeState)
Construct using the given tree state that holds the model to be used as the tree model.

Parameters:
componentName - The name of this container
treeState - treeState that holds the underlying tree model
Method Detail

getOptimizeItemRemoval

public boolean getOptimizeItemRemoval()
Gets whether item removal should be optimized. If true, re-rendering the tree is more efficient if the tree model doesn't get changed. However, if this is true, you need to push changes to this tree. This can easility be done by registering this tree as the listener for tree model events (TreeModelListener), but you should be carefull not to create a memory leak by doing this (e.g. when you store the tree model in your session, the tree you registered cannot be GC-ed). TRUE by default.

Returns:
whether item removal should be optimized

setOptimizeItemRemoval

public void setOptimizeItemRemoval(boolean optimizeItemRemoval)
Sets whether item removal should be optimized. If true, re-rendering the tree is more efficient if the tree model doesn't get changed. However, if this is true, you need to push changes to this tree. This can easility be done by registering this tree as the listener for tree model events (TreeModelListener), but you should be carefull not to create a memory leak by doing this (e.g. when you store the tree model in your session, the tree you registered cannot be GC-ed). TRUE by default.

Parameters:
optimizeItemRemoval - whether item removal should be optimized

treeNodesChanged

public void treeNodesChanged(javax.swing.event.TreeModelEvent e)
Specified by:
treeNodesChanged in interface javax.swing.event.TreeModelListener
See Also:
TreeModelListener.treeNodesChanged(javax.swing.event.TreeModelEvent)

treeNodesInserted

public void treeNodesInserted(javax.swing.event.TreeModelEvent e)
Specified by:
treeNodesInserted in interface javax.swing.event.TreeModelListener
See Also:
TreeModelListener.treeNodesInserted(javax.swing.event.TreeModelEvent)

treeNodesRemoved

public void treeNodesRemoved(javax.swing.event.TreeModelEvent e)
Specified by:
treeNodesRemoved in interface javax.swing.event.TreeModelListener
See Also:
TreeModelListener.treeNodesRemoved(javax.swing.event.TreeModelEvent)

treeStructureChanged

public void treeStructureChanged(javax.swing.event.TreeModelEvent e)
Specified by:
treeStructureChanged in interface javax.swing.event.TreeModelListener
See Also:
TreeModelListener.treeStructureChanged(javax.swing.event.TreeModelEvent)

internalOnBeginRequest

protected void internalOnBeginRequest()
Description copied from class: Component
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE. Called when a request begins.

Overrides:
internalOnBeginRequest in class Component
See Also:
Component.internalOnBeginRequest()

newNodePanel

protected Tree.NodePanel newNodePanel(java.lang.String panelId,
                                      javax.swing.tree.DefaultMutableTreeNode node)
Create a new panel for a tree node. This method can be overriden to provide a custom panel. This way, you can effectively nest anything you want in the tree, like input fields, images, etc.

you must use the provide panelId as the id of your custom panel
for example, do:

 return new MyNodePanel(panelId, node);
 

You can choose to either let your own panel extend from DefaultNodePanel when you just want to provide different markup but want to reuse the default components on this panel, or extend from NodePanel directly, and provide any component structure you like.

Parameters:
panelId - the id that the panel MUST use
node - the tree node for the panel
Returns:
a new Panel

createTreePathsListView

protected final wicket.markup.html.tree.Tree.TreePathsListView createTreePathsListView()
Creates the tree paths list view.

Returns:
the tree paths list view

equals

protected boolean equals(javax.swing.tree.TreePath path,
                         javax.swing.tree.TreePath selectedPath)
Returns whether the path and the selected path are equal. This method is used by the AttributeModifierthat is used for setting the CSS class for the selected row.

Parameters:
path - the path
selectedPath - the selected path
Returns:
true if the path and the selected are equal, false otherwise

getJunctionImage

protected Image getJunctionImage(javax.swing.tree.DefaultMutableTreeNode node)
Get image for a junction; used by method createExpandCollapseLink. If you use the packaged panel (Tree.html), you must name the component using JUNCTION_IMAGE_NAME.

Parameters:
node - the tree node
Returns:
the image for the junction

getNodeImage

protected Image getNodeImage(javax.swing.tree.DefaultMutableTreeNode node)
Get image for a node; used by method createNodeLink. If you use the packaged panel (Tree.html), you must name the component using NODE_IMAGE_NAME.

Parameters:
node - the tree node
Returns:
the image for the node

getNodeLabel

protected java.lang.String getNodeLabel(javax.swing.tree.DefaultMutableTreeNode node)
Gets the label of the node that is used for the node link. Defaults to treeNodeModel.getUserObject().toString(); override to provide a custom label

Parameters:
node - the tree node
Returns:
the label of the node that is used for the node link

junctionLinkClicked

protected void junctionLinkClicked(javax.swing.tree.DefaultMutableTreeNode node)
Handler that is called when a junction link is clicked; this implementation sets the expanded state to one that corresponds with the node selection.

Parameters:
node - the tree node

nodeLinkClicked

protected void nodeLinkClicked(javax.swing.tree.DefaultMutableTreeNode node)
Handler that is called when a node link is clicked; this implementation sets the expanded state just as a click on a junction would do. Override this for custom behaviour.

Parameters:
node - the tree node model


Copyright © 2004-2005 Wicket developers. All Rights Reserved.