KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > tree > model > TreeModel


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.custom.tree.model;
17
18 import java.util.Collection JavaDoc;
19
20
21 /**
22  * @author <a HREF="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
23  * @version $Revision: 1.4 $ $Date: 2004/10/13 11:50:58 $
24  * $Log: TreeModel.java,v $
25  * Revision 1.4 2004/10/13 11:50:58 matze
26  * renamed packages to org.apache
27  *
28  * Revision 1.3 2004/07/01 21:53:04 mwessendorf
29  * ASF switch
30  *
31  * Revision 1.2 2004/05/05 00:18:56 o_rossmueller
32  * various fixes/modifications in model event handling and tree update
33  *
34  * Revision 1.1 2004/04/22 10:20:24 manolito
35  * tree component
36  *
37  */

38 public interface TreeModel
39 {
40
41     /**
42      * Return the root of the tree.
43      *
44      * @return the root of the tree or null, it this tree has no nodes
45      */

46     public Object JavaDoc getRoot();
47
48
49     /**
50      * Return the child of <code>parent</code> at index <code>index</code>
51      * in the parent's child array.
52      *
53      * @param parent a node in the tree
54      * @return the child of <code>parent</code> at index <code>index</code>
55      */

56     public Object JavaDoc getChild(Object JavaDoc parent, int index);
57
58
59     /**
60      * Answer the number of children of <code>parent</code>.
61      *
62      * @param parent a node in the tree
63      * @return the number of children of the node <code>parent</code>
64      */

65     public int getChildCount(Object JavaDoc parent);
66
67
68     /**
69      * Answer <code>true</code> if <code>node</code> is a leaf.
70      *
71      * @param node a node in the tree
72      * @return true if <code>node</code> is a leaf
73      */

74     public boolean isLeaf(Object JavaDoc node);
75
76
77     /**
78      * Called when the value for the item identified
79      * by <code>path</code> has changed to <code>newValue</code>.
80      * If <code>newValue</code> signifies a truly new value
81      * the model should post a <code>treeNodesChanged</code> event.
82      *
83      * @param path path to the node that has been altered
84      * @param newValue the new value from the TreeCellEditor
85      */

86     public void valueForPathChanged(TreePath path, Object JavaDoc newValue);
87
88
89     /**
90      * Return the index of child in parent.
91      *
92      * @param parent a node in the tree
93      * @param child the node we are interested in
94      * @return the index of the child in the parent, or -1 if either
95      * <code>child</code> or <code>parent</code> are <code>null</code>
96      */

97     public int getIndexOfChild(Object JavaDoc parent, Object JavaDoc child);
98
99
100     /**
101      * Answer the mutable collection of tree model listeners.
102      *
103      * @return
104      */

105     Collection JavaDoc getTreeModelListeners();
106 }
107
Popular Tags