KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > catalog > impl > XCatalogBeanInfo


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;
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.CatalogDescriptor;
27
28 public class XCatalogBeanInfo extends SimpleBeanInfo {
29
30     /**
31      * Gets the bean's <code>BeanDescriptor</code>s.
32      *
33      * @return BeanDescriptor describing the editable
34      * properties of this bean. May return null if the
35      * information should be obtained by automatic analysis.
36      */

37     public BeanDescriptor getBeanDescriptor() {
38         BeanDescriptor beanDescriptor = new BeanDescriptor ( XCatalog.class , XCatalogCustomizer.class );
39         beanDescriptor.setDisplayName ( Util.THIS.getString("NAME_x_catalog") );
40         beanDescriptor.setShortDescription ( Util.THIS.getString("TEXT_x_catalog_desc") );
41         
42     return beanDescriptor;
43     }
44
45     /**
46      * Gets the bean's <code>PropertyDescriptor</code>s.
47      *
48      * @return An array of PropertyDescriptors describing the editable
49      * properties supported by this bean. May return null if the
50      * information should be obtained by automatic analysis.
51      * <p>
52      * If a property is indexed, then its entry in the result array will
53      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
54      * A client of getPropertyDescriptors can use "instanceof" to check
55      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
56      */

57     public PropertyDescriptor[] getPropertyDescriptors() {
58         PropertyDescriptor[] properties = new PropertyDescriptor[4];
59         int PROPERTY_source = 0;
60         int PROPERTY_displayName = 1;
61         int PROPERTY_shortDescription = 2;
62         int PROPERTY_icon = 3;
63         try {
64             properties[PROPERTY_source] = new PropertyDescriptor ( "source", XCatalog.class, "getSource", "setSource" );
65             properties[PROPERTY_source].setExpert ( true );
66             properties[PROPERTY_source].setDisplayName ( Util.THIS.getString("PROP_xcatalog_location") );
67             properties[PROPERTY_source].setShortDescription ( Util.THIS.getString("PROP_xcatalog_location_desc") );
68             properties[PROPERTY_displayName] = new PropertyDescriptor ( "displayName", XCatalog.class, "getDisplayName", null );
69             properties[PROPERTY_displayName].setDisplayName ( Util.THIS.getString("PROP_xcatalog_name") );
70             properties[PROPERTY_displayName].setShortDescription ( Util.THIS.getString("PROP_xcatalog_name_desc") );
71             properties[PROPERTY_shortDescription] = new PropertyDescriptor ( "shortDescription", XCatalog.class, "getShortDescription", null );
72             properties[PROPERTY_shortDescription].setDisplayName ( Util.THIS.getString("PROP_xcatalog_info") );
73             properties[PROPERTY_shortDescription].setShortDescription ( Util.THIS.getString("PROP_xcatalog_info_desc") );
74             properties[PROPERTY_icon] = new IndexedPropertyDescriptor ( "icon", XCatalog.class, null, null, "getIcon", null );
75             properties[PROPERTY_icon].setHidden ( true );
76         }
77         catch( IntrospectionException e) {}//GEN-HEADEREND:Properties
78

79         // Here you can add code for customizing the properties array.
80

81         properties[PROPERTY_shortDescription].setName(CatalogDescriptor.PROP_CATALOG_DESC);
82         properties[PROPERTY_displayName].setName(CatalogDescriptor.PROP_CATALOG_NAME);
83         properties[PROPERTY_icon].setName(CatalogDescriptor.PROP_CATALOG_ICON);
84     return properties;
85     }
86
87     public Image JavaDoc getIcon (int type) {
88         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
89             (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
90
91             return Utilities.loadImage ("org/netbeans/modules/xml/catalog/impl/xmlCatalog.gif"); // NOI18N
92
} else {
93             return null;
94         }
95     }
96
97 }
98
Popular Tags