KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > ui > nodes > FilteredSchemaComponentNodeChildren


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.schema.ui.nodes;
21
22 import java.util.*;
23 import org.netbeans.modules.xml.schema.model.SchemaComponent;
24 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
25
26 /**
27  * A children object that shows only a single type of child
28  *
29  * @author Todd Fast, todd.fast@sun.com
30  */

31 public class FilteredSchemaComponentNodeChildren<C extends SchemaComponent>
32     extends SchemaComponentNodeChildren<C>
33 {
34     /**
35      *
36      *
37      */

38     public <T extends SchemaComponent> FilteredSchemaComponentNodeChildren(
39         SchemaUIContext context, SchemaComponentReference<C> reference,
40         Class JavaDoc<T> childType, Comparator<SchemaComponent> comparator)
41     {
42         super(context,reference);
43         this.childType=childType;
44         this.comparator=comparator;
45     }
46
47     
48     /**
49      * The type of child to create
50      *
51      */

52     public Class JavaDoc<? extends SchemaComponent> getChildType()
53     {
54         return childType;
55     }
56
57
58     /**
59      *
60      *
61      */

62     public Comparator<SchemaComponent> getComparator()
63     {
64         return comparator;
65     }
66
67
68     /**
69      *
70      *
71      */

72     @Override JavaDoc
73     public void refreshChildren()
74     {
75         C parentComponent=getReference().get();
76
77         List<SchemaComponent> children=new java.util.ArrayList JavaDoc<SchemaComponent>(
78             parentComponent.getChildren(getChildType()));
79
80 // // Build a list of references for the children of the parent component
81
// List<SchemaComponentReference> references=
82
// new ArrayList<SchemaComponentReference>();
83
// for (SchemaComponent component: children)
84
// {
85
// references.add(SchemaComponentReference.create(component));
86
// }
87
//
88
if (getComparator()!=null)
89             Collections.sort(children,getComparator());
90
91         setKeys(children);
92     }
93
94
95
96
97     ////////////////////////////////////////////////////////////////////////////
98
// Instance members
99
////////////////////////////////////////////////////////////////////////////
100

101     private Class JavaDoc<? extends SchemaComponent> childType;
102     private Comparator<SchemaComponent> comparator;
103 }
104
Popular Tags