KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > settings > JavaSynchronizationSettingsBeanInfo


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.java.settings;
21
22 import java.awt.Image JavaDoc;
23 import java.beans.*;
24 import java.util.ResourceBundle JavaDoc;
25
26 import org.openide.ErrorManager;
27 import org.openide.util.NbBundle;
28 import org.openide.util.Utilities;
29
30 /** BeanInfo for class JavaSynchronizationSettings.
31 * It describes three properties one with special editor.
32 *
33 * @author Petr Hamernik
34 */

35 public class JavaSynchronizationSettingsBeanInfo extends SimpleBeanInfo {
36
37     /** Returns the ExternalCompilerSettings' icon */
38     public Image JavaDoc getIcon(int type) {
39         if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) || (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
40             return Utilities.loadImage("org/netbeans/modules/java/resources/synchronizeSettings.gif"); // NOI18N
41
} else {
42             return Utilities.loadImage("org/netbeans/modules/java/settings/javaSynchronizationSettings32.gif"); // NOI18N
43
}
44     }
45
46     /** Descriptor of valid properties
47     * @return array of properties
48     */

49     public PropertyDescriptor[] getPropertyDescriptors () {
50         try {
51             PropertyDescriptor[] desc = new PropertyDescriptor[] {
52                        new PropertyDescriptor(JavaSynchronizationSettings.PROP_GENERATE_RETURN,
53                                               JavaSynchronizationSettings.class, "getGenerateReturn", "setGenerateReturn"), // NOI18N
54
};
55             ResourceBundle JavaDoc bundle = NbBundle.getBundle(JavaSynchronizationSettingsBeanInfo.class);
56
57             desc[0].setDisplayName(bundle.getString("PROP_GENERATE_RETURN"));
58             desc[0].setShortDescription(bundle.getString("HINT_GENERATE_RETURN"));
59             desc[0].setPropertyEditorClass(RetGenEditor.class);
60
61         return desc;
62         }
63         catch (IntrospectionException ex) {
64         ErrorManager.getDefault().notify(ex);
65         return null;
66         }
67     }
68
69     public BeanDescriptor getBeanDescriptor() {
70         BeanDescriptor desc = new BeanDescriptor(JavaSettings.class);
71         desc.setDisplayName(JavaSettings.getString("CTL_JavaSynchronization_Settings"));
72         return desc;
73     }
74
75     /** Simple property editor for two-item pulldown. */
76     public static class RetGenEditor extends PropertyEditorSupport {
77
78         private static final String JavaDoc[] tags;
79
80         static {
81             tags = new String JavaDoc[3];
82             ResourceBundle JavaDoc bundle = NbBundle.getBundle(JavaSynchronizationSettingsBeanInfo.class);
83             tags[JavaSynchronizationSettings.RETURN_GEN_NOTHING] = bundle.getString("CTL_RETURN_GEN_NOTHING");
84             tags[JavaSynchronizationSettings.RETURN_GEN_EXCEPTION] = bundle.getString("CTL_RETURN_GEN_EXCEPTION");
85             tags[JavaSynchronizationSettings.RETURN_GEN_NULL] = bundle.getString("CTL_RETURN_GEN_NULL");
86         }
87
88         public String JavaDoc[] getTags () {
89             return tags;
90         }
91
92         public String JavaDoc getAsText () {
93             return tags[((Integer JavaDoc) getValue ()).intValue ()];
94         }
95
96         public void setAsText (String JavaDoc text) throws IllegalArgumentException JavaDoc {
97             for (int i = 0; i < tags.length; i++) {
98                 if (tags[i].equals (text)) {
99                     setValue (new Integer JavaDoc (i));
100                     return;
101                 }
102             }
103             throw new IllegalArgumentException JavaDoc ();
104         }
105     }
106
107 }
108
109
Popular Tags