KickJava   Java API By Example, From Geeks To Geeks.

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


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

36 public class AttributeGroupReferenceNode extends SchemaComponentNode<AttributeGroupReference>
37         
38 {
39     
40     private static final String JavaDoc NAME = "attributeGroup";
41     
42     /**
43      *
44      *
45      */

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

61     protected void updateDisplayName()
62     {
63             String JavaDoc name = getSuperDefinitionName();
64             if(name==null||name.equals(""))
65                 name = NAME;
66             setDisplayName(name);
67     }
68
69
70     /**
71      *
72      *
73      */

74     public String JavaDoc getHtmlDisplayName() {
75         String JavaDoc decoration=" (-&gt;)";
76                 String JavaDoc name = getDefaultDisplayName()+" <font color='#999999'>"+decoration+"</font>";
77                 return applyHighlights(name);
78     }
79
80     /**
81      *
82      *
83      */

84     @Override JavaDoc
85     public String JavaDoc getTypeDisplayName()
86     {
87         return NbBundle.getMessage(AttributeGroupReferenceNode.class,
88             "LBL_AttributeGroupReferenceNode_TypeDisplayName"); // NOI18N
89
}
90     
91      
92     @Override JavaDoc
93     protected GlobalAttributeGroup getSuperDefinition()
94     {
95         AttributeGroupReference sc = getReference().get();
96         GlobalAttributeGroup gt = null;
97         if(sc.getGroup()!=null)
98             gt = sc.getGroup().get();
99         return gt;
100     }
101         
102         private String JavaDoc getSuperDefinitionName()
103         {
104             String JavaDoc rawString = null;
105             AttributeGroupReference sc = getReference().get();
106             GlobalAttributeGroup gt = null;
107             if(sc.getGroup()!=null)
108                 rawString = sc.getGroup().getRefString();
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 = null;
119 // try {
120
sheet = super.createSheet();
121             Sheet.Set props = sheet.get(Sheet.PROPERTIES);
122             if (props == null) {
123                 props = Sheet.createPropertiesSet();
124                 sheet.put(props);
125             }
126             
127             try {
128                 //reference property
129
Node.Property refProp = new GlobalReferenceProperty<GlobalAttributeGroup>(
130                         getReference().get(),
131                         AttributeGroupReference.GROUP_PROPERTY,
132                         NbBundle.getMessage(AttributeGroupReferenceNode.class,
133                         "PROP_Reference_DisplayName"), // display name
134
NbBundle.getMessage(AttributeGroupReferenceNode.class,
135                         "HINT_Attr_Group_Reference"), // descr
136
getTypeDisplayName(), // type display name
137
NbBundle.getMessage(AttributeGroupReferenceNode.class,
138                         "LBL_GlobalAttributeGroupNode_TypeDisplayName"), // reference type display name
139
GlobalAttributeGroup.class
140                         );
141
142                 props.put(new SchemaModelFlushWrapper(getReference().get(), refProp));
143             } catch (NoSuchMethodException JavaDoc nsme) {
144                 assert false:"properties must be defined";
145             }
146 // PropertiesNotifier.addChangeListener(listener = new
147
// ChangeListener() {
148
// public void stateChanged(ChangeEvent ev) {
149
// firePropertyChange("value", null, null);
150
// }
151
// });
152
return sheet;
153     }
154     
155 }
156
Popular Tags