KickJava   Java API By Example, From Geeks To Geeks.

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


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  * GlobalElementsNode.java
22  *
23  * Created on September 18, 2006, 3:07 PM
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.AbstractElement;
34 import org.netbeans.modules.xml.axi.Element;
35 import org.netbeans.modules.xml.schema.model.GlobalElement;
36 import org.openide.nodes.AbstractNode;
37 import org.openide.nodes.Children;
38 import org.openide.nodes.Node;
39 import org.openide.util.NbBundle;
40
41 /**
42  *
43  * @author girix
44  */

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