create changelog entry
[debian/openrocket] / android-libraries / TreeViewList / src / pl / polidea / treeview / TreeStateManager.java
1 package pl.polidea.treeview;
2
3 import java.io.Serializable;
4 import java.util.List;
5
6 import android.database.DataSetObserver;
7
8 /**
9  * Manages information about state of the tree. It only keeps information about
10  * tree elements, not the elements themselves.
11  * 
12  * @param <T>
13  *            type of the identifier for nodes in the tree
14  */
15 public interface TreeStateManager<T> extends Serializable {
16
17     /**
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).
22      * 
23      * @param id
24      *            id of the node
25      * @return textual description of the hierarchy in tree for the node.
26      */
27     Integer[] getHierarchyDescription(T id);
28
29     /**
30      * Returns level of the node.
31      * 
32      * @param id
33      *            id of the node
34      * @return level in the tree
35      */
36     int getLevel(T id);
37
38     /**
39      * Returns information about the node.
40      * 
41      * @param id
42      *            node id
43      * @return node info
44      */
45     TreeNodeInfo<T> getNodeInfo(T id);
46
47     /**
48      * Returns children of the node.
49      * 
50      * @param id
51      *            id of the node or null if asking for top nodes
52      * @return children of the node
53      */
54     List<T> getChildren(T id);
55
56     /**
57      * Returns parent of the node.
58      * 
59      * @param id
60      *            id of the node
61      * @return parent id or null if no parent
62      */
63     T getParent(T id);
64
65     /**
66      * Adds the node before child or at the beginning.
67      * 
68      * @param parent
69      *            id of the parent node. If null - adds at the top level
70      * @param newChild
71      *            new child to add if null - adds at the beginning.
72      * @param beforeChild
73      *            child before which to add the new child
74      */
75     void addBeforeChild(T parent, T newChild, T beforeChild);
76
77     /**
78      * Adds the node after child or at the end.
79      * 
80      * @param parent
81      *            id of the parent node. If null - adds at the top level.
82      * @param newChild
83      *            new child to add. If null - adds at the end.
84      * @param afterChild
85      *            child after which to add the new child
86      */
87     void addAfterChild(T parent, T newChild, T afterChild);
88
89     /**
90      * Removes the node and all children from the tree.
91      * 
92      * @param id
93      *            id of the node to remove or null if all nodes are to be
94      *            removed.
95      */
96     void removeNodeRecursively(T id);
97
98     /**
99      * Expands all children of the node.
100      * 
101      * @param id
102      *            node which children should be expanded. cannot be null (top
103      *            nodes are always expanded!).
104      */
105     void expandDirectChildren(T id);
106
107     /**
108      * Expands everything below the node specified. Might be null - then expands
109      * all.
110      * 
111      * @param id
112      *            node which children should be expanded or null if all nodes
113      *            are to be expanded.
114      */
115     void expandEverythingBelow(T id);
116
117     /**
118      * Collapse children.
119      * 
120      * @param id
121      *            id collapses everything below node specified. If null,
122      *            collapses everything but top-level nodes.
123      */
124     void collapseChildren(T id);
125
126     /**
127      * Returns next sibling of the node (or null if no further sibling).
128      * 
129      * @param id
130      *            node id
131      * @return the sibling (or null if no next)
132      */
133     T getNextSibling(T id);
134
135     /**
136      * Returns previous sibling of the node (or null if no previous sibling).
137      * 
138      * @param id
139      *            node id
140      * @return the sibling (or null if no previous)
141      */
142     T getPreviousSibling(T id);
143
144     /**
145      * Checks if given node is already in tree.
146      * 
147      * @param id
148      *            id of the node
149      * @return true if node is already in tree.
150      */
151     boolean isInTree(T id);
152
153     /**
154      * Count visible elements.
155      * 
156      * @return number of currently visible elements.
157      */
158     int getVisibleCount();
159
160     /**
161      * Returns visible node list.
162      * 
163      * @return return the list of all visible nodes in the right sequence
164      */
165     List<T> getVisibleList();
166
167     /**
168      * Registers observers with the manager.
169      * 
170      * @param observer
171      *            observer
172      */
173     void registerDataSetObserver(final DataSetObserver observer);
174
175     /**
176      * Unregisters observers with the manager.
177      * 
178      * @param observer
179      *            observer
180      */
181     void unregisterDataSetObserver(final DataSetObserver observer);
182
183     /**
184      * Cleans tree stored in manager. After this operation the tree is empty.
185      * 
186      */
187     void clear();
188
189     /**
190      * Refreshes views connected to the manager.
191      */
192     void refresh();
193 }