KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.beans.PropertyEditorSupport JavaDoc;
23 import java.lang.reflect.InvocationTargetException JavaDoc;
24 import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
25 import org.netbeans.modules.xml.schema.model.SimpleTypeRestriction;
26 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
27 import org.netbeans.modules.xml.schema.ui.nodes.*;
28 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.GlobalReferenceProperty;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.Node;
31 import org.openide.nodes.PropertySupport;
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 SimpleTypeRestrictionNode extends SchemaComponentNode<SimpleTypeRestriction>
39 {
40     /**
41      *
42      *
43      */

44     public SimpleTypeRestrictionNode(SchemaUIContext context,
45         SchemaComponentReference<SimpleTypeRestriction> reference,
46         Children children)
47     {
48         super(context,reference,children);
49     }
50
51
52     /**
53      *
54      *
55      */

56     @Override JavaDoc
57     public String JavaDoc getTypeDisplayName()
58     {
59         return NbBundle.getMessage(SimpleTypeRestrictionNode.class,
60             "LBL_SimpleTypeRestrictionNode_TypeDisplayName"); // NOI18N
61
}
62  
63     @Override JavaDoc
64     protected Sheet createSheet() {
65         Sheet sheet = null;
66         try {
67             sheet = super.createSheet();
68             Sheet.Set props = sheet.get(Sheet.PROPERTIES);
69             if (props == null) {
70                     props = Sheet.createPropertiesSet();
71                     sheet.put(props);
72             }
73     
74             Node.Property baseTypeProp = new GlobalReferenceProperty<GlobalSimpleType>(
75                     getReference().get(),
76                     SimpleTypeRestriction.BASE_PROPERTY,
77                     NbBundle.getMessage(SimpleTypeRestrictionNode.class,
78                     "PROP_BaseType_DisplayName"), // display name
79
NbBundle.getMessage(SimpleTypeRestrictionNode.class,
80                     "HINT_BaseType__SimpleContent_ShortDesc"), // descr
81
getTypeDisplayName(), // type display name
82
NbBundle.getMessage(SimpleTypeRestrictionNode.class,
83                     "LBL_GlobalSimpleTypeNode_TypeDisplayName"), // reference type display name
84
GlobalSimpleType.class
85                     )
86             {
87                 public Object JavaDoc getValue() throws IllegalAccessException JavaDoc, InvocationTargetException JavaDoc
88                 {
89                     if(getReference().get().getBase()!= null)
90                         return super.getValue();
91                     return NbBundle.getMessage(ListNode.class,
92                             "LBL_LocalDefinition");
93                 }
94                 public boolean canWrite()
95                 {
96                     if(getReference().get().getBase()!= null)
97                         return super.canWrite();
98                     return false;
99                 }
100                 public java.beans.PropertyEditor JavaDoc getPropertyEditor()
101                 {
102                     if (getReference().get().getBase()!= null)
103                         return super.getPropertyEditor();
104                     return new PropertyEditorSupport JavaDoc(getReference().get());
105                 }
106             };
107             props.put(new SchemaModelFlushWrapper(getReference().get(), baseTypeProp));
108         } catch (NoSuchMethodException JavaDoc ex) {
109             assert false : "properties should be defined";
110         }
111         return sheet;
112     }
113
114 }
115
Popular Tags