KickJava   Java API By Example, From Geeks To Geeks.

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


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.ComplexContent;
23 import org.netbeans.modules.xml.schema.model.ComplexContentDefinition;
24 import org.netbeans.modules.xml.schema.model.ComplexContentRestriction;
25 import org.netbeans.modules.xml.schema.model.ComplexExtension;
26 import org.netbeans.modules.xml.schema.model.ComplexTypeDefinition;
27 import org.netbeans.modules.xml.schema.model.GlobalType;
28 import org.netbeans.modules.xml.schema.model.LocalComplexType;
29 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
30 import org.netbeans.modules.xml.schema.model.SimpleContent;
31 import org.netbeans.modules.xml.schema.model.SimpleContentDefinition;
32 import org.netbeans.modules.xml.schema.model.SimpleContentRestriction;
33 import org.netbeans.modules.xml.schema.model.SimpleExtension;
34 import org.netbeans.modules.xml.schema.ui.nodes.*;
35
36 import org.openide.nodes.Children;
37 import org.openide.nodes.Node.Property;
38 import org.openide.nodes.Sheet;
39 import org.openide.util.NbBundle;
40
41 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.BooleanProperty;
42 /**
43  *
44  * @author Todd Fast, todd.fast@sun.com
45  */

46 public class LocalComplexTypeNode extends SchemaComponentNode<LocalComplexType>
47 {
48     /**
49      *
50      *
51      */

52     public LocalComplexTypeNode(SchemaUIContext context,
53         SchemaComponentReference<LocalComplexType> reference,
54         Children children)
55     {
56         super(context,reference,children);
57         setIconBaseWithExtension(
58             "org/netbeans/modules/xml/schema/ui/nodes/resources/"+
59             "complextype.png");
60     }
61
62
63     protected GlobalType getSuperDefinition()
64     {
65         ComplexTypeDefinition definition = getReference().get().getDefinition();
66         GlobalType gt = null;
67         if(definition instanceof ComplexContent)
68         {
69             ComplexContentDefinition contentDef =
70                     ((ComplexContent)definition).getLocalDefinition();
71             if (contentDef instanceof ComplexContentRestriction)
72             {
73                 ComplexContentRestriction ccr = (ComplexContentRestriction)contentDef;
74                 if(ccr.getBase()!= null)
75                 {
76                     gt=ccr.getBase().get();
77                 }
78             }
79             if (contentDef instanceof ComplexExtension)
80             {
81                 ComplexExtension ce = (ComplexExtension)contentDef;
82                 if(ce.getBase()!= null)
83                 {
84                     gt=ce.getBase().get();
85                 }
86             }
87         }
88         else if(definition instanceof SimpleContent)
89         {
90             SimpleContentDefinition contentDef =
91                     ((SimpleContent)definition).getLocalDefinition();
92             if (contentDef instanceof SimpleContentRestriction)
93             {
94                 SimpleContentRestriction scr = (SimpleContentRestriction)contentDef;
95                 if(scr.getBase()!= null)
96                 {
97                     gt=scr.getBase().get();
98                 }
99             }
100             if (contentDef instanceof SimpleExtension)
101             {
102                 SimpleExtension se = (SimpleExtension)contentDef;
103                 if(se.getBase()!= null)
104                 {
105                     gt=se.getBase().get();
106                 }
107             }
108         }
109         return gt;
110     }
111
112     @Override JavaDoc
113     protected Sheet createSheet() {
114         Sheet sheet = super.createSheet();
115         Sheet.Set set = sheet.get(Sheet.PROPERTIES);
116         try {
117             // Mixed property
118
Property mixedProp = new BooleanProperty(
119                     getReference().get(), // schema component
120
LocalComplexType.MIXED_PROPERTY, // property name
121
NbBundle.getMessage(LocalComplexTypeNode.class,"PROP_Mixed_DisplayName"), // display name
122
NbBundle.getMessage(LocalComplexTypeNode.class,"PROP_Mixed_ShortDescription"), // descr
123
true // default value is false
124
);
125             set.put(new SchemaModelFlushWrapper(getReference().get(), mixedProp));
126         } catch (NoSuchMethodException JavaDoc nsme) {
127             assert false : "properties should be defined";
128         }
129         return sheet;
130     }
131     
132     
133     /**
134      *
135      *
136      */

137     @Override JavaDoc
138     public String JavaDoc getTypeDisplayName()
139     {
140         return NbBundle.getMessage(LocalComplexTypeNode.class,
141             "LBL_LocalComplexTypeNode_TypeDisplayName"); // NOI18N
142
}
143 }
144
Popular Tags