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;
44
import java.awt.Image;
45
import org.openide.util.Exceptions;
46
import org.openide.util.NbBundle;
48
import org.openide.util.Utilities;
51
* Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
55
public class SchemaDataLoaderBeanInfo extends SimpleBeanInfo {
57
private static final String ICON_DIR_BASE = "org/netbeans/modules/xml/schema/resources/"; // NOI18N
59
private static final int PROPERTY_extensions = 0;
60
private static final int PROPERTY_displayName = 1;
61
private static final int PROPERTY_representationClass = 2;
64
* Gets the bean's <code>BeanDescriptor</code>s.
66
* @return BeanDescriptor describing the editable
67
* properties of this bean. May return null if the
68
* information should be obtained by automatic analysis.
71
public BeanDescriptor getBeanDescriptor() {
72
BeanDescriptor beanDescriptor = new BeanDescriptor ( SchemaDataLoader.class , null );
73
beanDescriptor.setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "LBL_SchemaDataLoader_name") );
74
beanDescriptor.setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "LBL_SchemaDataLoader_desc") );//GEN-HEADEREND:BeanDescriptor
76
return beanDescriptor;
80
* Gets the bean's <code>PropertyDescriptor</code>s.
82
* @return An array of PropertyDescriptors describing the editable
83
* properties supported by this bean. May return null if the
84
* information should be obtained by automatic analysis.
86
* If a property is indexed, then its entry in the result array will
87
* belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
88
* A client of getPropertyDescriptors can use "instanceof" to check
89
* if a given PropertyDescriptor is an IndexedPropertyDescriptor.
91
@Override public PropertyDescriptor[] getPropertyDescriptors() {
92
PropertyDescriptor[] properties = new PropertyDescriptor[3];
95
properties[PROPERTY_extensions] = new PropertyDescriptor ( "extensions", SchemaDataLoader.class, "getExtensions", "setExtensions" );
96
properties[PROPERTY_extensions].setPreferred ( true );
97
properties[PROPERTY_extensions].setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_extensions_name") );
98
properties[PROPERTY_extensions].setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_extensions_desc") );
99
properties[PROPERTY_displayName] = new PropertyDescriptor ( "displayName", SchemaDataLoader.class, "getDisplayName", null );
100
properties[PROPERTY_displayName].setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_dname_name") );
101
properties[PROPERTY_displayName].setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_dname_desc") );
102
properties[PROPERTY_representationClass] = new PropertyDescriptor ( "representationClass", SchemaDataLoader.class, "getRepresentationClass", null );
103
properties[PROPERTY_representationClass].setExpert ( true );
104
properties[PROPERTY_representationClass].setDisplayName ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_class_name") );
105
properties[PROPERTY_representationClass].setShortDescription ( NbBundle.getMessage(SchemaDataLoaderBeanInfo.class, "PROP_SchemaDataLoader_class_desc") );
107
catch( IntrospectionException e) {
108
Exceptions.printStackTrace(e);
115
* Gets the bean's <code>EventSetDescriptor</code>s.
117
* @return An array of EventSetDescriptors describing the kinds of
118
* events fired by this bean. May return null if the information
119
* should be obtained by automatic analysis.
121
public EventSetDescriptor[] getEventSetDescriptors() {
122
return new EventSetDescriptor[0];
126
* Gets the bean's <code>MethodDescriptor</code>s.
128
* @return An array of MethodDescriptors describing the methods
129
* implemented by this bean. May return null if the information
130
* should be obtained by automatic analysis.
132
public MethodDescriptor[] getMethodDescriptors() {
133
return new MethodDescriptor[0];
137
* This method returns an image object that can be used to
138
* represent the bean in toolboxes, toolbars, etc. Icon images
139
* will typically be GIFs, but may in future include other formats.
141
* Beans aren't required to provide icons and may return null from
144
* There are four possible flavors of icons (16x16 color,
145
* 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
146
* support a single icon we recommend supporting 16x16 color.
148
* We recommend that icons have a "transparent" background
149
* so they can be rendered onto an existing background.
151
* @param iconKind The kind of icon requested. This should be
152
* one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
153
* ICON_MONO_16x16, or ICON_MONO_32x32.
154
* @return An image object representing the requested icon. May
155
* return null if no suitable icon is available.
157
public Image getIcon (int type) {
158
if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
159
(type == java.beans.BeanInfo.ICON_MONO_16x16)) {
161
return Utilities.loadImage (ICON_DIR_BASE + "Schema_File.gif"); // NOI18N