KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > css > CSSLoaderBeanInfo


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

31 public class CSSLoaderBeanInfo extends SimpleBeanInfo {
32
33     static final String JavaDoc ICON_DIR_BASE = "org/netbeans/modules/css/resources/"; // NOI18N
34

35     private static final String JavaDoc PROP_EXT = Util.THIS.getString("PROP_Extensions"); // NOI18N
36
private static final String JavaDoc HINT_EXT = Util.THIS.getString("HINT_Extensions"); // NOI18N
37

38
39     /**
40      * Gets the bean's <code>PropertyDescriptor</code>s.
41      *
42      * @return An array of PropertyDescriptors describing the editable
43      * properties supported by this bean. May return null if the
44      * information should be obtained by automatic analysis.
45      * <p>
46      * If a property is indexed, then its entry in the result array will
47      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
48      * A client of getPropertyDescriptors can use "instanceof" to check
49      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
50      */

51     public PropertyDescriptor[] getPropertyDescriptors() {
52         int PROPERTY_extensions = 0;
53         PropertyDescriptor[] properties = new PropertyDescriptor[1];
54         
55         try {
56             properties[PROPERTY_extensions] = new PropertyDescriptor ( "extensions", CSSLoader.class, "getExtensions", "setExtensions" ); // NOI18N
57
properties[PROPERTY_extensions].setDisplayName ( PROP_EXT );
58             properties[PROPERTY_extensions].setShortDescription ( HINT_EXT );
59         } catch( IntrospectionException e) {}
60             
61         return properties;
62     }
63
64     /**
65      * Gets the bean's <code>EventSetDescriptor</code>s.
66      *
67      * @return An array of EventSetDescriptors describing the kinds of
68      * events fired by this bean. May return null if the information
69      * should be obtained by automatic analysis.
70      */

71     public EventSetDescriptor[] getEventSetDescriptors() {
72         int EVENT_propertyChangeListener = 0;
73         EventSetDescriptor[] eventSets = new EventSetDescriptor[1];
74         
75         try {
76             eventSets[EVENT_propertyChangeListener] = new EventSetDescriptor ( CSSLoader.class, "propertyChangeListener", java.beans.PropertyChangeListener JavaDoc.class, new String JavaDoc[] {"propertyChange"}, "addPropertyChangeListener", "removePropertyChangeListener" ); // NOI18N
77
} catch( IntrospectionException e) {}
78         return eventSets;
79     }
80
81     /**
82      * Gets the bean's <code>MethodDescriptor</code>s.
83      *
84      * @return An array of MethodDescriptors describing the methods
85      * implemented by this bean. May return null if the information
86      * should be obtained by automatic analysis.
87      */

88     public MethodDescriptor[] getMethodDescriptors() {
89         return new MethodDescriptor[0];
90     }
91
92     /**
93      * This method returns an image object that can be used to
94      * represent the bean in toolboxes, toolbars, etc. Icon images
95      * will typically be GIFs, but may in future include other formats.
96      * <p>
97      * Beans aren't required to provide icons and may return null from
98      * this method.
99      * <p>
100      * There are four possible flavors of icons (16x16 color,
101      * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
102      * support a single icon we recommend supporting 16x16 color.
103      * <p>
104      * We recommend that icons have a "transparent" background
105      * so they can be rendered onto an existing background.
106      *
107      * @param iconKind The kind of icon requested. This should be
108      * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
109      * ICON_MONO_16x16, or ICON_MONO_32x32.
110      * @return An image object representing the requested icon. May
111      * return null if no suitable icon is available.
112      */

113     public Image JavaDoc getIcon (int type) {
114         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
115             (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
116
117             return Utilities.loadImage (ICON_DIR_BASE + "css.gif"); // NOI18N
118
} else {
119             return null;
120         }
121     }
122
123     public BeanInfo[] getAdditionalBeanInfo() {
124         try {
125             return new BeanInfo[] {
126                 java.beans.Introspector.getBeanInfo(org.openide.loaders.MultiFileLoader.class)
127             };
128         } catch (IntrospectionException e) {
129             // ignore
130
}
131         return super.getAdditionalBeanInfo();
132     }
133
134 }
135
Popular Tags