KickJava   Java API By Example, From Geeks To Geeks.

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


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.Utilities;
24 import org.openide.loaders.MultiFileLoader;
25 import org.openide.util.Exceptions;
26
27 /**
28  * Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
29  *
30  * @author Libor Kramolis
31  */

32 public class EntityDataLoaderBeanInfo extends SimpleBeanInfo {
33     /* Icon base dir. */
34     private static final String JavaDoc ICON_DIR_BASE = "org/netbeans/modules/xml/core/resources/"; // NOI18N
35

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

43     public BeanDescriptor getBeanDescriptor() {
44         BeanDescriptor beanDescriptor = new BeanDescriptor ( EntityDataLoader.class , null );
45         beanDescriptor.setDisplayName ( Util.THIS.getString ("PROP_EntityLoader_Name") );
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_extensions = 0;
63         PropertyDescriptor[] properties = new PropertyDescriptor[1];
64
65         try {
66             properties[PROPERTY_extensions] = new PropertyDescriptor ( "extensions", EntityDataLoader.class, "getExtensions", "setExtensions" );
67             properties[PROPERTY_extensions].setDisplayName ( Util.THIS.getString ("PROP_Entity_Extensions") );
68             properties[PROPERTY_extensions].setShortDescription ( Util.THIS.getString ("HINT_Entity_Extensions") );
69         }
70         catch( IntrospectionException e) {
71             Exceptions.printStackTrace(e);
72         }
73
74         // Here you can add code for customizing the properties array.
75

76         return properties;
77     }
78     
79     /**
80      * Gets the bean's <code>EventSetDescriptor</code>s.
81      *
82      * @return An array of EventSetDescriptors describing the kinds of
83      * events fired by this bean. May return null if the information
84      * should be obtained by automatic analysis.
85      */

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

97     public MethodDescriptor[] getMethodDescriptors() {
98         return new MethodDescriptor[0];
99     }
100
101     /** @param type Desired type of the icon
102      * @return returns the Entity loader's icon
103      */

104     public Image JavaDoc getIcon(final int type) {
105         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
106             (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
107
108             return Utilities.loadImage (ICON_DIR_BASE + "entObject.gif"); // NOI18N
109
} else {
110             return Utilities.loadImage (ICON_DIR_BASE + "entObject32.gif"); // NOI18N
111
}
112     }
113
114     public BeanInfo[] getAdditionalBeanInfo() {
115         try {
116             return new BeanInfo[] {
117                 java.beans.Introspector.getBeanInfo (MultiFileLoader.class)
118             };
119         } catch (IntrospectionException e) {
120             Exceptions.printStackTrace(e);
121         }
122         return super.getAdditionalBeanInfo();
123     }
124
125 }
126
Popular Tags