KickJava   Java API By Example, From Geeks To Geeks.

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


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.categorized;
21
22 import java.util.List JavaDoc;
23 import org.netbeans.modules.xml.schema.model.All;
24 import org.netbeans.modules.xml.schema.model.Annotation;
25 import org.netbeans.modules.xml.schema.model.AttributeGroupReference;
26 import org.netbeans.modules.xml.schema.model.AttributeReference;
27 import org.netbeans.modules.xml.schema.model.Choice;
28 import org.netbeans.modules.xml.schema.model.ElementReference;
29 import org.netbeans.modules.xml.schema.model.Enumeration;
30 import org.netbeans.modules.xml.schema.model.GlobalAttribute;
31 import org.netbeans.modules.xml.schema.model.GlobalAttributeGroup;
32 import org.netbeans.modules.xml.schema.model.GlobalComplexType;
33 import org.netbeans.modules.xml.schema.model.GlobalElement;
34 import org.netbeans.modules.xml.schema.model.GlobalGroup;
35 import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
36 import org.netbeans.modules.xml.schema.model.GroupReference;
37 import org.netbeans.modules.xml.schema.model.Import;
38 import org.netbeans.modules.xml.schema.model.Include;
39 import org.netbeans.modules.xml.schema.model.Key;
40 import org.netbeans.modules.xml.schema.model.KeyRef;
41 import org.netbeans.modules.xml.schema.model.LocalAttribute;
42 import org.netbeans.modules.xml.schema.model.LocalComplexType;
43 import org.netbeans.modules.xml.schema.model.LocalElement;
44 import org.netbeans.modules.xml.schema.model.LocalSimpleType;
45 import org.netbeans.modules.xml.schema.model.Redefine;
46 import org.netbeans.modules.xml.schema.model.Schema;
47 import org.netbeans.modules.xml.schema.model.SchemaComponent;
48 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
49 import org.netbeans.modules.xml.schema.model.SchemaModel;
50 import org.netbeans.modules.xml.schema.model.Sequence;
51 import org.netbeans.modules.xml.schema.model.Unique;
52 import org.netbeans.modules.xml.schema.ui.nodes.SchemaNodeFactory;
53 import org.openide.nodes.Children;
54 import org.openide.nodes.Node;
55 import org.openide.util.Lookup;
56
57 /**
58  * A simple node factory that creates instances of
59  * <code>SchemaComponentNodeChildren</code> to present a structural hierarchy
60  * of schema nodes.
61  *
62  * @author Todd Fast, todd.fast@sun.com
63  */

