|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zkoss.zul.AbstractTreeModel<E>
public abstract class AbstractTreeModel<E>
A skeletal implementation for TreeModel
.
AbstractTreeModel
implements both TreeSelectableModel
and TreeOpenableModel
. In other words, it stores the selection
and open states, such that Tree
and other UI can interact with.
In additions, AbstractTreeModel
also implements
Selectable
and Openable
to simplify the acess
(and provides backward compatibility to ZK 5 and ealier).
However, these two interfaces are optional and designed for application.
Tree
and all ZK core don't access it at all.
For introduction, please refer to ZK Developer's Reference: Tree Model.
Nested Class Summary | |
---|---|
protected static class |
AbstractTreeModel.Path
Represents a tree path. |
Field Summary | |
---|---|
protected java.util.Set<AbstractTreeModel.Path> |
_opens
The open information. |
protected java.util.Set<AbstractTreeModel.Path> |
_selection
The selection. |
Constructor Summary | |
---|---|
AbstractTreeModel(E root)
Creates a AbstractTreeModel . |
Method Summary | |
---|---|
boolean |
addOpenObject(E child)
Add the specified object into the collection of opened objects. |
boolean |
addOpenPath(int[] path)
Adds path to the current open. |
boolean |
addOpenPaths(int[][] paths)
Adds paths to the current Open. |
boolean |
addSelectionPath(int[] path)
Adds path to the current selection. |
boolean |
addSelectionPaths(int[][] paths)
Adds paths to the current selection. |
boolean |
addToSelection(E child)
Add the specified object into selection. |
void |
addTreeDataListener(TreeDataListener l)
Add a listener to the tree that's notified each time a change to the data model occurs |
protected void |
afterSort(java.lang.Object ctx)
A utility that the deriving class can call to restore the states saved by beforeSort() |
protected java.lang.Object |
beforeSort()
A utility that the deriving class can call to save the states before sorting the model. |
void |
clearOpen()
Empties the current open path. |
void |
clearSelection()
Empties the current selection. |
java.lang.Object |
clone()
|
void |
fireEvent(E node,
int indexFrom,
int indexTo,
int evtType)
Deprecated. As of release 6.0.0, replaced with fireEvent(int, int[], int, int) . |
void |
fireEvent(int evtType,
int[] path,
int indexFrom,
int indexTo)
Fires a TreeDataEvent for all registered listener
Note: you can invoke this method only in an event listener. |
protected void |
fireOpenChanged(int[] path)
Fires a TreeDataEvent for all registered listener when open
status has changed. |
protected void |
fireSelectionChanged(int[] path)
Fires a TreeDataEvent for all registered listener when selection
status has changed. |
E |
getChild(int[] path)
Returns the child at the given path where the path indicates the child is placed in the whole tree. |
int |
getIndexOfChild(E parent,
E child)
Returns the index of child in parent. |
int |
getOpenCount()
Returns the number of paths that are opened. |
java.util.Set<E> |
getOpenObjects()
Returns the objects that are opened. |
int[] |
getOpenPath()
Returns the first path in the open. |
int[][] |
getOpenPaths()
Returns the paths in the open. |
int[] |
getPath(E child)
Returns the path from the specified child. |
E |
getRoot()
Return the root of the tree model. |
java.util.Set<E> |
getSelection()
Returns the current selection. |
int |
getSelectionCount()
Returns the number of paths that are selected. |
int[] |
getSelectionPath()
Returns the first path in the selection. |
int[][] |
getSelectionPaths()
Returns the paths in the selection. |
boolean |
isMultiple()
Returns whether the current selection mode is multiple. |
boolean |
isObjectOpened(java.lang.Object child)
Returns whether the specified object be opened. |
boolean |
isOpenEmpty()
Returns true if the open is currently empty. |
boolean |
isPathOpened(int[] path)
Returns true if the path, path , is in the current open. |
boolean |
isPathSelected(int[] path)
Returns true if the path, path , is in the current selection. |
boolean |
isSelected(java.lang.Object child)
Returns whether an object is selected. |
boolean |
isSelectionEmpty()
Returns true if the selection is currently empty. |
boolean |
removeFromSelection(java.lang.Object child)
Remove the specified object from selection. |
boolean |
removeOpenObject(java.lang.Object child)
Remove the specified object from selection. |
boolean |
removeOpenPath(int[] path)
Removes path from the open. |
boolean |
removeOpenPaths(int[][] paths)
Removes paths from the open. |
boolean |
removeSelectionPath(int[] path)
Removes path from the selection. |
boolean |
removeSelectionPaths(int[][] paths)
Removes paths from the selection. |
void |
removeTreeDataListener(TreeDataListener l)
Remove a listener to the tree that's notified each time a change to the data model occurs |
void |
setMultiple(boolean multiple)
Sets the selection mode to be multiple. |
void |
setOpenObjects(java.util.Collection<? extends E> opened)
Replace the current set of opened objects with the given set. |
void |
setSelection(java.util.Collection<? extends E> selection)
Replace the current selection with the given set. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.zkoss.zul.TreeModel |
---|
getChild, getChildCount, isLeaf |
Field Detail |
---|
protected java.util.Set<AbstractTreeModel.Path> _selection
protected java.util.Set<AbstractTreeModel.Path> _opens
Constructor Detail |
---|
public AbstractTreeModel(E root)
AbstractTreeModel
.
root
- root of treeMethod Detail |
---|
public E getRoot()
getRoot
in interface TreeModel<E>
public void fireEvent(E node, int indexFrom, int indexTo, int evtType)
fireEvent(int, int[], int, int)
.
public void fireEvent(int evtType, int[] path, int indexFrom, int indexTo)
TreeDataEvent
for all registered listener
Note: you can invoke this method only in an event listener.
protected void fireSelectionChanged(int[] path)
TreeDataEvent
for all registered listener when selection
status has changed.
protected void fireOpenChanged(int[] path)
TreeDataEvent
for all registered listener when open
status has changed.
public int getIndexOfChild(E parent, E child)
The default implementation iterates through all children of
parent
by invoking, and check if child
is part
of them. You could override it if you have a better algorithm.
getChild(int[])
getIndexOfChild
in interface TreeModel<E>
parent
- a node in the tree, obtained from this data sourcechild
- the node we are interested in
public E getChild(int[] path)
TreeModel
getChild
in interface TreeModel<E>
path
- the tree path
public int[] getPath(E child)
getPath
in interface TreeModel<E>
child
- the node we are interested inpublic void addTreeDataListener(TreeDataListener l)
TreeModel
addTreeDataListener
in interface TreeModel<E>
l
- the listener to addpublic void removeTreeDataListener(TreeDataListener l)
TreeModel
removeTreeDataListener
in interface TreeModel<E>
l
- the listener to removepublic void setMultiple(boolean multiple)
TreeSelectableModel
setMultiple
in interface Selectable<E>
setMultiple
in interface TreeSelectableModel
public boolean isMultiple()
TreeSelectableModel
isMultiple
in interface Selectable<E>
isMultiple
in interface TreeSelectableModel
TreeSelectableModel.setMultiple(boolean)
public boolean addSelectionPath(int[] path)
TreeSelectableModel
path
is null.
addSelectionPath
in interface TreeSelectableModel
path
- the new path to add to the current selection
public boolean addSelectionPaths(int[][] paths)
TreeSelectableModel
paths
is null.
addSelectionPaths
in interface TreeSelectableModel
paths
- the new paths to add to the current selection
public boolean removeSelectionPath(int[] path)
TreeSelectableModel
path
is null.
removeSelectionPath
in interface TreeSelectableModel
path
- the path to remove from the selection
public boolean removeSelectionPaths(int[][] paths)
TreeSelectableModel
paths
are in the selection, the TreeDataListeners are
notified. This method has no effect if paths
is null.
removeSelectionPaths
in interface TreeSelectableModel
paths
- the path to remove from the selection
public boolean isPathSelected(int[] path)
TreeSelectableModel
path
, is in the current selection.
isPathSelected
in interface TreeSelectableModel
public int[] getSelectionPath()
TreeSelectableModel
getSelectionPath
in interface TreeSelectableModel
public int[][] getSelectionPaths()
TreeSelectableModel
getSelectionPaths
in interface TreeSelectableModel
public int getSelectionCount()
TreeSelectableModel
getSelectionCount
in interface TreeSelectableModel
public boolean isSelectionEmpty()
TreeSelectableModel
isSelectionEmpty
in interface Selectable<E>
isSelectionEmpty
in interface TreeSelectableModel
public void clearSelection()
TreeSelectableModel
clearSelection
in interface Selectable<E>
clearSelection
in interface TreeSelectableModel
public boolean addOpenPath(int[] path)
TreeOpenableModel
path
is null.
addOpenPath
in interface TreeOpenableModel
path
- the new path to add to the current open
public boolean addOpenPaths(int[][] paths)
TreeOpenableModel
paths
is null.
addOpenPaths
in interface TreeOpenableModel
paths
- the new paths to add to the current Open
public boolean removeOpenPath(int[] path)
TreeOpenableModel
path
is null.
removeOpenPath
in interface TreeOpenableModel
path
- the path to remove from the open
public boolean removeOpenPaths(int[][] paths)
TreeOpenableModel
paths
are in the open, the TreeDataListeners are notified. This method has no
effect if paths
is null.
removeOpenPaths
in interface TreeOpenableModel
paths
- the path to remove from the open
public boolean isPathOpened(int[] path)
TreeOpenableModel
path
, is in the current open.
isPathOpened
in interface TreeOpenableModel
public int[] getOpenPath()
TreeOpenableModel
getOpenPath
in interface TreeOpenableModel
public int[][] getOpenPaths()
TreeOpenableModel
getOpenPaths
in interface TreeOpenableModel
public int getOpenCount()
TreeOpenableModel
getOpenCount
in interface TreeOpenableModel
public boolean isOpenEmpty()
TreeOpenableModel
isOpenEmpty
in interface Openable<E>
isOpenEmpty
in interface TreeOpenableModel
public void clearOpen()
TreeOpenableModel
TreeDataListener
listeners are notified.
clearOpen
in interface Openable<E>
clearOpen
in interface TreeOpenableModel
protected java.lang.Object beforeSort()
Default: saves the selection and open states.
For example, DefaultTreeModel.sort(java.util.Comparator
invokes it to preserve
the selection to the same objects (rather than the same paths).
protected void afterSort(java.lang.Object ctx)
beforeSort()
public java.util.Set<E> getSelection()
Selectable
getSelection
in interface Selectable<E>
public void setSelection(java.util.Collection<? extends E> selection)
Selectable
If this represents a change to the current selection then notify each ListDataListener, including UI.
setSelection
in interface Selectable<E>
public boolean isSelected(java.lang.Object child)
Selectable
isSelected
in interface Selectable<E>
public boolean addToSelection(E child)
Selectable
If this represents a change to the current selection then notify each ListDataListener, including UI.
addToSelection
in interface Selectable<E>
child
- the object to be as selection.
obj
is not part of the data, or was already selected.public boolean removeFromSelection(java.lang.Object child)
Selectable
If this represents a change to the current selection then notify each ListDataListener, including UI.
removeFromSelection
in interface Selectable<E>
child
- the object to be remove from selection.
public java.util.Set<E> getOpenObjects()
Openable
getOpenObjects
in interface Openable<E>
public void setOpenObjects(java.util.Collection<? extends E> opened)
Openable
setOpenObjects
in interface Openable<E>
public boolean isObjectOpened(java.lang.Object child)
Openable
isObjectOpened
in interface Openable<E>
public boolean addOpenObject(E child)
Openable
addOpenObject
in interface Openable<E>
child
- the object to be as selection.
obj
is not part of the data, or was already opened.public boolean removeOpenObject(java.lang.Object child)
Openable
removeOpenObject
in interface Openable<E>
child
- the object to be remove from selection.
public java.lang.Object clone()
clone
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |