KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > core > SchemaDataLoaderBeanInfo


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 package org.netbeans.modules.xml.schema.core;
20
21 import java.beans.*;
22 import java.awt.Image JavaDoc;
23 import org.openide.util.NbBundle;
24
25 import org.openide.util.Utilities;
26
27 /**
28  * Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
29  *
30  * @author Petr Kuzel
31  */

32 public class SchemaDataLoaderBeanInfo extends SimpleBeanInfo {
33
34     private static final String JavaDoc ICON_DIR_BASE = "org/netbeans/modules/xml/schema/core/resources/"; // NOI18N
35

36     // Bean descriptor//GEN-FIRST:BeanDescriptor
37
/*lazy BeanDescriptor*/;
38     private static BeanDescriptor getBdescriptor(){
39         BeanDescriptor beanDescriptor = new BeanDescriptor ( SchemaDataLoader.class , null );
40         beanDescriptor.setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "LBL_SchemaDataLoader_name") );
41         beanDescriptor.setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "LBL_SchemaDataLoader_desc") );//GEN-HEADEREND:BeanDescriptor
42

43         // Here you can add code for customizing the BeanDescriptor.
44

45         return beanDescriptor; }//GEN-LAST:BeanDescriptor
46

47     
48     // Property identifiers//GEN-FIRST:Properties
49
private static final int PROPERTY_extensions = 0;
50     private static final int PROPERTY_displayName = 1;
51     private static final int PROPERTY_representationClass = 2;
52
53     // Property array
54
/*lazy PropertyDescriptor*/;
55     private static PropertyDescriptor[] getPdescriptor(){
56         PropertyDescriptor[] properties = new PropertyDescriptor[3];
57     
58         try {
59             properties[PROPERTY_extensions] = new PropertyDescriptor ( "extensions", SchemaDataLoader.class, "getExtensions", "setExtensions" );
60             properties[PROPERTY_extensions].setPreferred ( true );
61             properties[PROPERTY_extensions].setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_extensions_name") );
62             properties[PROPERTY_extensions].setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_extensions_desc") );
63             properties[PROPERTY_displayName] = new PropertyDescriptor ( "displayName", SchemaDataLoader.class, "getDisplayName", null );
64             properties[PROPERTY_displayName].setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_dname_name") );
65             properties[PROPERTY_displayName].setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_dname_desc") );
66             properties[PROPERTY_representationClass] = new PropertyDescriptor ( "representationClass", SchemaDataLoader.class, "getRepresentationClass", null );
67             properties[PROPERTY_representationClass].setExpert ( true );
68             properties[PROPERTY_representationClass].setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_class_name") );
69             properties[PROPERTY_representationClass].setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_class_desc") );
70         }
71         catch( IntrospectionException e) {}//GEN-HEADEREND:Properties
72

73         // Here you can add code for customizing the properties array.
74

75         return properties; }//GEN-LAST:Properties
76

77     // EventSet identifiers//GEN-FIRST:Events
78

79     // EventSet array
80
/*lazy EventSetDescriptor*/;
81     private static EventSetDescriptor[] getEdescriptor(){
82         EventSetDescriptor[] eventSets = new EventSetDescriptor[0];//GEN-HEADEREND:Events
83

84         // Here you can add code for customizing the event sets array.
85

86         return eventSets; }//GEN-LAST:Events
87

88     // Method identifiers//GEN-FIRST:Methods
89

90     // Method array
91
/*lazy MethodDescriptor*/;
92     private static MethodDescriptor[] getMdescriptor(){
93         MethodDescriptor[] methods = new MethodDescriptor[0];//GEN-HEADEREND:Methods
94

95         // Here you can add code for customizing the methods array.
96

97         return methods; }//GEN-LAST:Methods
98

99     private static final int defaultPropertyIndex = -1;//GEN-BEGIN:Idx
100
private static final int defaultEventIndex = -1;//GEN-END:Idx
101

