KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > viewmodel > TreeModel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.spi.viewmodel;
21
22
23
24 /**
25  * Defines data model for tree.
26  *
27  * @author Jan Jancura
28  */

29 public interface TreeModel extends Model {
30
31     /**
32      * Constant for root node. This root node should be used if root node
33      * does not represent any valuable information and should not be visible in
34      * tree.
35      */

36     public static final String JavaDoc ROOT = "Root";
37
38     /**
39      * Returns the root node of the tree or null, if the tree is empty.
40      *
41      * @return the root node of the tree or null
42      */

43     public abstract Object JavaDoc getRoot ();
44     
45     /**
46      * Returns children for given parent on given indexes.
47      *
48      * @param parent a parent of returned nodes
49      * @param from a start index
50      * @param to a end index
51      *
52      * @throws UnknownTypeException if this TreeModel implementation is not
53      * able to resolve children for given node type
54      *
55      * @return children for given parent on given indexes
56      */

57     public abstract Object JavaDoc[] getChildren (Object JavaDoc parent, int from, int to)
58         throws UnknownTypeException;
59     
60     /**
61      * Returns true if node is leaf.
62      *
63      * @throws UnknownTypeException if this TreeModel implementation is not
64      * able to resolve dchildren for given node type
65      * @return true if node is leaf
66      */

67     public abstract boolean isLeaf (Object JavaDoc node) throws UnknownTypeException;
68     
69     /**
70      * Returns number of children for given node.
71      *
72      * @param node the parent node
73      * @throws UnknownTypeException if this TreeModel implementation is not
74      * able to resolve children for given node type
75      *
76      * @return the children count
77      * @since 1.1
78      */

79     public abstract int getChildrenCount (Object JavaDoc node)
80     throws UnknownTypeException;
81
82     /**
83      * Registers given listener.
84      *
85      * @param l the listener to add
86      */

87     public abstract void addModelListener (ModelListener l);
88
89     /**
90      * Unregisters given listener.
91      *
92      * @param l the listener to remove
93      */

94     public abstract void removeModelListener (ModelListener l);
95 }
96
Popular Tags