KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.netbeans.modules.xml.schema.model.*;
23 import org.netbeans.modules.xml.schema.ui.nodes.schema.*;
24 import org.openide.nodes.Children;
25 import org.openide.nodes.Node;
26 import org.openide.util.Lookup;
27
28 /**
29  *
30  * @author Todd Fast, todd.fast@sun.com
31  */

32 public abstract class SchemaNodeFactory extends Object JavaDoc {
33
34     /**
35      *
36      *
37      */

38     public SchemaNodeFactory(SchemaModel model, Lookup lookup)
39     {
40         super();
41         context=createContext(model,lookup);
42     }
43
44     /**
45      * Creates the SchemaUIContext. Subclasses can override this method to
46      * customize the SchemaUIContext instance.
47      *
48      */

49     protected SchemaUIContext createContext(SchemaModel model, Lookup lookup)
50     {
51         return new SchemaUIContext(model,this,lookup);
52     }
53
54
55     /**
56      * Returns the context object used by this factory. All nodes created by
57      * this factory will share this context object.
58      *
59      */

60     public SchemaUIContext getContext()
61     {
62         return context;
63     }
64
65     /**
66      * Convenience method to create a "root" node for representing the schema.
67      * This method is a convenience for calling <code>createNode()</code> and
68      * passing it a reference to the <code>Schema</code> component.
69      *
70      */

71     public SchemaNode createRootNode()
72     {
73 // SchemaComponentReference<Schema> reference=
74
// SchemaComponentReference.create(
75
// getContext().getModel().getSchema());
76
return (SchemaNode)createNode(getContext().getModel().getSchema());
77     }
78
79
80
81
82     ////////////////////////////////////////////////////////////////////////////
83
// Primary factory methods
84
////////////////////////////////////////////////////////////////////////////
85

86     /**
87      * Creates a node for the specified schema component
88      *
89      */

90     public Node createNode(SchemaComponent component)
91     {
92         CreateSchemaComponentNodeVisitor cscnv = new CreateSchemaComponentNodeVisitor();
93         return cscnv.createNode(this,component);
94     }
95
96         /**
97          * Create the node to represent the set of built-in simple types
98          * (referred to as "primitive" types).
99          *
100          * @return container node for the primitive simple types.
101          */

102         public abstract Node createPrimitiveTypesNode();
103
104     /**
105      * Creates the children object for the specified component reference. The
106      * defalut implementation returns <code>Children.LEAF</code>, meaning that
107      * any nodes created via <code>createNode()</code> will be lead nodes with
108      * no sub-structure. Subclasses should override this method to return
109      * more functional children objects.<p>
110      *
111      * Note, this method is only used by convention by methods in this class;
112      * subclasses are free to create and use any children object in the
113      * various node factory methods. This method provides a way to override
114      * the default children created by this class, but its use by particular
115      * node factory methods is not guaranteed.
116      *
117      * @param parent
118      * The parent node of the about-to-be created node for which this
119      * method will return the children object. Note, this node is
120      * <em>not</em> the node with which the return children object
121      * will be associated.
122      * @param reference
123      * The schema component reference associated with the about-to-be-
124      * created node.
125      */

126     public <C extends SchemaComponent> Children createChildren(
127             SchemaComponentReference<C> reference)
128     {
129         return Children.LEAF;
130     }
131
132
133     ////////////////////////////////////////////////////////////////////////////
134
// Node factory methods
135
////////////////////////////////////////////////////////////////////////////
136

137     /**
138      *
139      *
140      */

141     protected Node createAllNode(
142         SchemaComponentReference<All> reference)
143     {
144         Children children=createChildren(reference);
145         return new AllNode(getContext(),reference,children);
146     }
147
148
149     /**
150      *
151      *
152      */

153     protected Node createAnnotationNode(
154         SchemaComponentReference<Annotation> reference)
155     {
156         Children children=createChildren(reference);
157         return new AnnotationNode(getContext(),reference,children);
158     }
159
160
161     /**
162      *
163      *
164      */

165     protected Node createAnyNode(
166         SchemaComponentReference<AnyElement> reference)
167     {
168         Children children=createChildren(reference);
169         return new AnyNode(getContext(),reference,children);
170     }
171
172
173     /**
174      *
175      *
176      */

177     protected Node createAnyAttributeNode(
178         SchemaComponentReference<AnyAttribute> reference)
179     {
180         Children children=createChildren(reference);
181         return new AnyAttributeNode(getContext(),reference,children);
182     }
183
184
185     /**
186      *
187      *
188      */

189     protected Node createAttributeGroupReferenceNode(
190         SchemaComponentReference<AttributeGroupReference> reference)
191     {
192         Children children=createChildren(reference);
193         return new AttributeGroupReferenceNode(getContext(),reference,children);
194     }
195
196
197     /**
198      *
199      *
200      */

201     protected Node createChoiceNode(
202         SchemaComponentReference<Choice> reference)
203     {
204         Children children=createChildren(reference);
205         return new ChoiceNode(getContext(),reference,children);
206     }
207
208
209     /**
210      *
211      *
212      */

213     protected Node createComplexContentNode(
214         SchemaComponentReference<ComplexContent> reference)
215     {
216         Children children=createChildren(reference);
217         return new ComplexContentNode(getContext(),reference,children);
218     }
219
220
221     /**
222      *
223      *
224      */

225     protected Node createComplexContentRestrictionNode(
226         SchemaComponentReference<ComplexContentRestriction> reference)
227     {
228         Children children=createChildren(reference);
229         return new ComplexContentRestrictionNode(getContext(),reference,children);
230     }
231
232
233     /**
234      *
235      *
236      */

237     protected Node createComplexExtensionNode(
238         SchemaComponentReference<ComplexExtension> reference)
239     {
240         Children children=createChildren(reference);
241         return new ComplexExtensionNode(getContext(),reference,children);
242     }
243
244
245     /**
246      *
247      *
248      */

249     protected Node createDocumentationNode(
250         SchemaComponentReference<Documentation> reference)
251     {
252         Children children=createChildren(reference);
253         return new DocumentationNode(getContext(),reference,children);
254     }
255
256
257     /**
258      *
259      *
260      */

261     protected Node createAppInfoNode(
262         SchemaComponentReference<AppInfo> reference)
263     {
264         Children children=createChildren(reference);
265         return new AppInfoNode(getContext(),reference,children);
266     }
267
268
269     /**
270      *
271      *
272      */

273     protected Node createEnumerationNode(
274         SchemaComponentReference<Enumeration> reference)
275     {
276         Children children=createChildren(reference);
277         return new EnumerationNode(getContext(),reference,children);
278     }
279
280
281     /**
282      *
283      *
284      */

285     protected Node createFieldNode(
286         SchemaComponentReference<Field> reference)
287     {
288         Children children=createChildren(reference);
289         return new FieldNode(getContext(),reference,children);
290     }
291
292
293     /**
294      *
295      *
296      */

297     protected Node createFractionDigitsNode(
298         SchemaComponentReference<FractionDigits> reference)
299     {
300         Children children=createChildren(reference);
301         return new FractionDigitsNode(getContext(),reference,children);
302     }
303
304
305     /**
306      *
307      *
308      */

309     protected Node createGlobalAttributeNode(
310         SchemaComponentReference<GlobalAttribute> reference)
311     {
312         Children children=createChildren(reference);
313         return new GlobalAttributeNode(getContext(),reference,children);
314     }
315
316
317     /**
318      *
319      *
320      */

321     protected Node createGlobalAttributeGroupNode(
322         SchemaComponentReference<GlobalAttributeGroup> reference)
323     {
324         Children children=createChildren(reference);
325         return new GlobalAttributeGroupNode(getContext(),reference,children);
326     }
327
328
329     /**
330      *
331      *
332      */

333     protected Node createGlobalComplexTypeNode(
334         SchemaComponentReference<GlobalComplexType> reference)
335     {
336         Children children=createChildren(reference);
337         return new GlobalComplexTypeNode(getContext(),reference,children);
338     }
339
340
341     /**
342      *
343      *
344      */

345     protected Node createGlobalElementNode(
346         SchemaComponentReference<GlobalElement> reference)
347     {
348         Children children=createChildren(reference);
349         return new GlobalElementNode(getContext(),reference,children);
350     }
351
352
353     /**
354      *
355      *
356      */

357     protected Node createGlobalGroupNode(
358         SchemaComponentReference<GlobalGroup> reference)
359     {
360         Children children=createChildren(reference);
361         return new GlobalGroupNode(getContext(),reference,children);
362     }
363
364
365     /**
366      *
367      *
368      */

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

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

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

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

417     protected Node createKeyNode(
418         SchemaComponentReference<Key> reference)
419     {
420         Children children=createChildren(reference);
421         return new KeyNode(getContext(),reference,children);
422     }
423
424
425     /**
426      *
427      *
428      */

429     protected Node createKeyRefNode(
430         SchemaComponentReference<KeyRef> reference)
431     {
432         Children children=createChildren(reference);
433         return new KeyRefNode(getContext(),reference,children);
434     }
435
436
437     /**
438      *
439      *
440      */

441     protected Node createLengthNode(
442         SchemaComponentReference<Length> reference)
443     {
444         Children children=createChildren(reference);
445         return new LengthNode(getContext(),reference,children);
446     }
447
448
449     /**
450      *
451      *
452      */

453     protected Node createListNode(
454         SchemaComponentReference<List> reference)
455     {
456         Children children=createChildren(reference);
457         return new ListNode(getContext(),reference,children);
458     }
459
460
461     /**
462      *
463      *
464      */

465     protected Node createLocalAttributeNode(
466         SchemaComponentReference<LocalAttribute> reference)
467     {
468         Children children=createChildren(reference);
469         return new LocalAttributeNode(getContext(),reference,children);
470     }
471
472     /**
473      *
474      *
475      */

476     protected Node createAttributeReferenceNode(
477         SchemaComponentReference<AttributeReference> reference)
478     {
479         Children children=createChildren(reference);
480         return new AttributeReferenceNode(getContext(),reference,children);
481     }
482
483     /**
484      *
485      *
486      */

487     protected Node createLocalComplexTypeNode(
488         SchemaComponentReference<LocalComplexType> reference)
489     {
490         Children children=createChildren(reference);
491         return new LocalComplexTypeNode(getContext(),reference,children);
492     }
493
494
495     /**
496      *
497      *
498      */

499     protected Node createLocalElementNode(
500         SchemaComponentReference<LocalElement> reference)
501     {
502         Children children=createChildren(reference);
503         return new LocalElementNode(getContext(),reference,children);
504     }
505     
506     /**
507      *
508      *
509      */

510     protected Node createElementReferenceNode(
511         SchemaComponentReference<ElementReference> reference)
512     {
513         Children children=createChildren(reference);
514         return new ElementReferenceNode(getContext(),reference,children);
515     }
516
517
518     /**
519      *
520      *
521      */

522     protected Node createLocalSimpleTypeNode(
523         SchemaComponentReference<LocalSimpleType> reference)
524     {
525         Children children=createChildren(reference);
526         return new LocalSimpleTypeNode(getContext(),reference,children);
527     }
528
529
530     /**
531      *
532      *
533      */

534     protected Node createMaxExclusiveNode(
535         SchemaComponentReference<MaxExclusive> reference)
536     {
537         Children children=createChildren(reference);
538         return new MaxExclusiveNode(getContext(),reference,children);
539     }
540
541
542     /**
543      *
544      *
545      */

546     protected Node createMaxInclusiveNode(
547         SchemaComponentReference<MaxInclusive> reference)
548     {
549         Children children=createChildren(reference);
550         return new MaxInclusiveNode(getContext(),reference,children);
551     }
552
553
554     /**
555      *
556      *
557      */

558     protected Node createMaxLengthNode(
559         SchemaComponentReference<MaxLength> reference)
560     {
561         Children children=createChildren(reference);
562         return new MaxLengthNode(getContext(),reference,children);
563     }
564
565
566     /**
567      *
568      *
569      */

570     protected Node createMinInclusiveNode(
571         SchemaComponentReference<MinInclusive> reference)
572     {
573         Children children=createChildren(reference);
574         return new MinInclusiveNode(getContext(),reference,children);
575     }
576
577
578     /**
579      *
580      *
581      */

582     protected Node createMinExclusiveNode(
583         SchemaComponentReference<MinExclusive> reference)
584     {
585         Children children=createChildren(reference);
586         return new MinExclusiveNode(getContext(),reference,children);
587     }
588
589
590     /**
591      *
592      *
593      */

594     protected Node createMinLengthNode(
595         SchemaComponentReference<MinLength> reference)
596     {
597         Children children=createChildren(reference);
598         return new MinLengthNode(getContext(),reference,children);
599     }
600
601
602     /**
603      *
604      *
605      */

606     protected Node createNotationNode(
607         SchemaComponentReference<Notation> reference)
608     {
609         Children children=createChildren(reference);
610         return new NotationNode(getContext(),reference,children);
611     }
612
613
614     /**
615      *
616      *
617      */

618     protected Node createPatternNode(
619         SchemaComponentReference<Pattern> reference)
620     {
621         Children children=createChildren(reference);
622         return new PatternNode(getContext(),reference,children);
623     }
624
625
626     /**
627      *
628      *
629      */

630     protected Node createRedefineNode(
631         SchemaComponentReference<Redefine> reference)
632     {
633         Children children=createChildren(reference);
634         return new RedefineNode(getContext(),reference,children);
635     }
636
637
638     /**
639      *
640      *
641      */

642     protected Node createSchemaNode(
643         SchemaComponentReference<Schema> reference)
644     {
645         Children children=createChildren(reference);
646         return new SchemaNode(getContext(),reference,children);
647     }
648
649
650     /**
651      *
652      *
653      */

654     protected Node createSequenceNode(
655         SchemaComponentReference<Sequence> reference)
656     {
657         Children children=createChildren(reference);
658         return new SequenceNode(getContext(),reference,children);
659     }
660
661
662     /**
663      *
664      *
665      */

666     protected Node createSelectorNode(
667         SchemaComponentReference<Selector> reference)
668     {
669         Children children=createChildren(reference);
670         return new SelectorNode(getContext(),reference,children);
671     }
672
673
674     /**
675      *
676      *
677      */

678     protected Node createSimpleContentNode(
679         SchemaComponentReference<SimpleContent> reference)
680     {
681         Children children=createChildren(reference);
682         return new SimpleContentNode(getContext(),reference,children);
683     }
684
685
686     /**
687      *
688      *
689      */

690     protected Node createSimpleContentRestrictionNode(
691         SchemaComponentReference<SimpleContentRestriction> reference)
692     {
693         Children children=createChildren(reference);
694         return new SimpleContentRestrictionNode(getContext(),reference,children);
695     }
696
697
698     /**
699      *
700      *
701      */

702     protected Node createSimpleExtensionNode(
703         SchemaComponentReference<SimpleExtension> reference)
704     {
705         Children children=createChildren(reference);
706         return new SimpleExtensionNode(getContext(),reference,children);
707     }
708
709
710     /**
711      *
712      *
713      */

714     protected Node createSimpleTypeRestrictionNode(
715         SchemaComponentReference<SimpleTypeRestriction> reference)
716     {
717         Children children=createChildren(reference);
718         return new SimpleTypeRestrictionNode(getContext(),reference,children);
719     }
720
721
722     /**
723      *
724      *
725      */

726     protected Node createTotalDigitsNode(
727         SchemaComponentReference<TotalDigits> reference)
728     {
729         Children children=createChildren(reference);
730         return new TotalDigitsNode(getContext(),reference,children);
731     }
732
733
734     /**
735      *
736      *
737      */

738     protected Node createUnionNode(
739         SchemaComponentReference<Union> reference)
740     {
741         Children children=createChildren(reference);
742         return new UnionNode(getContext(),reference,children);
743     }
744
745
746     /**
747      *
748      *
749      */

750     protected Node createUniqueNode(
751         SchemaComponentReference<Unique> reference)
752     {
753         Children children=createChildren(reference);
754         return new UniqueNode(getContext(),reference,children);
755     }
756
757
758     /**
759      *
760      *
761      */

762     protected Node createWhitespaceNode(
763         SchemaComponentReference<Whitespace> reference)
764     {
765         Children children=createChildren(reference);
766         return new WhitespaceNode(getContext(),reference,children);
767     }
768
769
770
771
772     ////////////////////////////////////////////////////////////////////////////
773
// Instance members
774
////////////////////////////////////////////////////////////////////////////
775

776     private SchemaUIContext context;
777 }
778
Popular Tags