KickJava   Java API By Example, From Geeks To Geeks.

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


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  * GlobalAttributesNode.java
22  *
23  * Created on September 18, 2006, 3:59 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.Attribute;
34 import org.netbeans.modules.xml.schema.model.GlobalAttribute;
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
40 /**
41  *
42  * @author girix
43  */

44 public class GlobalAttributesNode extends AbstractNode{
45     
46     /** Creates a new instance of ABEDocumentNode */
47     public GlobalAttributesNode(ABEUIContext context, AXIDocument document){
48         super(new GlobalAttributes(context, document));
49         setName(NbBundle.getMessage(GlobalContentModelsNode.class,
50                 "LBL_CategoryNode_GlobalAttributesNode"));
51     }
52     
53     public boolean canRename() {
54         return false;
55     }
56     
57     public boolean canDestroy() {
58         return false;
59     }
60     
61     public boolean canCut() {
62         return false;
63     }
64     
65     public boolean canCopy() {
66         return false;
67     }
68
69     public Image JavaDoc getOpenedIcon(int i) {
70         return org.netbeans.modules.xml.schema.ui.nodes.categorized.
71                 CategorizedChildren.getBadgedFolderIcon(i, GlobalAttribute.class);
72     }
73
74     public Image JavaDoc getIcon(int i) {
75         return org.netbeans.modules.xml.schema.ui.nodes.categorized.
76                 CategorizedChildren.getOpenedBadgedFolderIcon(i, GlobalAttribute.class);
77     }
78     
79     
80     
81     private static class GlobalAttributes extends Children.Keys {
82         GlobalAttributes(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 Attribute) {
89                 Node node = context.getFactory().createNode(getNode(), (Attribute)key);
90                 return new Node[] {node};
91             }
92             assert false;
93             return new Node[]{};
94         }
95         
96         protected void addNotify() {
97             setKeys(document.getAttributes());
98         }
99         
100         private AXIDocument document;
101         private ABEUIContext context;
102     }
103     
104     
105 }
106
Popular Tags