KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > abe > nodes > PrimitiveSimpleTypesNode


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 /*
21  * PrimitiveSimpleTypesNode.java
22  *
23  * Created on April 13, 2006, 9:49 AM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.schema.abe.nodes;
30
31 import java.awt.Image JavaDoc;
32 import org.netbeans.modules.xml.axi.datatype.Datatype;
33 import org.netbeans.modules.xml.axi.datatype.DatatypeFactory;
34 import org.netbeans.modules.xml.schema.model.GlobalElement;
35 import org.openide.nodes.AbstractNode;
36 import org.openide.nodes.Children;
37 import org.openide.nodes.FilterNode;
38 import org.openide.nodes.Node;
39 import org.openide.util.NbBundle;
40 import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
41 import org.netbeans.modules.xml.schema.model.SchemaModelFactory;
42
43 /**
44  *
45  * @author Ayub Khan
46  */

47 public class PrimitiveSimpleTypesNode extends AbstractNode
48 {
49     /** Creates a new instance of PrimitiveSimpleTypesNode */
50     public PrimitiveSimpleTypesNode(ABEUIContext context)
51     {
52         super(new TypesChildren(context));
53         setName(NbBundle.getMessage(PrimitiveSimpleTypesNode.class,
54                 "LBL_CategoryNode_PrimitiveSimpleTypes"));
55     }
56
57     public boolean canRename()
58     {
59         return false;
60     }
61
62     public boolean canDestroy()
63     {
64         return false;
65     }
66
67     public boolean canCut()
68     {
69         return false;
70     }
71
72     public boolean canCopy()
73     {
74         return false;
75     }
76         
77            public Image JavaDoc getOpenedIcon(int i) {
78                return org.netbeans.modules.xml.schema.ui.nodes.categorized.
79                        CategorizedChildren.getBadgedFolderIcon(i, GlobalSimpleType.class);
80            }
81            
82            public Image JavaDoc getIcon(int i) {
83                return org.netbeans.modules.xml.schema.ui.nodes.categorized.
84                        CategorizedChildren.getOpenedBadgedFolderIcon(i, GlobalSimpleType.class);
85            }
86     
87     private static class TypesChildren extends Children.Keys
88     {
89         TypesChildren(ABEUIContext context) {
90             super();
91             this.context = context;
92         }
93         protected Node[] createNodes(Object JavaDoc key)
94         {
95             if(key instanceof GlobalSimpleType)
96             {
97                 GlobalSimpleType gst = (GlobalSimpleType)key;
98                 Datatype type = DatatypeFactory.getDefault().
99                     createPrimitive(((GlobalSimpleType)gst).getName());
100                 Node node = context.getFactory().createNode(getNode(), type);
101                 return new Node[] {new TypeNode(node)};
102             }
103             assert false;
104             return new Node[]{};
105         }
106
107         protected void addNotify()
108         {
109             setKeys(SchemaModelFactory.getDefault().getPrimitiveTypesModel().
110                     getSchema().getSimpleTypes());
111         }
112         
113         private ABEUIContext context;
114     }
115     
116     public static class TypeNode extends FilterNode {
117         
118         private TypeNode(Node original)
119         {
120             super(original, Children.LEAF);
121             final String JavaDoc details = NbBundle.getMessage(
122                     PrimitiveSimpleTypesNode.class,"MSG_"+getOriginal().getName());
123             setShortDescription(details);
124         }
125         
126         public String JavaDoc getHtmlDisplayName()
127         {
128             return null;
129         }
130         
131         public Datatype getType() {
132             return ((DatatypeNode)getOriginal()).getType();
133         }
134     }
135     
136 }
137
Popular Tags