64 public class CategorizedSchemaNodeFactory extends SchemaNodeFactory
65 {
66     /**
67      *
68      *
69      */

70     public CategorizedSchemaNodeFactory(SchemaModel model, Lookup lookup)
71     {
72         this(model,null,lookup);
73     }
74     
75     
76     /**
77      *
78      *
79      * @param filters
80      * A list of schema component types to show, or null if all
81      * children should be shown
82      */

83     public CategorizedSchemaNodeFactory(SchemaModel model,
84             List JavaDoc<Class JavaDoc<? extends SchemaComponent>> filters, Lookup lookup)
85     {
86         super(model,lookup);
87         this.filters=filters;
88     }
89     
90     
91     /**
92      *
93      *
94      */

95     public List JavaDoc<Class JavaDoc<? extends SchemaComponent>> getChildFilters()
96     {
97         return filters;
98     }
99     
100     
101     /**
102      *
103      *
104      */

105     @Override JavaDoc
106     public <C extends SchemaComponent> Children createChildren(
107             SchemaComponentReference<C> reference)
108     {
109         return new CategorizedChildren<C>(getContext(),reference,
110                 getChildFilters());
111     }
112     
113
114         public Node createPrimitiveTypesNode() {
115             return new PrimitiveSimpleTypesNode(getContext());
116         }
117     
118     
119     
120     ////////////////////////////////////////////////////////////////////////////
121
// Node factory methods
122
////////////////////////////////////////////////////////////////////////////
123

124     /**
125      *
126      *
127      */

128     @Override JavaDoc
129     protected Node createAnnotationNode(
130             SchemaComponentReference<Annotation> reference)
131     {
132         // Create our "custom" node and children instead of the default
133
Children children=new AnnotationChildren(getContext(), reference);
134         return new AdvancedAnnotationNode(getContext(),reference,children);
135     }
136     
137     /**
138      *
139      *
140      */

141     @Override JavaDoc
142     protected Node createAllNode(
143             SchemaComponentReference<All> reference)
144     {
145         // Create our "custom" node instead of the default
146
Children children=createChildren(reference);
147         return new AdvancedAllNode(getContext(),reference,children);
148     }
149     
150     
151     /**
152      *
153      *
154      */

155     protected Node createSequenceNode(
156             SchemaComponentReference<Sequence> reference)
157     {
158         Children children = new SequenceChildren<Sequence>(
159                 getContext(), reference);
160         return new AdvancedSequenceNode(getContext(), reference,
161                 children);
162     }
163     
164     
165     /**
166      *
167      *
168      */

169     protected Node createChoiceNode(
170             SchemaComponentReference<Choice> reference)
171     {
172         Children children=createChildren(reference);
173         return new AdvancedChoiceNode(getContext(),reference,children);
174     }
175     
176     
177     /**
178      *
179      *
180      */

181     protected Node createGlobalAttributeGroupNode(
182             SchemaComponentReference<GlobalAttributeGroup> reference)
183     {
184         Children children=createChildren(reference);
185         return new AdvancedGlobalAttributeGroupNode(
186                 getContext(),reference,children);
187     }
188     
189     
190     /**
191      *
192      *
193      */

194     protected Node createGlobalGroupNode(
195             SchemaComponentReference<GlobalGroup> reference)
196     {
197         Children children=createChildren(reference);
198         return new AdvancedGlobalGroupNode(
199                 getContext(),reference,children);
200     }
201     
202     
203     /**
204      *
205      *
206      */

207     protected Node createGlobalAttributeNode(
208             SchemaComponentReference<GlobalAttribute> reference)
209     {
210         Children children=createChildren(reference);
211         return new AdvancedGlobalAttributeNode(
212                 getContext(),reference,children);
213     }
214     
215     
216     /**
217      *
218      *
219      */

220     protected Node createLocalAttributeNode(
221             SchemaComponentReference<LocalAttribute> reference)
222     {
223         Children children=createChildren(reference);
224         return new AdvancedLocalAttributeNode(
225                 getContext(),reference,children);
226     }
227     
228     
229     /**
230      *
231      *
232      */

233     @Override JavaDoc
234     protected Node createGlobalElementNode(
235             SchemaComponentReference<GlobalElement> reference)
236     {
237         Children children = new ElementChildren<GlobalElement>
238                 (getContext(),reference);
239         AdvancedGlobalElementNode result=
240                 new AdvancedGlobalElementNode(getContext(),reference,children);
241         return result;
242     }
243     
244     
245     /**
246      *
247      *
248      */

249     @Override JavaDoc
250     protected Node createLocalElementNode(
251             SchemaComponentReference<LocalElement> reference)
252     {
253         Children children = new ElementChildren<LocalElement>
254                 (getContext(),reference);
255         Node result=
256                 new AdvancedLocalElementNode(getContext(),reference,children);
257         return result;
258     }
259     
260     
261     @Override JavaDoc
262     protected Node createElementReferenceNode(
263             SchemaComponentReference<ElementReference> reference) {
264         Children children = new ReferenceChildren<ElementReference>
265                 (getContext(),reference);
266         Node result=
267                 new AdvancedElementReferenceNode(getContext(),reference,children);
268         return result;
269     }
270
271     @Override JavaDoc
272     protected Node createAttributeGroupReferenceNode(
273             SchemaComponentReference<AttributeGroupReference> reference) {
274         Children children = new ReferenceChildren<AttributeGroupReference>
275                 (getContext(),reference);
276         Node result=
277                 new AdvancedAttributeGroupReferenceNode(getContext(),reference,children);
278         return result;
279     }
280
281     @Override JavaDoc
282     protected Node createGroupReferenceNode(
283             SchemaComponentReference<GroupReference> reference) {
284         Children children = new ReferenceChildren<GroupReference>
285                 (getContext(),reference);
286         Node result=
287                 new AdvancedGroupReferenceNode(getContext(),reference,children);
288         return result;
289     }
290
291     @Override JavaDoc
292     protected Node createAttributeReferenceNode(
293             SchemaComponentReference<AttributeReference> reference) {
294         Children children = new ReferenceChildren<AttributeReference>
295                 (getContext(),reference);
296         Node result=
297                 new AdvancedAttributeReferenceNode(getContext(),reference,children);
298         return result;
299     }
300
301     /**
302      *
303      *
304      */

305     @Override JavaDoc
306     protected Node createGlobalComplexTypeNode(
307             SchemaComponentReference<GlobalComplexType> reference)
308     {
309         
310         Children children = new ComplexTypeChildren<GlobalComplexType>
311                 (getContext(),reference);
312         AdvancedGlobalComplexTypeNode result=
313                 new AdvancedGlobalComplexTypeNode(getContext(),reference,children);
314         return result;
315     }
316     
317     
318     /**
319      *
320      *
321      */

322     protected Node createLocalComplexTypeNode(
323             SchemaComponentReference<LocalComplexType> reference)
324     {
325         Children children = new ComplexTypeChildren<LocalComplexType>
326                 (getContext(),reference);
327         return new AdvancedLocalComplexTypeNode(
328                 getContext(),reference,children);
329     }
330     
331     
332     /**
333      *
334      *
335      */

336     protected Node createGlobalSimpleTypeNode(
337             SchemaComponentReference<GlobalSimpleType> reference)
338     {
339         Children children = new SimpleTypeChildren<GlobalSimpleType>
340                 (getContext(),reference);
341         return new AdvancedGlobalSimpleTypeNode(
342                 getContext(),reference,children);
343     }
344     
345     
346     /**
347      *
348      *
349      */

350     protected Node createLocalSimpleTypeNode(
351             SchemaComponentReference<LocalSimpleType> reference)
352     {
353         Children children = new SimpleTypeChildren<LocalSimpleType>
354                 (getContext(),reference);
355         return new AdvancedLocalSimpleTypeNode(
356                 getContext(),reference,children);
357     }
358     
359     
360     protected Node createEnumerationNode(SchemaComponentReference<Enumeration> reference) {
361         Children children = createChildren(reference);
362         return new AdvancedEnumerationNode(getContext(),reference,children);
363     }
364
365     /**
366      *
367      *
368      */

369     protected Node createKeyNode(
370             SchemaComponentReference<Key> reference)
371     {
372         Children children = createChildren(reference);
373         return new AdvancedKeyNode(getContext(),reference,children);
374     }
375     
376     
377     /**
378      *
379      *
380      */

381     protected Node createKeyRefNode(
382             SchemaComponentReference<KeyRef> reference)
383     {
384         Children children = createChildren(reference);
385         return new AdvancedKeyRefNode(getContext(),reference,children);
386     }
387     
388     
389     /**
390      *
391      *
392      */

393     protected Node createUniqueNode(
394             SchemaComponentReference<Unique> reference)
395     {
396         Children children = createChildren(reference);
397         return new AdvancedUniqueNode(getContext(),reference,children);
398     }
399     
400     
401     /**
402      *
403      *
404      */

405     protected Node createSchemaNode(
406             SchemaComponentReference<Schema> reference)
407     {
408         Children children=createChildren(reference);
409         return new AdvancedSchemaNode(getContext(),reference,children);
410     }
411     
412     
413     /**
414      *
415      *
416      */

417     protected Node createImportNode(
418             SchemaComponentReference<Import> reference)
419     {
420         Children children = new ReferencedSchemaModelChildren<Import>
421                 (getContext(),reference);
422         return new AdvancedImportNode(getContext(),reference,children);
423     }
424     
425     
426     /**
427      *
428      *
429      */

430     protected Node createIncludeNode(
431             SchemaComponentReference<Include> reference)
432     {
433         Children children = new ReferencedSchemaModelChildren<Include>
434                 (getContext(),reference);
435         return new AdvancedIncludeNode(getContext(),reference,children);
436     }
437     
438     
439     /**
440      *
441      *
442      */

443     protected Node createRedefineNode(
444             SchemaComponentReference<Redefine> reference)
445     {
446         Children children = new ReferencedSchemaModelChildren<Redefine>
447                 (getContext(),reference);
448         return new AdvancedRedefineNode(getContext(),reference,children);
449     }
450     
451     
452     ////////////////////////////////////////////////////////////////////////////
453
// Instance members
454
////////////////////////////////////////////////////////////////////////////
455

456     private List JavaDoc<Class JavaDoc<? extends SchemaComponent>> filters;
457
458 }
459
Popular Tags