|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.arsdigita.bebop.Completable
com.arsdigita.bebop.SimpleComponent
com.arsdigita.bebop.Tree
Used to print a tree structure. Nodes can be in expanded or
collapsed state. Tree uses the getChildren() and
getRoot() methods from TreeModel and traverses the iterator to get
to all the nodes.
This class keeps track of which nodes are expanded and collapsed
and the hierarchy of nodes, and displays the tree correspondingly.
| Nested Class Summary | |
static class |
Tree.TreeSingleSelectionModel
Deprecated. The ParameterSingleSelectionModel contains
all the functionality of this class |
| Field Summary | |
protected TreeModelBuilder |
m_builder
|
protected StringParameter |
m_currentState
|
static String |
versionId
|
| Fields inherited from class com.arsdigita.bebop.SimpleComponent |
m_attr |
| Fields inherited from interface com.arsdigita.bebop.Component |
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE |
| Constructor Summary | |
Tree(TreeModel t)
Deprecated. This constructor has been deprecated in favor of Tree(TreeModelBuilder b). It is not practical
to hardwire the TreeModel into the Tree,
since the model may change during each request. It is possible
to write the model-instantiation code in
TreeModel.getRoot(PageState), but the
TreeModelBuilder fits better into the pattern which has
already been established by List and Table |
|
Tree(TreeModelBuilder b)
Constructs a new Tree using the specified
TreeModelBuilder. |
|
| Method Summary | |
void |
addActionListener(ActionListener l)
Adds a listener that is notified whenever a user clicks on any part of the tree, either to expand or collapse a node, or to select a node. |
void |
addChangeListener(ChangeListener l)
Adds a change listener. |
void |
addTreeExpansionListener(TreeExpansionListener l)
Adds a listener that is notified whenever a tree node is expanded or collpased, either by a user's click or by explicit calls to expand or collapse. |
void |
clearExpansionState(PageState state)
Clears any tree node expansion state on the request. |
void |
clearSelection(PageState state)
Clears the selection in the request represented by state. |
void |
collapse(String nodeKey,
PageState data)
Collapses a node in the tree and makes its children visible. |
protected ChangeListener |
createChangeListener()
Creates the change listener used for forwarding change events fired by the selection model to change listeners registered with the tree. |
void |
expand(String nodeKey,
PageState data)
Expands a node in the tree and makes its children visible. |
protected void |
fireActionEvent(PageState data)
Notifies listeners that some part of the tree was clicked by the user. |
protected void |
fireStateChanged(PageState state)
Fires a change event to signal that the selected list item has changed in the request represented by state. |
protected void |
fireTreeCollapsed(PageState state,
Object nodeKey)
Notifies all registered TreeExpansionListeners that a node in the tree has been collapsed. |
protected void |
fireTreeExpanded(PageState state,
Object nodeKey)
Notifies all registered TreeExpansionListeners that a node in the tree has been expanded. |
protected void |
generateTree(PageState data,
Element parent,
TreeNode node,
TreeModel tree)
Builds a DOM representing the tree. |
void |
generateXML(PageState data,
Element parent)
Services the request by building a DOM tree with the nodes first and then the included page. |
TreeCellRenderer |
getCellRenderer()
Returns the renderer currently used to render tree nodes. |
TreeModelBuilder |
getModelBuilder()
|
Object |
getSelectedKey(PageState state)
Gets the key for the selected node. |
SingleSelectionModel |
getSelectionModel()
Gets the selection model, which keeps track of which node is currently selected. |
TreeModel |
getTreeModel()
Deprecated. Use getTreeModel(PageState) instead |
TreeModel |
getTreeModel(PageState s)
Returns the TreeModel used by the tree for the current
request. |
boolean |
hasExpansionState(PageState state)
Tells whether the tree has state on the request for tree node expansion. |
boolean |
isCollapsed(String nodeKey,
PageState data)
Determines whether the node at the specified display row is collapsed. |
boolean |
isSelected(PageState state)
Returns true if one of the nodes is currently selected. |
void |
lock()
Locks the Tree and prohibits further modifications. |
void |
register(Page p)
Registers the two parameters to the page. |
void |
removeActionListener(ActionListener l)
Removes a previously added ActionListener. |
void |
removeChangeListener(ChangeListener l)
Removes a change listener. |
void |
removeTreeExpansionListener(TreeExpansionListener l)
Removes a previously added TreeExpansionListener. |
void |
reset(PageState state)
Clears the request state of the tree. |
void |
respond(PageState data)
Notifies the Tree that a node has been selected. |
void |
setCellRenderer(TreeCellRenderer r)
Sets the cell renderer to be used when generating output with generateXML. |
void |
setModelBuilder(TreeModelBuilder b)
|
void |
setSelectedKey(PageState state,
Object key)
Sets the selection to the one with the specified key. |
void |
setSelectionModel(SingleSelectionModel m)
Sets the selection model, which keeps track of which node is currently selected. |
void |
setTreeModel(TreeModel m)
Sets the tree model used for this tree. |
| Methods inherited from class com.arsdigita.bebop.SimpleComponent |
children, clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, register, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible |
| Methods inherited from class com.arsdigita.bebop.Completable |
addCompletionListener, fireCompletionEvent |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String versionId
protected StringParameter m_currentState
protected TreeModelBuilder m_builder
| Constructor Detail |
public Tree(TreeModelBuilder b)
Tree using the specified
TreeModelBuilder. The TreeModelBuilder will
instantiate a TreeModel during each request.
b - the TreeModelBuilderpublic Tree(TreeModel t)
Tree(TreeModelBuilder b). It is not practical
to hardwire the TreeModel into the Tree,
since the model may change during each request. It is possible
to write the model-instantiation code in
TreeModel.getRoot(PageState), but the
TreeModelBuilder fits better into the pattern which has
already been established by List and Table
TreeModel
and wraps it in a dummy TreeModelBuilder.
t - the TreeModel| Method Detail |
public void register(Page p)
register in interface Componentregister in class SimpleComponentpublic void reset(PageState state)
reset in interface Resettablestate - the page statepublic final TreeModel getTreeModel()
getTreeModel(PageState) instead
TreeModel.setTreeModel,
TreeModelpublic TreeModel getTreeModel(PageState s)
TreeModel used by the tree for the current
request.
s - the page statepublic final TreeModelBuilder getModelBuilder()
TreeModelBuilder used to build the tree model
for this tree.public void setModelBuilder(TreeModelBuilder b)
b - the new TreeModelBuilder for the treepublic void setTreeModel(TreeModel m)
TreeModel.setTreeModel,
TreeModelpublic void setSelectionModel(SingleSelectionModel m)
m - the new selection modelpublic final SingleSelectionModel getSelectionModel()
public Object getSelectedKey(PageState state)
isSelected is true.
state - represents the state of the current request
public void setSelectedKey(PageState state,
Object key)
key was not selected already, fires the ChangeEvent.
state - represents the state of the current requestkey - the key for the selected nodefireStateChangedpublic boolean isSelected(PageState state)
true if one of the nodes is currently selected.
state - represents the state of the current request
true if one of the nodes is selected;
false otherwise.public void clearSelection(PageState state)
state.
state - represents the state of the current requestpublic final boolean hasExpansionState(PageState state)
public final void clearExpansionState(PageState state)
protected ChangeListener createChangeListener()
public void addChangeListener(ChangeListener l)
l - the change listener to run when the selected item changes in
a requestpublic void removeChangeListener(ChangeListener l)
addChangeListener, although no
error is signalled if the change listener is not found among the
tree's listeners.
l - the change listener to remove from the treeprotected void fireStateChanged(PageState state)
state. The source of the
event is the tree.
state - represents the state of the current requestpublic void addActionListener(ActionListener l)
respond is
called.
public void removeActionListener(ActionListener l)
ActionListener.
addActionListenerprotected void fireActionEvent(PageState data)
respondpublic void addTreeExpansionListener(TreeExpansionListener l)
expand or collapse.
public void removeTreeExpansionListener(TreeExpansionListener l)
TreeExpansionListener.
addTreeExpansionListener
protected void fireTreeExpanded(PageState state,
Object nodeKey)
TreeExpansionListeners that a node in the tree has been expanded.
protected void fireTreeCollapsed(PageState state,
Object nodeKey)
TreeExpansionListeners that a node in the tree has been collapsed.
public void respond(PageState data)
throws javax.servlet.ServletException
Tree that a node has been selected.
Changes the currently selected tree component.
respond in interface Componentrespond in class SimpleComponentdata - the current page state
javax.servlet.ServletException
public boolean isCollapsed(String nodeKey,
PageState data)
true if the node at the specified display row is collapsed;
false otherwise.
public void collapse(String nodeKey,
PageState data)
nodeKey - the key that the tree model uses to identify the
nodedata - represents the current request
public void expand(String nodeKey,
PageState data)
nodeKey - the key that the tree model uses to identify the
nodedata - represents the current requestpublic final TreeCellRenderer getCellRenderer()
public void setCellRenderer(TreeCellRenderer r)
generateXML.
r - a TreeCellRenderer value
protected void generateTree(PageState data,
Element parent,
TreeNode node,
TreeModel tree)
public void generateXML(PageState data,
Element parent)
generateXML in interface ComponentgenerateXML in class SimpleComponentpublic void lock()
Tree and prohibits further modifications.
lock in interface Lockablelock in class SimpleComponent
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||