KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > SchemaLoaderBeanInfo


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.schema;
20
21 import java.beans.*;
22 import java.awt.Image JavaDoc;
23 import org.openide.loaders.UniFileLoader;
24 import org.openide.util.Exceptions;
25
26 import org.openide.util.Utilities;
27
28 /**
29  * Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
30  *
31  * @author Petr Kuzel
32  */

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

37     private static final int PROPERTY_extensions = 0;
38     private static final int PROPERTY_displayName = 1;
39     private static final int PROPERTY_representationClass = 2;
40
41     public BeanInfo[] getAdditionalBeanInfo() {
42         BeanInfo sbi = null;
43         try {
44             sbi = Introspector.getBeanInfo(UniFileLoader.class);//GEN-HEADEREND:Superclass
45
} catch(IntrospectionException ex) {
46             Exceptions.printStackTrace(ex);
47         }
48         return new BeanInfo[] { sbi }; }//GEN-LAST:Superclass
49

50     /**
51      * Gets the bean's <code>BeanDescriptor</code>s.
52      *
53      * @return BeanDescriptor describing the editable
54      * properties of this bean. May return null if the
55      * information should be obtained by automatic analysis.
56      */

57     public BeanDescriptor getBeanDescriptor() {
58         BeanDescriptor beanDescriptor = new BeanDescriptor ( SchemaLoader.class , null );
59         beanDescriptor.setDisplayName ( Util.THIS.getString("SchemaLoader_name") );
60         beanDescriptor.setShortDescription ( Util.THIS.getString("SchemaLoader_desc") );//GEN-HEADEREND:BeanDescriptor
61

62         // Here you can add code for customizing the BeanDescriptor.
63

64         return beanDescriptor;
65     }
66     
67     /**
68      * Gets the bean's <code>PropertyDescriptor</code>s.
69      *
70      * @return An array of PropertyDescriptors describing the editable
71      * properties supported by this bean. May return null if the
72      * information should be obtained by automatic analysis.
73      * <p>
74      * If a property is indexed, then its entry in the result array will
75      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
76      * A client of getPropertyDescriptors can use "instanceof" to check
77      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
78      */

79     public PropertyDescriptor[] getPropertyDescriptors() {
80         PropertyDescriptor[] properties = new PropertyDescriptor[3];
81     
82         try {
83             properties[PROPERTY_extensions] = new PropertyDescriptor ( "extensions", SchemaLoader.class, "getExtensions", "setExtensions" );
84             properties[PROPERTY_extensions].setPreferred ( true );
85             properties[PROPERTY_extensions].setDisplayName ( Util.THIS.getString("PROP_SchemaLoader_extensions_name") );
86             properties[PROPERTY_extensions].setShortDescription ( Util.THIS.getString("PROP_SchemaLoader_extensions_desc") );
87             properties[PROPERTY_displayName] = new PropertyDescriptor ( "displayName", SchemaLoader.class, "getDisplayName", null );
88             properties[PROPERTY_displayName].setDisplayName ( Util.THIS.getString("PROP_SchemaLoader_dname_name") );
89             properties[PROPERTY_displayName].setShortDescription ( Util.THIS.getString("PROP_SchemaLoader_dname_desc") );
90             properties[PROPERTY_representationClass] = new PropertyDescriptor ( "representationClass", SchemaLoader.class, "getRepresentationClass", null );
91             properties[PROPERTY_representationClass].setExpert ( true );
92             properties[PROPERTY_representationClass].setDisplayName ( Util.THIS.getString("PROP_SchemaLoader_class_name") );
93             properties[PROPERTY_representationClass].setShortDescription ( Util.THIS.getString("PROP_SchemaLoader_class_desc") );
94         }
95         catch( IntrospectionException e) {
96             Exceptions.printStackTrace(e);
97         }
98         
99         // Here you can add code for customizing the properties array.
100

101         return properties;
102     }
103     
104     /**
105      * Gets the bean's <code>EventSetDescriptor</code>s.
106      *
107      * @return An array of EventSetDescriptors describing the kinds of
108      * events fired by this bean. May return null if the information
109      * should be obtained by automatic analysis.
110      */

111     public EventSetDescriptor[] getEventSetDescriptors() {
112         EventSetDescriptor[] eventSets = new EventSetDescriptor[0];
113         
114         // Here you can add code for customizing the event sets array.
115

116         return eventSets;
117     }
118     
119     /**
120      * Gets the bean's <code>MethodDescriptor</code>s.
121      *
122      * @return An array of MethodDescriptors describing the methods
123      * implemented by this bean. May return null if the information
124      * should be obtained by automatic analysis.
125      */

126     public MethodDescriptor[] getMethodDescriptors() {
127         MethodDescriptor[] methods = new MethodDescriptor[0];
128         return methods;
129     }
130     
131     /**
132      * This method returns an image object that can be used to
133      * represent the bean in toolboxes, toolbars, etc. Icon images
134      * will typically be GIFs, but may in future include other formats.
135      * <p>
136      * Beans aren't required to provide icons and may return null from
137      * this method.
138      * <p>
139      * There are four possible flavors of icons (16x16 color,
140      * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
141      * support a single icon we recommend supporting 16x16 color.
142      * <p>
143      * We recommend that icons have a "transparent" background
144      * so they can be rendered onto an existing background.
145      *
146      * @param iconKind The kind of icon requested. This should be
147      * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
148      * ICON_MONO_16x16, or ICON_MONO_32x32.
149      * @return An image object representing the requested icon. May
150      * return null if no suitable icon is available.
151      */

152     public Image JavaDoc getIcon (int type) {
153         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
154             (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
155
156             return Utilities.loadImage (ICON_DIR_BASE + "xmlSchemaObject.gif"); // NOI18N
157
} else {
158             return Utilities.loadImage (ICON_DIR_BASE + "xmlSchemaObject32.gif"); // NOI18N
159
}
160     }
161     
162 }
163
Popular Tags