KickJava   Java API By Example, From Geeks To Geeks.

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


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.GlobalSimpleType;
23 import org.netbeans.modules.xml.schema.model.List;
24 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
25 import org.netbeans.modules.xml.schema.model.SimpleTypeDefinition;
26 import org.netbeans.modules.xml.schema.model.SimpleTypeRestriction;
27 import org.netbeans.modules.xml.schema.ui.nodes.*;
28 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.DerivationTypeProperty;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.Sheet;
31 import org.openide.nodes.Node.Property;
32 import org.openide.util.NbBundle;
33 /**
34  *
35  * @author Todd Fast, todd.fast@sun.com
36  */

37 public class GlobalSimpleTypeNode extends SchemaComponentNode<GlobalSimpleType>
38 {
39    /**
40      *
41      *
42      */

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

59     @Override JavaDoc
60     public String JavaDoc getTypeDisplayName()
61     {
62         return NbBundle.getMessage(GlobalSimpleTypeNode.class,
63             "LBL_GlobalSimpleTypeNode_TypeDisplayName"); // NOI18N
64
}
65
66     @Override JavaDoc
67     protected GlobalSimpleType getSuperDefinition()
68     {
69         SimpleTypeDefinition definition = getReference().get().getDefinition();
70         GlobalSimpleType gt = null;
71         if(definition instanceof SimpleTypeRestriction)
72         {
73             SimpleTypeRestriction str = (SimpleTypeRestriction)definition;
74             if(str.getBase()!=null)
75             {
76                 gt = str.getBase().get();
77             }
78         }
79         if(definition instanceof List)
80         {
81             List list = (List)definition;
82             GlobalSimpleType gst = null;
83             if(list.getType()!=null)
84             {
85                 gt = list.getType().get();
86             }
87         }
88         return gt;
89     }
90         
91     protected String JavaDoc getSuperDefinitionName()
92     {
93         String JavaDoc rawString = null;
94         SimpleTypeDefinition definition = getReference().get().getDefinition();
95         GlobalSimpleType gt = null;
96         if(definition instanceof SimpleTypeRestriction) {
97             SimpleTypeRestriction str = (SimpleTypeRestriction)definition;
98             if(str.getBase()!=null) {
99                 rawString = str.getBase().getRefString();
100             }
101         }
102         if(definition instanceof List) {
103             List list = (List)definition;
104             GlobalSimpleType gst = null;
105             if(list.getType()!=null) {
106                 rawString = list.getType().getRefString();
107             }
108         }
109         int i = rawString!=null?rawString.indexOf(':'):-1;
110         if (i != -1 && i < rawString.length()) {
111             rawString = rawString.substring(i);
112         }
113         return rawString;
114     }
115     
116     @Override JavaDoc
117     protected Sheet createSheet() {
118         Sheet sheet = super.createSheet();
119         Sheet.Set set = sheet.get(Sheet.PROPERTIES);
120         try {
121             // final property
122
Property finalProp = new DerivationTypeProperty(
123                     getReference().get(),
124                     GlobalSimpleType.FINAL_PROPERTY,
125                     NbBundle.getMessage(GlobalSimpleTypeNode.class,"PROP_Final_DisplayName"), // display name
126
NbBundle.getMessage(GlobalSimpleTypeNode.class,"HINT_Final_ShortDesc"), // descr
127
getTypeDisplayName()
128                     );
129             set.put(new SchemaModelFlushWrapper(getReference().get(), finalProp));
130             
131         } catch (NoSuchMethodException JavaDoc nsme) {
132             assert false : "properties should be defined";
133         }
134         
135         return sheet;
136     }
137 }
138
Popular Tags