KickJava   Java API By Example, From Geeks To Geeks.

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


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.List;
26 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
27 import org.netbeans.modules.xml.schema.ui.basic.editors.GlobalReferenceEditor;
28 import org.netbeans.modules.xml.schema.ui.nodes.*;
29 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.GlobalReferenceProperty;
30 import org.openide.nodes.Children;
31 import org.openide.nodes.Node;
32 import org.openide.nodes.PropertySupport;
33 import org.openide.nodes.Sheet;
34 import org.openide.util.NbBundle;
35 /**
36  *
37  * @author Todd Fast, todd.fast@sun.com
38  */

39 public class ListNode extends SchemaComponentNode<List>
40 {
41     /**
42      *
43      *
44      */

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

57     @Override JavaDoc
58     public String JavaDoc getTypeDisplayName()
59     {
60         return NbBundle.getMessage(ListNode.class,
61             "LBL_ListNode_TypeDisplayName"); // NOI18N
62
}
63
64     @Override JavaDoc
65     protected Sheet createSheet()
66     {
67         Sheet 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         try {
74             // Item Type property
75
Node.Property baseTypeProp = new GlobalReferenceProperty<GlobalSimpleType>(
76                     getReference().get(),
77                     List.TYPE_PROPERTY,
78                     NbBundle.getMessage(ListNode.class,
79                     "PROP_ItemType_DisplayName"), // display name
80
NbBundle.getMessage(ListNode.class,
81                     "PROP_ItemType_ShortDesc"), // descr
82
getTypeDisplayName(), // type display name
83
NbBundle.getMessage(ListNode.class,
84                     "LBL_GlobalSimpleTypeNode_TypeDisplayName"), // reference type display name
85
GlobalSimpleType.class
86                     )
87             {
88                 public Object JavaDoc getValue() throws IllegalAccessException JavaDoc, InvocationTargetException JavaDoc
89                 {
90                     if(getReference().get().getType()!= null)
91                         return super.getValue();
92                     return NbBundle.getMessage(ListNode.class,
93                             "LBL_LocalDefinition");
94                 }
95                 public boolean canWrite()
96                 {
97                     if(getReference().get().getType()!= null)
98                         return super.canWrite();
99                     return false;
100                 }
101                 public java.beans.PropertyEditor JavaDoc getPropertyEditor()
102                 {
103                     if (getReference().get().getType()!= null)
104                         return super.getPropertyEditor();
105                     return new PropertyEditorSupport JavaDoc(getReference().get());
106                 }
107             };
108             props.put(new SchemaModelFlushWrapper(getReference().get(), baseTypeProp));
109         } catch (NoSuchMethodException JavaDoc nsme) {
110             assert false : "properties should be defined";
111         }
112         
113 // PropertiesNotifier.addChangeListener(listener = new
114
// ChangeListener() {
115
// public void stateChanged(ChangeEvent ev) {
116
// firePropertyChange("value", null, null);
117
// }
118
// });
119
return sheet;
120     }
121 }
122
Popular Tags