KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > src > beaninfo > MemberElementBeanInfo


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
20 package org.openide.src.beaninfo;
21
22 import java.beans.*;
23 import org.openide.explorer.propertysheet.editors.ModifierEditor;
24
25 import org.openide.src.*;
26
27 /**
28 * Bean info containing common information for all MemberElements (e.g. Fields, Methods,...)
29 *
30 * @author Petr Hamernik
31 */

32 public class MemberElementBeanInfo extends SimpleBeanInfo implements ElementProperties {
33
34     static String JavaDoc getString(String JavaDoc key) {
35     return org.openide.util.NbBundle.getMessage(MemberElementBeanInfo.class, key);
36     }
37     
38     /**
39      * Gets the beans <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      */

45     public PropertyDescriptor[] getPropertyDescriptors() {
46         try {
47             PropertyDescriptor[] properties = new PropertyDescriptor[] {
48                              new PropertyDescriptor(PROP_NAME, MemberElement.class, "getName", "setName"), // NOI18N
49
new PropertyDescriptor(PROP_MODIFIERS, MemberElement.class, "getModifiers", "setModifiers") // NOI18N
50
};
51             properties[1].setPropertyEditorClass(ModifierEditor.class);
52         properties[0].setDisplayName(getString("PROP_MEMBER_NAME")); // NOI18N
53
properties[1].setDisplayName(getString("PROP_MEMBER_MODIFIERS")); // NOI18N
54
return properties;
55         } catch( IntrospectionException e) {
56             return super.getPropertyDescriptors();
57         }
58     }
59
60     /**
61      * A bean may have a "default" property that is the property that will
62      * mostly commonly be initially chosen for update by human's who are
63      * customizing the bean.
64      * @return Index of default property in the PropertyDescriptor array
65      * returned by getPropertyDescriptors.
66      * <P> Returns -1 if there is no default property.
67      */

68     public int getDefaultPropertyIndex() {
69         return 0;
70     }
71 }
72
Popular Tags