KickJava   Java API By Example, From Geeks To Geeks.

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


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.AXIDocument;
33 import org.netbeans.modules.xml.axi.datatype.CustomDatatype;
34 import org.netbeans.modules.xml.axi.datatype.DatatypeFactory;
35 import org.openide.nodes.AbstractNode;
36 import org.openide.nodes.Children;
37 import org.openide.nodes.Node;
38 import org.openide.util.NbBundle;
39 import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
40
41 /**
42  *
43  * @author Ayub Khan
44  */

45 public class SimpleTypesNode extends AbstractNode
46 {
47     /** Creates a new instance of PrimitiveSimpleTypesNode */
48     public SimpleTypesNode(ABEUIContext context, AXIDocument document)
49     {
50         super(new TypesChildren(context, document));
51         setName(NbBundle.getMessage(PrimitiveSimpleTypesNode.class,
52                 "LBL_CategoryNode_SimpleTypesNode"));
53     }
54
55     public boolean canRename()
56     {
57         return false;
58     }
59
60     public boolean canDestroy()
61     {
62         return false;
63     }
64
65     public boolean canCut()
66     {
67         return false;
68     }
69
70     public boolean canCopy()
71     {
72         return false;
73     }
74     
75             public Image JavaDoc getOpenedIcon(int i) {
76                 return org.netbeans.modules.xml.schema.ui.nodes.categorized.
77                         CategorizedChildren.getBadgedFolderIcon(i, GlobalSimpleType.class);
78             }
79             
80             public Image JavaDoc getIcon(int i) {
81                 return org.netbeans.modules.xml.schema.ui.nodes.categorized.
82                         CategorizedChildren.getOpenedBadgedFolderIcon(i, GlobalSimpleType.class);
83             }
84         
85     private static class TypesChildren extends Children.Keys
86     {
87         TypesChildren(ABEUIContext context, AXIDocument document) {
88             super();
89             this.context = context;
90                         this.document = document;
91         }
92         protected Node[] createNodes(Object JavaDoc key)
93         {
94             if(key instanceof GlobalSimpleType)
95             {
96                 CustomDatatype type =
97                     (CustomDatatype) DatatypeFactory.getDefault().getDatatype(
98                         document.getModel(), (GlobalSimpleType)key);
99                 Node node = context.getFactory().createNode(getNode(), type);
100                 return new Node[] {node};
101             }
102             assert false;
103             return new Node[]{};
104         }
105
106         protected void addNotify()
107         {
108             setKeys(document.getModel().getSchemaModel().getSchema().getSimpleTypes());
109         }
110         
111         private AXIDocument document;
112         private ABEUIContext context;
113     }
114     
115 }
116
Popular Tags