KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > core > settings > CoreSettingsBeanInfo


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.settings;
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  *
28  * @author Petr Kuzel
29  * @author Libor Kramolis
30  * @version 0.2
31  */

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

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

44     public BeanDescriptor getBeanDescriptor() {
45     return new BeanDescriptor ( CoreSettings.class , null );
46     }
47
48     /**
49      * Gets the bean's <code>PropertyDescriptor</code>s.
50      *
51      * @return An array of PropertyDescriptors describing the editable
52      * properties supported by this bean. May return null if the
53      * information should be obtained by automatic analysis.
54      * <p>
55      * If a property is indexed, then its entry in the result array will
56      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
57      * A client of getPropertyDescriptors can use "instanceof" to check
58      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
59      */

60     public PropertyDescriptor[] getPropertyDescriptors() {
61         int PROPERTY_preferedShortEmptyElement = 0;
62         int PROPERTY_defaultAction = 1;
63         int PROPERTY_autoParsingDelay = 2;
64         PropertyDescriptor[] properties = new PropertyDescriptor[3];
65
66         try {
67             properties[PROPERTY_preferedShortEmptyElement] = new PropertyDescriptor ( "preferedShortEmptyElement", CoreSettings.class, "isPreferedShortEmptyElement", "setPreferedShortEmptyElement" );
68             properties[PROPERTY_preferedShortEmptyElement].setExpert ( true );
69             properties[PROPERTY_preferedShortEmptyElement].setDisplayName ( Util.THIS.getString("PROP_preferedShortEmptyElement") );
70             properties[PROPERTY_preferedShortEmptyElement].setShortDescription ( Util.THIS.getString("PROP_preferedShortEmptyElement_desc") );
71             properties[PROPERTY_defaultAction] = new PropertyDescriptor ( "defaultAction", CoreSettings.class, "getDefaultAction", "setDefaultAction" );
72             properties[PROPERTY_defaultAction].setExpert ( true );
73             properties[PROPERTY_defaultAction].setDisplayName ( Util.THIS.getString("PROP_default_action") );
74             properties[PROPERTY_defaultAction].setShortDescription ( Util.THIS.getString("PROP_default_action_hint") );
75             properties[PROPERTY_defaultAction].setBound ( true );
76             properties[PROPERTY_defaultAction].setPropertyEditorClass ( DefaultActionPropertyEditor.class );
77             properties[PROPERTY_autoParsingDelay] = new PropertyDescriptor ( "autoParsingDelay", CoreSettings.class, "getAutoParsingDelay", "setAutoParsingDelay" );
78             properties[PROPERTY_autoParsingDelay].setDisplayName ( Util.THIS.getString("PROP_AUTO_PARSING_DELAY") );
79             properties[PROPERTY_autoParsingDelay].setShortDescription ( Util.THIS.getString("HINT_AUTO_PARSING_DELAY") );
80         }
81         catch( IntrospectionException e) {
82             Exceptions.printStackTrace(e);
83         }
84         return properties;
85     }
86
87     /**
88      * Gets the bean's <code>EventSetDescriptor</code>s.
89      *
90      * @return An array of EventSetDescriptors describing the kinds of
91      * events fired by this bean. May return null if the information
92      * should be obtained by automatic analysis.
93      */

94     public EventSetDescriptor[] getEventSetDescriptors() {
95         return new EventSetDescriptor[0];
96     }
97
98     /**
99      * Gets the bean's <code>MethodDescriptor</code>s.
100      *
101      * @return An array of MethodDescriptors describing the methods
102      * implemented by this bean. May return null if the information
103      * should be obtained by automatic analysis.
104      */

105     public MethodDescriptor[] getMethodDescriptors() {
106         return new MethodDescriptor[0];
107     }
108
109     public Image JavaDoc getIcon (int type) {
110         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
111             (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
112
113             return Utilities.loadImage (ICON_DIR_BASE + "coreSettings.gif"); // NOI18N
114
} else {
115             return Utilities.loadImage (ICON_DIR_BASE + "coreSettings32.gif"); // NOI18N
116
}
117     }
118
119 }
120
Popular Tags