KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

36     private static final String JavaDoc PROP_EXT = Util.THIS.getString ("PROP_Extensions"); // NOI18N
37
private static final String JavaDoc HINT_EXT = Util.THIS.getString ("HINT_Extensions"); // NOI18N
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", XMLDataLoader.class, "getExtensions", "setExtensions" ); // NOI18N
57
properties[PROPERTY_extensions].setDisplayName ( PROP_EXT );
58             properties[PROPERTY_extensions].setShortDescription ( HINT_EXT );
59         } catch( IntrospectionException e) {
60             Exceptions.printStackTrace(e);
61         }
62         return properties;
63     }
64
65     /**
66      * Gets the bean's <code>EventSetDescriptor</code>s.
67      *
68      * @return An array of EventSetDescriptors describing the kinds of
69      * events fired by this bean. May return null if the information
70      * should be obtained by automatic analysis.
71      */

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

91     public MethodDescriptor[] getMethodDescriptors() {
92         return new MethodDescriptor[0];
93     }
94
95     /** @param type Desired type of the icon
96      * @return returns the xml loader's icon
97      */

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