KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Filters content of some original tree of nodes (represented by
26  * {@link TreeModel}).
27  *
28  * @author Jan Jancura
29  */

30 public interface TreeModelFilter extends Model {
31
32
33     /**
34      * Returns filtered root of hierarchy.
35      *
36      * @param original the original tree model
37      * @return filtered root of hierarchy
38      */

39     public abstract Object JavaDoc getRoot (TreeModel original);
40
41     /**
42      * Returns filtered children for given parent on given indexes.
43      * Typically you should get original nodes
44      * (<code>original.getChildren (...)</code>), and modify them, or return
45      * it without modifications. You should not throw UnknownTypeException
46      * directly from this method!
47      *
48      * @param original the original tree model
49      * @param parent a parent of returned nodes
50      * @throws UnknownTypeException this exception can be thrown from
51      * <code>original.getChildren (...)</code> method call only!
52      *
53      * @return children for given parent on given indexes
54      */

55     public abstract Object JavaDoc[] getChildren (
56         TreeModel original,
57         Object JavaDoc parent,
58         int from,
59         int to
60     ) throws UnknownTypeException;
61     
62     /**
63      * Returns number of filterred children for given node.
64      *
65      * @param original the original tree model
66      * @param node the parent node
67      * @throws UnknownTypeException if this TreeModel implementation is not
68      * able to resolve children for given node type
69      *
70      * @return true if node is leaf
71      */

72     public abstract int getChildrenCount (
73         TreeModel original,
74         Object JavaDoc node
75     ) throws UnknownTypeException;
76     
77     /**
78      * Returns true if node is leaf. You should not throw UnknownTypeException
79      * directly from this method!
80      *
81      * @param original the original tree model
82      * @throws UnknownTypeException this exception can be thrown from
83      * <code>original.isLeaf (...)</code> method call only!
84      * @return true if node is leaf
85      */

86     public abstract boolean isLeaf (
87         TreeModel original,
88         Object JavaDoc node
89     ) throws UnknownTypeException;
90
91     /**
92      * Registers given listener.
93      *
94      * @param l the listener to add
95      */

96     public abstract void addModelListener (ModelListener l);
97
98     /**
99      * Unregisters given listener.
100      *
101      * @param l the listener to remove
102      */

103     public abstract void removeModelListener (ModelListener l);
104 }
105
Popular Tags