KickJava   Java API By Example, From Geeks To Geeks.

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


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.openide.nodes.Node;
24 import org.openide.util.NbBundle;
25 import org.netbeans.modules.xml.schema.model.Element;
26 import org.netbeans.modules.xml.schema.model.GlobalElement;
27 import org.netbeans.modules.xml.schema.model.LocalElement;
28 import org.netbeans.modules.xml.schema.model.GlobalType;
29 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
30 import org.netbeans.modules.xml.schema.ui.nodes.SchemaUIContext;
31
32 /**
33  *
34  * @author Ajit Bhate
35  */

36 public class ElementChildren<C extends Element>
37         extends CategorizedChildren<C>
38 {
39     /**
40      *
41      *
42      */

43     public ElementChildren(SchemaUIContext context,
44             SchemaComponentReference<C> reference) {
45         super(context,reference);
46     }
47     
48     
49     /**
50      *
51      *
52      */

53     protected List JavaDoc<Node> createKeys() {
54         List JavaDoc<Node> keys=super.createKeys();
55         
56         int index=0;
57         
58         // Insert the inherited node after the details node
59
if (keys.size() > 0 && keys.get(0) instanceof DetailsNode)
60             index=1;
61         
62         GlobalType superType = null;
63         if(getReference().get() instanceof GlobalElement) {
64             GlobalElement element = (GlobalElement) getReference().get();
65             if(element.getType()!=null)
66                 superType = element.getType().get();
67         } else if(getReference().get() instanceof LocalElement) {
68             LocalElement element = (LocalElement) getReference().get();
69             if(element.getType()!=null)
70                 superType = element.getType().get();
71         }
72         if (superType != null) {
73             // Create a readonly node to show the supertype's content
74
keys.add(index, new ReadOnlySchemaComponentNode(
75                     getContext().getFactory().createNode(superType),
76                     NbBundle.getMessage(ElementChildren.class,
77                     "LBL_InheritedFrom")));
78         }
79         return keys;
80     }
81 }
82
Popular Tags