KickJava   Java API By Example, From Geeks To Geeks.

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


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.GlobalGroup;
23 import org.netbeans.modules.xml.schema.model.GroupReference;
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.GlobalReferenceProperty;
29 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.NonNegativeIntegerProperty;
30 import org.openide.nodes.Children;
31 import org.openide.nodes.Node;
32 import org.openide.nodes.Sheet;
33 import org.openide.util.NbBundle;
34 /**
35  *
36  * @author Todd Fast, todd.fast@sun.com
37  */

38 public class GroupReferenceNode extends SchemaComponentNode<GroupReference>
39 {
40     private static final String JavaDoc NAME = "group";
41     /**
42      *
43      *
44      */

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

60     @Override JavaDoc
61     public String JavaDoc getTypeDisplayName()
62     {
63         return NbBundle.getMessage(GroupReferenceNode.class,
64             "LBL_GroupReferenceNode_TypeDisplayName"); // NOI18N
65
}
66      
67     @Override JavaDoc
68     protected GlobalGroup getSuperDefinition()
69     {
70         GroupReference sc = getReference().get();
71         GlobalGroup gt = null;
72         if(sc.getRef()!=null)
73             gt = sc.getRef().get();
74         return gt;
75     }
76
77     @Override JavaDoc
78     protected Sheet createSheet() {
79     Sheet sheet = null;
80                 
81          try {
82             sheet = super.createSheet();
83             Sheet.Set props = sheet.get(Sheet.PROPERTIES);
84             if (props == null) {
85                 props = Sheet.createPropertiesSet();
86                 sheet.put(props);
87             }
88             
89             Node.Property minOccursProp = new NonNegativeIntegerProperty(
90                     getReference().get(), // SchemaComponent
91
GroupReference.MIN_OCCURS_PROPERTY,
92                     NbBundle.getMessage(GroupReferenceNode.class,"PROP_MinOccurs_DisplayName"), // display name
93
NbBundle.getMessage(GroupReferenceNode.class,"PROP_MinOccurs_ShortDescription") // descr
94
);
95             props.put(new SchemaModelFlushWrapper(getReference().get(), minOccursProp));
96
97                 // maxOccurs
98
Property maxOccursProp = new BaseSchemaProperty(
99                         getReference().get(), // schema component
100
String JavaDoc.class,
101                         GroupReference.MAX_OCCURS_PROPERTY,
102                         NbBundle.getMessage(GroupReferenceNode.class,"PROP_MaxOccurs_DisplayName"), // display name
103
NbBundle.getMessage(GroupReferenceNode.class,"PROP_MaxOccurs_ShortDescription"), // descr
104
MaxOccursEditor.class
105                         );
106             props.put(new SchemaModelFlushWrapper(getReference().get(), maxOccursProp));
107
108             //reference property
109
Node.Property refProp = new GlobalReferenceProperty<GlobalGroup>(
110                     getReference().get(),
111                     GroupReference.REF_PROPERTY,
112                     NbBundle.getMessage(GroupReferenceNode.class,
113                     "PROP_Reference_DisplayName"), // display name
114
NbBundle.getMessage(GroupReferenceNode.class,
115                     "HINT_Group_Reference"), // descr
116
getTypeDisplayName(), // type display name
117
NbBundle.getMessage(GroupReferenceNode.class,
118                     "LBL_GlobalGroupNode_TypeDisplayName"), // reference type display name
119
GlobalGroup.class
120                     );
121
122                 props.put(new SchemaModelFlushWrapper(getReference().get(), refProp));
123          } catch (NoSuchMethodException JavaDoc nsme) {
124                 assert false : "properties should be defined";
125             }
126             
127             return sheet;
128     }
129
130     /**
131      * The display name is name of reference if present
132      *
133      */

134     protected void updateDisplayName()
135     {
136         GlobalGroup ref = getSuperDefinition();
137         String JavaDoc name = ref==null?null:ref.getName();
138         if(name==null||name.equals(""))
139             name = NAME;
140         setDisplayName(name);
141     }
142 }
143
Popular Tags