KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > settings > examples > ProxySettingsBeanInfo


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.netbeans.modules.settings.examples;
21
22 import java.beans.*;
23
24 public class ProxySettingsBeanInfo extends SimpleBeanInfo {
25
26
27     // Bean descriptor //GEN-FIRST:BeanDescriptor
28
/*lazy BeanDescriptor*/;
29     private static BeanDescriptor getBdescriptor(){
30         BeanDescriptor beanDescriptor = new BeanDescriptor ( ProxySettings.class , null );
31         beanDescriptor.setDisplayName ( getLocalized("LBL_ProxySettings") );
32         beanDescriptor.setShortDescription ( getLocalized("HINT_ProxySettings") );//GEN-HEADEREND:BeanDescriptor
33

34         return beanDescriptor; }//GEN-LAST:BeanDescriptor
35

36     
37     // Property identifiers //GEN-FIRST:Properties
38
private static final int PROPERTY_proxyPort = 0;
39     private static final int PROPERTY_proxyHost = 1;
40
41     // Property array
42
/*lazy PropertyDescriptor*/;
43     private static PropertyDescriptor[] getPdescriptor(){
44         PropertyDescriptor[] properties = new PropertyDescriptor[2];
45     
46         try {
47             properties[PROPERTY_proxyPort] = new PropertyDescriptor ( "proxyPort", ProxySettings.class, "getProxyPort", "setProxyPort" );
48             properties[PROPERTY_proxyPort].setDisplayName ( getLocalized("LBL_Port") );
49             properties[PROPERTY_proxyPort].setShortDescription ( getLocalized("HINT_Port") );
50             properties[PROPERTY_proxyHost] = new PropertyDescriptor ( "proxyHost", ProxySettings.class, "getProxyHost", "setProxyHost" );
51             properties[PROPERTY_proxyHost].setDisplayName ( getLocalized("LBL_Host") );
52             properties[PROPERTY_proxyHost].setShortDescription ( getLocalized("HINT_Host") );
53         }
54         catch( IntrospectionException e) {}//GEN-HEADEREND:Properties
55

56         // Here you can add code for customizing the properties array.
57

58         return properties; }//GEN-LAST:Properties
59

60     // EventSet identifiers//GEN-FIRST:Events
61

62     // EventSet array
63
/*lazy EventSetDescriptor*/;
64     private static EventSetDescriptor[] getEdescriptor(){
65         EventSetDescriptor[] eventSets = new EventSetDescriptor[0];//GEN-HEADEREND:Events
66

67         // Here you can add code for customizing the event sets array.
68

69         return eventSets; }//GEN-LAST:Events
70

71     // Method identifiers //GEN-FIRST:Methods
72

73     // Method array
74
/*lazy MethodDescriptor*/;
75     private static MethodDescriptor[] getMdescriptor(){
76         MethodDescriptor[] methods = new MethodDescriptor[0];//GEN-HEADEREND:Methods
77

78         // Here you can add code for customizing the methods array.
79

80         return methods; }//GEN-LAST:Methods
81

82     
83     private static final int defaultPropertyIndex = -1;//GEN-BEGIN:Idx
84
private static final int defaultEventIndex = -1;//GEN-END:Idx
85

86     
87  //GEN-FIRST:Superclass
88

89     // Here you can add code for customizing the Superclass BeanInfo.
90

91  //GEN-LAST:Superclass
92

93     /**
94      * Gets the bean's <code>BeanDescriptor</code>s.
95      *
96      * @return BeanDescriptor describing the editable
97      * properties of this bean. May return null if the
98      * information should be obtained by automatic analysis.
99      */

100     public BeanDescriptor getBeanDescriptor() {
101         return getBdescriptor();
102     }
103     
104     /**
105      * Gets the bean's <code>PropertyDescriptor</code>s.
106      *
107      * @return An array of PropertyDescriptors describing the editable
108      * properties supported by this bean. May return null if the
109      * information should be obtained by automatic analysis.
110      * <p>
111      * If a property is indexed, then its entry in the result array will
112      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
113      * A client of getPropertyDescriptors can use "instanceof" to check
114      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
115      */

116     public PropertyDescriptor[] getPropertyDescriptors() {
117         return getPdescriptor();
118     }
119     
120     /**
121      * Gets the bean's <code>EventSetDescriptor</code>s.
122      *
123      * @return An array of EventSetDescriptors describing the kinds of
124      * events fired by this bean. May return null if the information
125      * should be obtained by automatic analysis.
126      */

127     public EventSetDescriptor[] getEventSetDescriptors() {
128         return getEdescriptor();
129     }
130     
131     /**
132      * Gets the bean's <code>MethodDescriptor</code>s.
133      *
134      * @return An array of MethodDescriptors describing the methods
135      * implemented by this bean. May return null if the information
136      * should be obtained by automatic analysis.
137      */

138     public MethodDescriptor[] getMethodDescriptors() {
139         return getMdescriptor();
140     }
141     
142     /**
143      * A bean may have a "default" property that is the property that will
144      * mostly commonly be initially chosen for update by human's who are
145      * customizing the bean.
146      * @return Index of default property in the PropertyDescriptor array
147      * returned by getPropertyDescriptors.
148      * <P> Returns -1 if there is no default property.
149      */

150     public int getDefaultPropertyIndex() {
151         return defaultPropertyIndex;
152     }
153     
154     /**
155      * A bean may have a "default" event that is the event that will
156      * mostly commonly be used by human's when using the bean.
157      * @return Index of default event in the EventSetDescriptor array
158      * returned by getEventSetDescriptors.
159      * <P> Returns -1 if there is no default event.
160      */

161     public int getDefaultEventIndex() {
162         return defaultEventIndex;
163     }
164     
165     private static String JavaDoc getLocalized(String JavaDoc key) {
166         return org.openide.util.NbBundle.getMessage(ProxySettings.class, key);
167     }
168 }
169
170
Popular Tags