org.apache.wicket.extensions.markup.html.tree
Class DefaultAbstractTree

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.markup.html.WebMarkupContainer
              extended by org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup
                  extended by org.apache.wicket.markup.html.panel.Panel
                      extended by org.apache.wicket.markup.html.tree.AbstractTree
                          extended by org.apache.wicket.extensions.markup.html.tree.DefaultAbstractTree
All Implemented Interfaces:
Serializable, EventListener, TreeModelListener, AjaxRequestTarget.ITargetRespondListener, IClusterable, IConverterLocator, IHeaderPartContainerProvider, ITreeStateListener
Direct Known Subclasses:
Tree, TreeTable

public abstract class DefaultAbstractTree
extends AbstractTree

Tree class that contains convenient functions related to presentation of the tree, which includes junction link, tree item selection link, spacers (with lines) and default tree item and folder icons.

The class itself adds no component to tree items. If you use this class directly, you have to implement populateTreeItem() on your own. If you want to use an existing (complete) tree class, use Tree

This class allows you to choose between 3 types of links. setLinkType(org.apache.wicket.extensions.markup.html.tree.DefaultAbstractTree.LinkType)

Author:
Matej Knopp
See Also:
Serialized Form

Nested Class Summary
protected static interface DefaultAbstractTree.ILinkCallback
          Helper class for calling an action from a link.
static class DefaultAbstractTree.LinkType
          The type of junction links and node selection links.
 
Nested classes/interfaces inherited from class org.apache.wicket.Component
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor<T extends Component>, Component.VisibilityChange
 
Field Summary
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_CONFIGURED, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER
 
Constructor Summary
DefaultAbstractTree(String id)
          Tree constructor.
DefaultAbstractTree(String id, IModel<TreeModel> model)
          Tree constructor.
DefaultAbstractTree(String id, TreeModel model)
          Tree constructor.
 
Method Summary
protected  ResourceReference getCSS()
          Returns the resource reference of default stylesheet.
protected  ResourceReference getFolderClosed()
          Returns the resource reference of default closed tree folder.
protected  ResourceReference getFolderOpen()
          Returns the resource reference of default open tree folder.
protected  ResourceReference getItem()
          Returns the resource reference of default tree item (not folder).
 DefaultAbstractTree.LinkType getLinkType()
          Returns the current type of links on tree items.
protected  ResourceReference getNodeIcon(TreeNode node)
          Returns the resource reference for icon of specified tree node.
protected  Component newIndentation(MarkupContainer parent, String id, TreeNode node, int level)
          Creates the indentation element.
protected  MarkupContainer newJunctionImage(MarkupContainer parent, String id, TreeNode node)
          Creates an image placed on junction link.
protected  Component newJunctionLink(MarkupContainer parent, String id, String imageId, TreeNode node)
          Creates the junction link for given node.
protected  MarkupContainer newLink(MarkupContainer parent, String id, DefaultAbstractTree.ILinkCallback callback)
          Creates a link of type specified by current linkType.
protected  Component newNodeIcon(MarkupContainer parent, String id, TreeNode node)
          Creates the icon for current node.
protected  MarkupContainer newNodeLink(MarkupContainer parent, String id, TreeNode node)
          Creates a link that can be used to select / deselect the specified node.
protected  void onJunctionLinkClicked(AjaxRequestTarget target, TreeNode node)
          Callback function called after user clicked on an junction link.
protected  void onNodeLinkClicked(AjaxRequestTarget target, TreeNode node)
          This callback method is called after user has selected / deselected the given node.
 void setLinkType(DefaultAbstractTree.LinkType linkType)
          Sets the type of links on tree items.
 
Methods inherited from class org.apache.wicket.markup.html.tree.AbstractTree
addComponent, allNodesCollapsed, allNodesExpanded, getChildAt, getChildCount, getModel, getModelObject, getNodeComponent, getParentNode, getTreeState, invalidateAll, isForceRebuildOnSelectionChange, isLeaf, isNodeExpanded, isRootLess, markNodeChildrenDirty, markNodeDirty, newTreeState, nodeChildren, nodeCollapsed, nodeExpanded, nodeSelected, nodeUnselected, onAfterRender, onBeforeAttach, onBeforeRender, onDetach, onTargetRespond, populateTreeItem, setModel, setModelObject, setRootLess, treeNodesChanged, treeNodesInserted, treeNodesRemoved, treeStructureChanged, updateTree, updateTree
 
