KickJava   Java API By Example, From Geeks To Geeks.

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


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.abe.nodes;
21
22 import java.awt.Image JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.List JavaDoc;
25 import org.netbeans.modules.xml.axi.AXIDocument;
26 import org.netbeans.modules.xml.axi.ContentModel;
27 import org.netbeans.modules.xml.schema.model.GlobalComplexType;
28 import org.openide.nodes.AbstractNode;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.Node;
31 import org.openide.util.NbBundle;
32
33 /**
34  * This node represents a category node.
35  * @author Chris Webster
36  */

37 public class GlobalContentModelsNode extends AbstractNode {
38     
39     /** Creates a new instance of ABEDocumentNode */
40     public GlobalContentModelsNode(ABEUIContext context, AXIDocument document) {
41         super(new ContentModels(context, document));
42         setName(NbBundle.getMessage(GlobalContentModelsNode.class,
43                 "LBL_CategoryNode_GlobalContentModelsNode"));
44     }
45
46     public boolean canRename()
47     {
48         return false;
49     }
50
51     public boolean canDestroy()
52     {
53         return false;
54     }
55
56     public boolean canCut()
57     {
58         return false;
59     }
60
61     public boolean canCopy()
62     {
63         return false;
64     }
65         
66         public Image JavaDoc getOpenedIcon(int i) {
67             return org.netbeans.modules.xml.schema.ui.nodes.categorized.
68                     CategorizedChildren.getBadgedFolderIcon(i, GlobalComplexType.class);
69         }
70         
71         public Image JavaDoc getIcon(int i) {
72             return org.netbeans.modules.xml.schema.ui.nodes.categorized.
73                     CategorizedChildren.getOpenedBadgedFolderIcon(i, GlobalComplexType.class);
74         }
75     
76     private static class ContentModels extends Children.Keys
77     {
78         ContentModels(ABEUIContext context, AXIDocument document) {
79             super();
80             this.context = context;
81                         this.document = document;
82         }
83         protected Node[] createNodes(Object JavaDoc key)
84         {
85             if(key instanceof ContentModel)
86             {
87                 Node node = context.getFactory().createNode(getNode(), (ContentModel)key);
88                 return new Node[] {node};
89             }
90             assert false;
91             return new Node[]{};
92         }
93
94         protected void addNotify()
95         {
96                     List JavaDoc <ContentModel> list = document.getContentModels();
97                     List JavaDoc<ContentModel> list2 = new ArrayList JavaDoc<ContentModel>();
98                     for(ContentModel cm : list){
99                         if(cm.getType() == ContentModel.ContentModelType.COMPLEX_TYPE)
100                             list2.add(cm);
101                     }
102                     setKeys(list2);
103         }
104         
105         private AXIDocument document;
106         private ABEUIContext context;
107     }
108         
109 }
110
Popular Tags