KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > core > DTDDataLoaderBeanInfo


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.core;
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 /**
27  * Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
28  *
29  * @author Petr Kuzel
30  */

31 public class DTDDataLoaderBeanInfo extends SimpleBeanInfo {
32
33     private static final String JavaDoc ICON_DIR_BASE = "org/netbeans/modules/xml/core/resources/"; // NOI18N
34

35     private static final String JavaDoc PROP_DTD_EXT = Util.THIS.getString ("PROP_DTD_Extensions"); // NOI18N
36
private static final String JavaDoc HINT_DTD_EXT = Util.THIS.getString ("HINT_DTD_Extensions"); // NOI18N
37

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

50     public PropertyDescriptor[] getPropertyDescriptors() {
51         int PROPERTY_extensions = 0;
52         PropertyDescriptor[] properties = new PropertyDescriptor[1];
53         
54         try {
55             properties[PROPERTY_extensions] = new PropertyDescriptor ( "extensions", DTDDataLoader.class, "getExtensions", "setExtensions" ); // NOI18N
56
properties[PROPERTY_extensions].setDisplayName ( PROP_DTD_EXT );
57             properties[PROPERTY_extensions].setShortDescription ( HINT_DTD_EXT );
58         } catch( IntrospectionException e) {
59             Exceptions.printStackTrace(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 ( DTDDataLoader.class, "propertyChangeListener", java.beans.PropertyChangeListener JavaDoc.class, new String JavaDoc[] {"propertyChange"}, "addPropertyChangeListener", "removePropertyChangeListener" ); // NOI18N
77
} catch( IntrospectionException e) {
78             Exceptions.printStackTrace(e);
79         }
80         return eventSets;
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     /** @param type Desired type of the icon
95      * @return returns the dtd loader's icon
96      */

97     public Image JavaDoc getIcon (int type) {
98         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
99             (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
100
101             return Utilities.loadImage (ICON_DIR_BASE + "dtdObject.gif"); // NOI18N
102
} else {
103             return Utilities.loadImage (ICON_DIR_BASE + "dtdObject32.gif"); // NOI18N
104
}
105     }
106
107     public BeanInfo[] getAdditionalBeanInfo() {
108         try {
109             return new BeanInfo[] {
110                 java.beans.Introspector.getBeanInfo(org.openide.loaders.MultiFileLoader.class)
111             };
112         } catch (IntrospectionException e) {
113             // ignore
114
}
115         return super.getAdditionalBeanInfo();
116     }
117
118 }
119
Popular Tags