KickJava   Java API By Example, From Geeks To Geeks.

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


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

44 public class LocalElementNode extends SchemaComponentNode<LocalElement>
45 {
46     /**
47      *
48      *
49      */

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

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

88         // nillable property
89
Node.Property nillableProp = new BooleanProperty(
90         getReference().get(), // schema component
91
LocalElement.NILLABLE_PROPERTY, // property name
92
NbBundle.getMessage(LocalElementNode.class,"PROP_Nillable_DisplayName"), // display name
93
NbBundle.getMessage(LocalElementNode.class,"PROP_Nillable_ShortDescription"), // descr
94
true // default value is false
95
);
96         set.put(new SchemaModelFlushWrapper(getReference().get(),nillableProp));
97         
98         // fixed property
99
Node.Property fixedProp = new FixedProperty(
100         getReference().get(), // schema component
101
NbBundle.getMessage(LocalElementNode.class,"PROP_Fixed_DisplayName"), // display name
102
NbBundle.getMessage(LocalElementNode.class,"PROP_Fixed_ShortDescription") // descr
103
);
104         set.put(new SchemaModelFlushWrapper(getReference().get(),fixedProp));
105         
106         // default property
107
Node.Property defaultProp = new DefaultProperty(
108         getReference().get(), // schema component
109
NbBundle.getMessage(LocalElementNode.class,"PROP_Default_DisplayName"), // display name
110
NbBundle.getMessage(LocalElementNode.class,"PROP_Default_ShortDescription") // descr
111
);
112         set.put(new SchemaModelFlushWrapper(getReference().get(),defaultProp));
113         
114         if (getReference().get().allowsFullMultiplicity()) {
115         
116         // maxOccurs
117
Property maxOccursProp = new BaseSchemaProperty(
118             getReference().get(), // schema component
119
String JavaDoc.class,
120             LocalElement.MAX_OCCURS_PROPERTY,
121             NbBundle.getMessage(LocalElementNode.class,"PROP_MaxOccurs_DisplayName"), // display name
122
NbBundle.getMessage(LocalElementNode.class,"PROP_MaxOccurs_ShortDescription"), // descr
123
MaxOccursEditor.class
124             );
125         set.put(new SchemaModelFlushWrapper(getReference().get(), maxOccursProp));
126         
127         }
128         //TODO
129
// if (getReference().get().allowsFullMultiplicity()) {
130
// Add code here to support only zero or one for min occurs
131
// }
132

133         // minOccurs
134
Property minOccursProp = new NonNegativeIntegerProperty(
135         getReference().get(), // schema component
136
LocalElement.MIN_OCCURS_PROPERTY,
137         NbBundle.getMessage(LocalElementNode.class,"PROP_MinOccurs_DisplayName"), // display name
138
NbBundle.getMessage(LocalElementNode.class,"PROP_MinOccurs_ShortDescription") // descr
139
);
140         set.put(new SchemaModelFlushWrapper(getReference().get(), minOccursProp));
141         
142         // form property
143
Node.Property formProp = new FormProperty(
144                 getReference().get(), // schema component
145
LocalElement.FORM_PROPERTY, //property name
146
NbBundle.getMessage(LocalElementNode.class,"PROP_Form_DisplayName"), // display name
147
NbBundle.getMessage(LocalElementNode.class,"PROP_Form_ElementShortDescription") // descr
148
);
149         set.put(new SchemaModelFlushWrapper(getReference().get(),formProp));
150         
151         // block property
152
Node.Property blockProp = new DerivationTypeProperty(
153                 getReference().get(),
154                 LocalElement.BLOCK_PROPERTY,
155                 NbBundle.getMessage(LocalElementNode.class,"PROP_Block_DisplayName"), // display name
156
NbBundle.getMessage(LocalElementNode.class,"HINT_Block_ShortDesc"), // descr
157
getTypeDisplayName()
158                 );
159         set.put(new SchemaModelFlushWrapper(getReference().get(), blockProp));
160         
161         
162     } catch (NoSuchMethodException JavaDoc nsme) {
163         assert false : "properties should be defined";
164     }
165     
166     return sheet;
167     }
168
169 }
170
Popular Tags