2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
41
package org.netbeans.modules.xml.schema.core;
44
import java.awt.Image;
45
import org.openide.util.NbBundle;
47
import org.openide.util.Utilities;
50
* Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
54
public class SchemaDataLoaderBeanInfo extends SimpleBeanInfo {
56
private static final String ICON_DIR_BASE = "org/netbeans/modules/xml/schema/core/resources/"; // NOI18N
58
// Bean descriptor//GEN-FIRST:BeanDescriptor
59
/*lazy BeanDescriptor*/;
60
private static BeanDescriptor getBdescriptor(){
61
BeanDescriptor beanDescriptor = new BeanDescriptor ( SchemaDataLoader.class , null );
62
beanDescriptor.setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "LBL_SchemaDataLoader_name") );
63
beanDescriptor.setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "LBL_SchemaDataLoader_desc") );//GEN-HEADEREND:BeanDescriptor
65
// Here you can add code for customizing the BeanDescriptor.
67
return beanDescriptor; }//GEN-LAST:BeanDescriptor
70
// Property identifiers//GEN-FIRST:Properties
71
private static final int PROPERTY_extensions = 0;
72
private static final int PROPERTY_displayName = 1;
73
private static final int PROPERTY_representationClass = 2;
76
/*lazy PropertyDescriptor*/;
77
private static PropertyDescriptor[] getPdescriptor(){
78
PropertyDescriptor[] properties = new PropertyDescriptor[3];
81
properties[PROPERTY_extensions] = new PropertyDescriptor ( "extensions", SchemaDataLoader.class, "getExtensions", "setExtensions" );
82
properties[PROPERTY_extensions].setPreferred ( true );
83
properties[PROPERTY_extensions].setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_extensions_name") );
84
properties[PROPERTY_extensions].setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_extensions_desc") );
85
properties[PROPERTY_displayName] = new PropertyDescriptor ( "displayName", SchemaDataLoader.class, "getDisplayName", null );
86
properties[PROPERTY_displayName].setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_dname_name") );
87
properties[PROPERTY_displayName].setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_dname_desc") );
88
properties[PROPERTY_representationClass] = new PropertyDescriptor ( "representationClass", SchemaDataLoader.class, "getRepresentationClass", null );
89
properties[PROPERTY_representationClass].setExpert ( true );
90
properties[PROPERTY_representationClass].setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_class_name") );
91
properties[PROPERTY_representationClass].setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_class_desc") );
93
catch( IntrospectionException e) {}//GEN-HEADEREND:Properties
95
// Here you can add code for customizing the properties array.
97
return properties; }//GEN-LAST:Properties
99
// EventSet identifiers//GEN-FIRST:Events
102
/*lazy EventSetDescriptor*/;
103
private static EventSetDescriptor[] getEdescriptor(){
104
EventSetDescriptor[] eventSets = new EventSetDescriptor[0];//GEN-HEADEREND:Events
106
// Here you can add code for customizing the event sets array.
108
return eventSets; }//GEN-LAST:Events
110
// Method identifiers//GEN-FIRST:Methods
113
/*lazy MethodDescriptor*/;
114
private static MethodDescriptor[] getMdescriptor(){
115
MethodDescriptor[] methods = new MethodDescriptor[0];//GEN-HEADEREND:Methods
117
// Here you can add code for customizing the methods array.
119
return methods; }//GEN-LAST:Methods
121
private static final int defaultPropertyIndex = -1;//GEN-BEGIN:Idx
122
private static final int defaultEventIndex = -1;//GEN-END:Idx
125
public BeanInfo[] getAdditionalBeanInfo() {//GEN-FIRST:Superclass
126
Class superclass = SchemaDataLoader.class.getSuperclass();
129
sbi = Introspector.getBeanInfo(superclass);//GEN-HEADEREND:Superclass
131
// Here you can add code for customizing the Superclass BeanInfo.
133
} catch(IntrospectionException ex) { } return new BeanInfo[] { sbi }; }//GEN-LAST:Superclass
136
* Gets the bean's <code>BeanDescriptor</code>s.
138
* @return BeanDescriptor describing the editable
139
* properties of this bean. May return null if the
140
* information should be obtained by automatic analysis.
142
public BeanDescriptor getBeanDescriptor() {
143
return getBdescriptor();
147
* Gets the bean's <code>PropertyDescriptor</code>s.
149
* @return An array of PropertyDescriptors describing the editable
150
* properties supported by this bean. May return null if the
151
* information should be obtained by automatic analysis.
153
* If a property is indexed, then its entry in the result array will
154
* belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
155
* A client of getPropertyDescriptors can use "instanceof" to check
156
* if a given PropertyDescriptor is an IndexedPropertyDescriptor.
158
public PropertyDescriptor[] getPropertyDescriptors() {
159
return getPdescriptor();
163
* Gets the bean's <code>EventSetDescriptor</code>s.
165
* @return An array of EventSetDescriptors describing the kinds of
166
* events fired by this bean. May return null if the information
167
* should be obtained by automatic analysis.
169
public EventSetDescriptor[] getEventSetDescriptors() {
170
return getEdescriptor();
174
* Gets the bean's <code>MethodDescriptor</code>s.
176
* @return An array of MethodDescriptors describing the methods
177
* implemented by this bean. May return null if the information
178
* should be obtained by automatic analysis.
180
public MethodDescriptor[] getMethodDescriptors() {
181
return getMdescriptor();
185
* A bean may have a "default" property that is the property that will
186
* mostly commonly be initially chosen for update by human's who are
187
* customizing the bean.
188
* @return Index of default property in the PropertyDescriptor array
189
* returned by getPropertyDescriptors.
190
* <P> Returns -1 if there is no default property.
192
public int getDefaultPropertyIndex() {
193
return defaultPropertyIndex;
197
* A bean may have a "default" event that is the event that will
198
* mostly commonly be used by human's when using the bean.
199
* @return Index of default event in the EventSetDescriptor array
200
* returned by getEventSetDescriptors.
201
* <P> Returns -1 if there is no default event.
203
public int getDefaultEventIndex() {
204
return defaultEventIndex;
208
* This method returns an image object that can be used to
209
* represent the bean in toolboxes, toolbars, etc. Icon images
210
* will typically be GIFs, but may in future include other formats.
212
* Beans aren't required to provide icons and may return null from
215
* There are four possible flavors of icons (16x16 color,
216
* 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
217
* support a single icon we recommend supporting 16x16 color.
219
* We recommend that icons have a "transparent" background
220
* so they can be rendered onto an existing background.
222
* @param iconKind The kind of icon requested. This should be
223
* one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
224
* ICON_MONO_16x16, or ICON_MONO_32x32.
225
* @return An image object representing the requested icon. May
226
* return null if no suitable icon is available.
228
public Image getIcon (int type) {
229
if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
230
(type == java.beans.BeanInfo.ICON_MONO_16x16)) {
232
return Utilities.loadImage (ICON_DIR_BASE + "Schema_File.gif"); // NOI18N