KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > catalog > impl > sun > CatalogBeanInfo


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.catalog.impl.sun;
20
21 import java.beans.*;
22 import java.awt.Image JavaDoc;
23
24 import org.openide.util.Utilities;
25
26 import org.netbeans.modules.xml.catalog.spi.*;
27
28 public class CatalogBeanInfo extends SimpleBeanInfo {
29
30     private static final String JavaDoc ICON_DIR_BASE = "org/netbeans/modules/xml/catalog/impl/sun/"; // NOI18N
31

32     /**
33      * Gets the bean's <code>BeanDescriptor</code>s.
34      *
35      * @return BeanDescriptor describing the editable
36      * properties of this bean. May return null if the
37      * information should be obtained by automatic analysis.
38      */

39     public BeanDescriptor getBeanDescriptor() {
40     BeanDescriptor beanDescriptor = new BeanDescriptor ( Catalog.class , CatalogCustomizer.class );
41         beanDescriptor.setDisplayName ( Util.THIS.getString("PROP_Catalog") );
42         beanDescriptor.setShortDescription ( Util.THIS.getString("PROP_Catalog_desc") );//GEN-HEADEREND:BeanDescriptor
43

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

46         return beanDescriptor;
47     }
48
49     /**
50      * Gets the bean's <code>PropertyDescriptor</code>s.
51      *
52      * @return An array of PropertyDescriptors describing the editable
53      * properties supported by this bean. May return null if the
54      * information should be obtained by automatic analysis.
55      * <p>
56      * If a property is indexed, then its entry in the result array will
57      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
58      * A client of getPropertyDescriptors can use "instanceof" to check
59      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
60      */

61     public PropertyDescriptor[] getPropertyDescriptors() {
62         int PROPERTY_displayName = 0;
63         int PROPERTY_shortDescription = 1;
64         int PROPERTY_icon = 2;
65         PropertyDescriptor[] properties = new PropertyDescriptor[3];
66
67         try {
68             properties[PROPERTY_displayName] = new PropertyDescriptor ( "displayName", Catalog.class, "getDisplayName", null );
69             properties[PROPERTY_displayName].setDisplayName ( Util.THIS.getString("PROP_catalog_name") );
70             properties[PROPERTY_displayName].setShortDescription ( Util.THIS.getString("PROP_catalog_name_desc") );
71             properties[PROPERTY_shortDescription] = new PropertyDescriptor ( "shortDescription", Catalog.class, "getShortDescription", null );
72             properties[PROPERTY_shortDescription].setDisplayName ( Util.THIS.getString("PROP_catalog_info") );
73             properties[PROPERTY_shortDescription].setShortDescription ( Util.THIS.getString("PROP_catalog_info_desc") );
74             properties[PROPERTY_icon] = new IndexedPropertyDescriptor ( "icon", Catalog.class, null, null, "getIcon", null );
75             properties[PROPERTY_icon].setHidden ( true );
76         }
77         catch( IntrospectionException e) {}//GEN-HEADEREND:Properties
78
properties[PROPERTY_shortDescription].setName(CatalogDescriptor.PROP_CATALOG_DESC);
79         properties[PROPERTY_displayName].setName(CatalogDescriptor.PROP_CATALOG_NAME);
80         properties[PROPERTY_icon].setName(CatalogDescriptor.PROP_CATALOG_ICON);
81
82         return properties;
83     }
84
85     /**
86      * Gets the bean's <code>EventSetDescriptor</code>s.
87      *
88      * @return An array of EventSetDescriptors describing the kinds of
89      * events fired by this bean. May return null if the information
90      * should be obtained by automatic analysis.
91      */

92     public EventSetDescriptor[] getEventSetDescriptors() {
93     return new EventSetDescriptor[0];
94     }
95
96     /**
97      * Gets the bean's <code>MethodDescriptor</code>s.
98      *
99      * @return An array of MethodDescriptors describing the methods
100      * implemented by this bean. May return null if the information
101      * should be obtained by automatic analysis.
102      */

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

128     public Image JavaDoc getIcon (int type) {
129         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
130             (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
131
132             return Utilities.loadImage (ICON_DIR_BASE + "sunCatalog.gif"); // NOI18N
133
} else {
134             return null;
135         }
136     }
137
138 }
139
Popular Tags