KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > catalog > CatalogEntryBeanInfo


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

30     private static final String JavaDoc PUBLICID_N = Util.THIS.getString("PROP_public_id");
31     private static final String JavaDoc PUBLICID_D = Util.THIS.getString("PROP_public_id_desc");
32     private static final String JavaDoc SYSTEMID_D = Util.THIS.getString("PROP_system_id_desc");
33     private static final String JavaDoc SYSTEMID_N = Util.THIS.getString("PROP_system_id");
34     private static final String JavaDoc URI_D = Util.THIS.getString("PROP_uri_desc");
35     private static final String JavaDoc URI_N = Util.THIS.getString("PROP_uri");
36     
37     /**
38      * Gets the bean's <code>PropertyDescriptor</code>s.
39      *
40      * @return An array of PropertyDescriptors describing the editable
41      * properties supported by this bean. May return null if the
42      * information should be obtained by automatic analysis.
43      * <p>
44      * If a property is indexed, then its entry in the result array will
45      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
46      * A client of getPropertyDescriptors can use "instanceof" to check
47      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
48      */

49     public PropertyDescriptor[] getPropertyDescriptors() {
50         int PROPERTY_publicID = 0;
51         int PROPERTY_systemID = 1;
52         int PROPERTY_URI = 2;
53         PropertyDescriptor[] properties = new PropertyDescriptor[3];
54
55         try {
56             properties[PROPERTY_publicID] = new PropertyDescriptor ( "publicID", CatalogEntry.class, "getPublicIDValue", null ); // NOI18N
57
properties[PROPERTY_publicID].setDisplayName ( PUBLICID_N );
58             properties[PROPERTY_publicID].setShortDescription ( PUBLICID_D );
59             properties[PROPERTY_systemID] = new PropertyDescriptor ( "systemID", CatalogEntry.class, "getSystemIDValue", null ); // NOI18N
60
properties[PROPERTY_systemID].setDisplayName ( SYSTEMID_N );
61             properties[PROPERTY_systemID].setShortDescription ( SYSTEMID_D );
62             properties[PROPERTY_URI] = new PropertyDescriptor ( "uri", CatalogEntry.class, "getUriValue", null ); // NOI18N
63
properties[PROPERTY_URI].setDisplayName ( URI_N );
64             properties[PROPERTY_URI].setShortDescription ( URI_D );
65         }
66         catch( IntrospectionException e) {
67             Exceptions.printStackTrace(e);
68         }
69         return properties;
70     }
71
72     /**
73      * Gets the bean's <code>EventSetDescriptor</code>s.
74      *
75      * @return An array of EventSetDescriptors describing the kinds of
76      * events fired by this bean. May return null if the information
77      * should be obtained by automatic analysis.
78      */

79     public EventSetDescriptor[] getEventSetDescriptors() {
80         return new EventSetDescriptor[0];
81     }
82
83     /**
84      * Gets the bean's <code>MethodDescriptor</code>s.
85      *
86      * @return An array of MethodDescriptors describing the methods
87      * implemented by this bean. May return null if the information
88      * should be obtained by automatic analysis.
89      */

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

115     public Image JavaDoc getIcon (int type) {
116         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
117             (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
118
119             return Utilities.loadImage (ICON_DIR_BASE + "catalog-entry.gif"); // NOI18N
120
} else {
121             return null;
122         }
123     }
124
125 }
126
Popular Tags