org.apache.wicket.markup.html.tree
Class BaseTree

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.markup.html.tree.BaseTree
All Implemented Interfaces:
Serializable, EventListener, TreeModelListener, AjaxRequestTarget.ITargetRespondListener, IClusterable, IConverterLocator, IHeaderPartContainerProvider, ITreeStateListener
Direct Known Subclasses:
LabelTree

public abstract class BaseTree
extends AbstractTree

An abstract Tree component that should serve as a base for custom Tree Components. It has one abstract method - newNodeComponent(String, IModel) that needs to be overridden.

Author:
Matej Knopp
See Also:
Serialized Form

Nested Class Summary
static interface BaseTree.ILinkCallback
          Helper class for calling an action from a link.
static class BaseTree.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, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Constructor Summary
BaseTree(String id)
          Construct.
BaseTree(String id, IModel<TreeModel> model)
          Construct.
 
Method Summary
protected  ResourceReference getCSS()
          Returns the stylesheet reference
protected  String getItemClass(Object node)
           
 BaseTree.LinkType getLinkType()
          Returns the current type of links on tree items.
protected  String getSelectedClass()
          Returns the class name that will be added to row's CSS class for selected rows
protected  boolean isForceRebuildOnSelectionChange()
          Determines whether the TreeNode needs to be rebuilt if it is selected or deselected
protected  Component newJunctionLink(MarkupContainer parent, String id, Object node)
          Creates the junction link for given node.
 MarkupContainer newLink(String id, BaseTree.ILinkCallback callback)
          Creates a link of type specified by current linkType.
protected abstract  Component newNodeComponent(String id, IModel<Object> model)
          Creates a new component for the given TreeNode.
protected  void onJunctionLinkClicked(AjaxRequestTarget target, Object node)
          Callback function called after user clicked on an junction link.
protected  void populateTreeItem(WebMarkupContainer item, int level)
          This method is called after creating every TreeItem.
 void setLinkType(BaseTree.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, isLeaf, isNodeExpanded, isRootLess, markNodeChildrenDirty, markNodeDirty, newTreeState, nodeChildren, nodeCollapsed, nodeExpanded, nodeSelected, nodeUnselected, onAfterRender, onBeforeAttach, onBeforeRender, onDetach, onTargetRespond, 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, getAjaxRegionMarkupId, 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

BaseTree

public BaseTree(String id)
Construct.

Parameters:
id -

BaseTree

public BaseTree(String id,
                IModel<TreeModel> model)
Construct.

Parameters:
id -
model -
Method Detail

getCSS

protected ResourceReference getCSS()
Returns the stylesheet reference

Returns:
stylesheet reference

populateTreeItem

protected void populateTreeItem(WebMarkupContainer item,
                                int level)
Description copied from class: AbstractTree
This method is called after creating every TreeItem. This is the place for adding components on item (junction links, labels, icons...)

Specified by:
populateTreeItem in class AbstractTree
Parameters:
item - newly created tree item. The node can be obtained as item.getModelObject()
level - how deep the component is in tree hierarchy (0 for root item)
See Also:
AbstractTree.populateTreeItem(org.apache.wicket.markup.html.WebMarkupContainer, int)

getItemClass

protected String getItemClass(Object node)

getSelectedClass

protected String getSelectedClass()
Returns the class name that will be added to row's CSS class for selected rows

Returns:
CSS class name

newNodeComponent

protected abstract Component newNodeComponent(String id,
                                              IModel<Object> model)
Creates a new component for the given TreeNode.

Parameters:
id - component ID
model - model that returns the node
Returns:
component for node

newJunctionLink

protected Component newJunctionLink(MarkupContainer parent,
                                    String id,
                                    Object 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
node - tree node for which the link should be created.
Returns:
The link component

onJunctionLinkClicked

protected void onJunctionLinkClicked(AjaxRequestTarget target,
                                     Object 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

newLink

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

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

getLinkType

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

Returns:
The link type

setLinkType

public void setLinkType(BaseTree.LinkType linkType)
Sets the type of links on tree items. After the link type is changed, the whole tree must be rebuilt (call invalidateAll).

Parameters:
linkType - type of links

isForceRebuildOnSelectionChange

protected boolean isForceRebuildOnSelectionChange()
Description copied from class: AbstractTree
Determines whether the TreeNode needs to be rebuilt if it is selected or deselected

Overrides:
isForceRebuildOnSelectionChange in class AbstractTree
Returns:
true if the node should be rebuilt after (de)selection, false otherwise
See Also:
AbstractTree.isForceRebuildOnSelectionChange()


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