Methods inherited from class org.apache.wicket.markup.html.panel.Panel
onComponentTag, onComponentTagBody, renderHead
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup
newHeaderPartContainer, renderHeadFromAssociatedMarkupFile
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getMarkupType, getWebPage, getWebRequest
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onAfterRenderChildren, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, renderNext, replace, setDefaultModel, setMarkupStream, size, swap, toString, toString, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, configure, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getBehaviors, getBehaviors, getBehaviorsRawList, getClassRelativePath, getComponentBorder, getConverter, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdImpl, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, onAttach, onBeginRequest, onConfigure, onEndRequest, onInitialize, onModelChanged, onModelChanging, onRemove, prepareForRender, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultAbstractTree

public DefaultAbstractTree(String id)
Tree constructor.

Parameters:
id - The component id

DefaultAbstractTree

public DefaultAbstractTree(String id,
                           IModel<TreeModel> model)
Tree constructor.

Parameters:
id - The component id
model - The tree model

DefaultAbstractTree

public DefaultAbstractTree(String id,
                           TreeModel model)
Tree constructor.

Parameters:
id - The component id
model - The tree model
Method Detail

getLinkType

public DefaultAbstractTree.LinkType getLinkType()
Returns the current type of links on tree items.

Returns:
The link type

setLinkType

public void setLinkType(DefaultAbstractTree.LinkType linkType)
Sets the type of links on tree items. After the link type is changed, the whole tree is rebuild and re-rendered.

Parameters:
linkType - type of links

getCSS

protected ResourceReference getCSS()
Returns the resource reference of default stylesheet.

Returns:
The package resource reference

getFolderClosed

protected ResourceReference getFolderClosed()
Returns the resource reference of default closed tree folder.

Returns:
The package resource reference

getFolderOpen

protected ResourceReference getFolderOpen()
Returns the resource reference of default open tree folder.

Returns:
The package resource reference

getItem

protected ResourceReference getItem()
Returns the resource reference of default tree item (not folder).

Returns:
The package resource reference

getNodeIcon

protected ResourceReference getNodeIcon(TreeNode node)
Returns the resource reference for icon of specified tree node.

Parameters:
node - The node
Returns:
The package resource reference

newIndentation

protected Component newIndentation(MarkupContainer parent,
                                   String id,
                                   TreeNode node,
                                   int level)
Creates the indentation element. This element should be placed as first element in the tree item markup to ensure proper indentation of the tree item. This implementation also takes care of lines that connect nodes.

Parameters:
parent - The component parent
id - The component id
node - The tree node for which to create the indentation element
level - The current level
Returns:
The indentation component

newJunctionImage

protected MarkupContainer newJunctionImage(MarkupContainer parent,
                                           String id,
                                           TreeNode node)
Creates an image placed on junction link. This image actually consists of two spans with different css classes. These classes are specified according to the stylesheet to make the junction image look well together with lines connecting nodes.

Parameters:
parent - The component parent
id - The component id
node - The tree node
Returns:
The component that represents a junction

newJunctionLink

protected Component newJunctionLink(MarkupContainer parent,
                                    String id,
                                    String imageId,
                                    TreeNode node)
Creates the junction link for given node. Also (optionally) creates the junction image. If the node is a leaf (it has no children), the created junction link is non-functional.

Parameters:
parent - parent component of the link
id - wicket:id of the component
imageId - wicket:id of the image. this can be null, in that case image is not created. image is supposed to be placed on the link (link is parent of image)
node - tree node for which the link should be created.
Returns:
The link component

newLink

protected MarkupContainer newLink(MarkupContainer parent,
                                  String id,
                                  DefaultAbstractTree.ILinkCallback callback)
Creates a link of type specified by current linkType. When the links is clicked it calls the specified callback.

Parameters:
parent - The parent component
id - The component id
callback - The link call back
Returns:
The link component

newNodeIcon

protected Component newNodeIcon(MarkupContainer parent,
                                String id,
                                TreeNode node)
Creates the icon for current node. By default uses image reference specified by getNodeIcon(TreeNode).

Parameters:
parent - The parent component
id - The component id
node - The tree node
Returns:
The web component that represents the icon of the current node

newNodeLink

protected MarkupContainer newNodeLink(MarkupContainer parent,
                                      String id,
                                      TreeNode node)
Creates a link that can be used to select / deselect the specified node.

Parameters:
parent - The parent component
id - The component id
node - The parent node
Returns:
The component that represents the link

onJunctionLinkClicked

protected void onJunctionLinkClicked(AjaxRequestTarget target,
                                     TreeNode node)
Callback function called after user clicked on an junction link. The node has already been expanded/collapsed (depending on previous status).

Parameters:
target - Request target - may be null on non-ajax call
node - Node for which this callback is relevant

onNodeLinkClicked

protected void onNodeLinkClicked(AjaxRequestTarget target,
                                 TreeNode node)
This callback method is called after user has selected / deselected the given node.

Parameters:
target - Request target - may be null on non-ajax call
node - Node for which this this callback is fired.


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.