102     
103     public BeanInfo[] getAdditionalBeanInfo() {//GEN-FIRST:Superclass
104
Class JavaDoc superclass = SchemaDataLoader.class.getSuperclass();
105         BeanInfo sbi = null;
106         try {
107             sbi = Introspector.getBeanInfo(superclass);//GEN-HEADEREND:Superclass
108

109             // Here you can add code for customizing the Superclass BeanInfo.
110

111         } catch(IntrospectionException ex) { } return new BeanInfo[] { sbi }; }//GEN-LAST:Superclass
112

113     /**
114      * Gets the bean's <code>BeanDescriptor</code>s.
115      *
116      * @return BeanDescriptor describing the editable
117      * properties of this bean. May return null if the
118      * information should be obtained by automatic analysis.
119      */

120     public BeanDescriptor getBeanDescriptor() {
121         return getBdescriptor();
122     }
123     
124     /**
125      * Gets the bean's <code>PropertyDescriptor</code>s.
126      *
127      * @return An array of PropertyDescriptors describing the editable
128      * properties supported by this bean. May return null if the
129      * information should be obtained by automatic analysis.
130      * <p>
131      * If a property is indexed, then its entry in the result array will
132      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
133      * A client of getPropertyDescriptors can use "instanceof" to check
134      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
135      */

136     public PropertyDescriptor[] getPropertyDescriptors() {
137         return getPdescriptor();
138     }
139     
140     /**
141      * Gets the bean's <code>EventSetDescriptor</code>s.
142      *
143      * @return An array of EventSetDescriptors describing the kinds of
144      * events fired by this bean. May return null if the information
145      * should be obtained by automatic analysis.
146      */

147     public EventSetDescriptor[] getEventSetDescriptors() {
148         return getEdescriptor();
149     }
150     
151     /**
152      * Gets the bean's <code>MethodDescriptor</code>s.
153      *
154      * @return An array of MethodDescriptors describing the methods
155      * implemented by this bean. May return null if the information
156      * should be obtained by automatic analysis.
157      */

158     public MethodDescriptor[] getMethodDescriptors() {
159         return getMdescriptor();
160     }
161     
162     /**
163      * A bean may have a "default" property that is the property that will
164      * mostly commonly be initially chosen for update by human's who are
165      * customizing the bean.
166      * @return Index of default property in the PropertyDescriptor array
167      * returned by getPropertyDescriptors.
168      * <P> Returns -1 if there is no default property.
169      */

170     public int getDefaultPropertyIndex() {
171         return defaultPropertyIndex;
172     }
173     
174     /**
175      * A bean may have a "default" event that is the event that will
176      * mostly commonly be used by human's when using the bean.
177      * @return Index of default event in the EventSetDescriptor array
178      * returned by getEventSetDescriptors.
179      * <P> Returns -1 if there is no default event.
180      */

181     public int getDefaultEventIndex() {
182         return defaultEventIndex;
183     }
184     
185     /**
186      * This method returns an image object that can be used to
187      * represent the bean in toolboxes, toolbars, etc. Icon images
188      * will typically be GIFs, but may in future include other formats.
189      * <p>
190      * Beans aren't required to provide icons and may return null from
191      * this method.
192      * <p>
193      * There are four possible flavors of icons (16x16 color,
194      * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
195      * support a single icon we recommend supporting 16x16 color.
196      * <p>
197      * We recommend that icons have a "transparent" background
198      * so they can be rendered onto an existing background.
199      *
200      * @param iconKind The kind of icon requested. This should be
201      * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
202      * ICON_MONO_16x16, or ICON_MONO_32x32.
203      * @return An image object representing the requested icon. May
204      * return null if no suitable icon is available.
205      */

206     public Image JavaDoc getIcon (int type) {
207         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
208             (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
209
210             return Utilities.loadImage (ICON_DIR_BASE + "Schema_File.gif"); // NOI18N
211
}
212     
213     return null;
214     }
215     
216 }
217
Popular Tags