KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > ui > nodes > schema > GlobalElementNode


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.ui.nodes.schema;
21
22 import org.netbeans.modules.xml.schema.model.GlobalElement;
23 import org.netbeans.modules.xml.schema.model.GlobalType;
24 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
25 import org.netbeans.modules.xml.schema.ui.nodes.*;
26 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.BooleanProperty;
27 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.DefaultProperty;
28 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.DerivationTypeProperty;
29 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.FixedProperty;
30 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.GlobalReferenceProperty;
31 import org.openide.nodes.Children;
32 import org.openide.nodes.Node;
33 import org.openide.nodes.Node.Property;
34 import org.openide.nodes.Sheet;
35 import org.openide.util.NbBundle;
36
37 /**
38  *
39  * @author Todd Fast, todd.fast@sun.com
40  */

41 public class GlobalElementNode extends SchemaComponentNode<GlobalElement>
42 {
43     /**
44      *
45      *
46      */

47     public GlobalElementNode(SchemaUIContext context,
48         SchemaComponentReference<GlobalElement> reference,
49         Children children)
50     {
51         super(context,reference,children);
52
53         setIconBaseWithExtension(
54             "org/netbeans/modules/xml/schema/ui/nodes/resources/element.png");
55     }
56
57
58     /**
59      *
60      *
61      */

62     @Override JavaDoc
63     public String JavaDoc getTypeDisplayName()
64     {
65         return NbBundle.getMessage(GlobalElementNode.class,
66             "LBL_GlobalElementNode_TypeDisplayName"); // NOI18N
67
}
68         
69     @Override JavaDoc
70     protected GlobalType getSuperDefinition()
71     {
72         GlobalElement sc = getReference().get();
73         GlobalType gt = null;
74         if(sc.getType()!=null)
75             gt = sc.getType().get();
76         return gt;
77     }
78     
79         @Override JavaDoc
80         protected Sheet createSheet() {
81             Sheet sheet = super.createSheet();
82             Sheet.Set set = sheet.get(Sheet.PROPERTIES);
83             try {
84                 // The methods are used because the Node.Property support for
85
// netbeans doesn't recognize the is.. for boolean properties
86

87                 // block, final needs custom editor
88

89                 // Abstract property
90
Property abstractProp = new BooleanProperty(
91                         getReference().get(), // schema component
92
GlobalElement.ABSTRACT_PROPERTY, // property name
93
NbBundle.getMessage(GlobalElementNode.class,"PROP_Abstract_DisplayName"), // display name
94
NbBundle.getMessage(GlobalElementNode.class,"PROP_Abstract_ShortDescription"), // descr
95
true // default value is false
96
);
97                 set.put(new SchemaModelFlushWrapper(getReference().get(), abstractProp));
98                 
99                 // nillable property
100
Node.Property nillableProp = new BooleanProperty(
101                         getReference().get(), // schema component
102
GlobalElement.NILLABLE_PROPERTY, // property name
103
NbBundle.getMessage(GlobalElementNode.class,"PROP_Nillable_DisplayName"), // display name
104
NbBundle.getMessage(GlobalElementNode.class,"PROP_Nillable_ShortDescription"), // descr
105
true // default value is false
106
);
107                 set.put(new SchemaModelFlushWrapper(getReference().get(),nillableProp));
108                 
109                 // fixed property
110
Node.Property fixedProp = new FixedProperty(
111                         getReference().get(), // schema component
112
NbBundle.getMessage(GlobalElementNode.class,"PROP_Fixed_DisplayName"), // display name
113
NbBundle.getMessage(GlobalElementNode.class,"PROP_Fixed_ShortDescription") // descr
114
);
115                 set.put(new SchemaModelFlushWrapper(getReference().get(),fixedProp));
116                 
117                 // default property
118
Node.Property defaultProp = new DefaultProperty(
119                         getReference().get(), // schema component
120
NbBundle.getMessage(GlobalElementNode.class,"PROP_Default_DisplayName"), // display name
121
NbBundle.getMessage(GlobalElementNode.class,"PROP_Default_ShortDescription") // descr
122
);
123                 set.put(new SchemaModelFlushWrapper(getReference().get(),defaultProp));
124
125                 // final property
126
Node.Property finalProp = new DerivationTypeProperty(
127                         getReference().get(),
128                         GlobalElement.FINAL_PROPERTY,
129                         NbBundle.getMessage(GlobalElementNode.class,"PROP_Final_DisplayName"), // display name
130
NbBundle.getMessage(GlobalElementNode.class,"HINT_Final_ShortDesc"), // descr
131
getTypeDisplayName()
132                         );
133                 set.put(new SchemaModelFlushWrapper(getReference().get(), finalProp));
134                 
135                 // block property
136
Node.Property blockProp = new DerivationTypeProperty(
137                         getReference().get(),
138                         GlobalElement.BLOCK_PROPERTY,
139                         NbBundle.getMessage(GlobalElementNode.class,"PROP_Block_DisplayName"), // display name
140
NbBundle.getMessage(GlobalElementNode.class,"HINT_Block_ShortDesc"), // descr
141
getTypeDisplayName()
142                         );
143                 set.put(new SchemaModelFlushWrapper(getReference().get(), blockProp));
144
145                 // substitutionGroup
146
Node.Property substitutionGroupProp = new GlobalReferenceProperty<GlobalElement>(
147                         getReference().get(),
148                         GlobalElement.SUBSTITUTION_GROUP_PROPERTY,
149                         NbBundle.getMessage(GlobalElementNode.class,
150                         "PROP_SubstitutionGroup_DisplayName"), // display name
151
NbBundle.getMessage(GlobalElementNode.class,
152                         "HINT_SubstitutionGroup_ShortDesc"), // descr
153
getTypeDisplayName(), // type display name
154
NbBundle.getMessage(GlobalElementNode.class,
155                         "LBL_GlobalElementNode_TypeDisplayName"), // reference type display name
156
GlobalElement.class
157                         ) {
158                             //allows null value as default value
159
public boolean supportsDefaultValue() {
160                                 return true;
161                             }
162                 };
163                 set.put(new SchemaModelFlushWrapper(getReference().get(), substitutionGroupProp));
164             } catch (NoSuchMethodException JavaDoc nsme) {
165                 assert false : "properties should be defined";
166             }
167             
168             return sheet;
169         }
170
171 }
172
Popular Tags