1 package pl.polidea.treeview;
3 import java.io.Serializable;
6 import android.database.DataSetObserver;
9 * Manages information about state of the tree. It only keeps information about
10 * tree elements, not the elements themselves.
13 * type of the identifier for nodes in the tree
15 public interface TreeStateManager<T> extends Serializable {
18 * Returns array of integers showing the location of the node in hierarchy.
19 * It corresponds to heading numbering. {0,0,0} in 3 level node is the first
20 * node {0,0,1} is second leaf (assuming that there are two leaves in first
21 * subnode of the first node).
25 * @return textual description of the hierarchy in tree for the node.
27 Integer[] getHierarchyDescription(T id);
30 * Returns level of the node.
34 * @return level in the tree
39 * Returns information about the node.
45 TreeNodeInfo<T> getNodeInfo(T id);
48 * Returns children of the node.
51 * id of the node or null if asking for top nodes
52 * @return children of the node
54 List<T> getChildren(T id);
57 * Returns parent of the node.
61 * @return parent id or null if no parent
66 * Adds the node before child or at the beginning.
69 * id of the parent node. If null - adds at the top level
71 * new child to add if null - adds at the beginning.
73 * child before which to add the new child
75 void addBeforeChild(T parent, T newChild, T beforeChild);
78 * Adds the node after child or at the end.
81 * id of the parent node. If null - adds at the top level.
83 * new child to add. If null - adds at the end.
85 * child after which to add the new child
87 void addAfterChild(T parent, T newChild, T afterChild);
90 * Removes the node and all children from the tree.
93 * id of the node to remove or null if all nodes are to be
96 void removeNodeRecursively(T id);
99 * Expands all children of the node.
102 * node which children should be expanded. cannot be null (top
103 * nodes are always expanded!).
105 void expandDirectChildren(T id);
108 * Expands everything below the node specified. Might be null - then expands
112 * node which children should be expanded or null if all nodes
113 * are to be expanded.
115 void expandEverythingBelow(T id);
121 * id collapses everything below node specified. If null,
122 * collapses everything but top-level nodes.
124 void collapseChildren(T id);
127 * Returns next sibling of the node (or null if no further sibling).
131 * @return the sibling (or null if no next)
133 T getNextSibling(T id);
136 * Returns previous sibling of the node (or null if no previous sibling).
140 * @return the sibling (or null if no previous)
142 T getPreviousSibling(T id);
145 * Checks if given node is already in tree.
149 * @return true if node is already in tree.
151 boolean isInTree(T id);
154 * Count visible elements.
156 * @return number of currently visible elements.
158 int getVisibleCount();
161 * Returns visible node list.
163 * @return return the list of all visible nodes in the right sequence
165 List<T> getVisibleList();
168 * Registers observers with the manager.
173 void registerDataSetObserver(final DataSetObserver observer);
176 * Unregisters observers with the manager.
181 void unregisterDataSetObserver(final DataSetObserver observer);
184 * Cleans tree stored in manager. After this operation the tree is empty.
190 * Refreshes views connected to the manager.