KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > i18n > I18nOptionsBeanInfo


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.modules.i18n;
22
23
24 import java.awt.Image JavaDoc;
25 import java.beans.BeanDescriptor JavaDoc;
26 import java.beans.BeanInfo JavaDoc;
27 import java.beans.IntrospectionException JavaDoc;
28 import java.beans.SimpleBeanInfo JavaDoc;
29 import java.beans.PropertyDescriptor JavaDoc;
30 import java.util.ResourceBundle JavaDoc;
31
32 import org.openide.util.NbBundle;
33 import org.openide.util.Utilities;
34
35
36 /**
37  * Bean info for <code>I18nOptions</code> class.
38  *
39  * @author Peter Zavadsky
40  */

41 public class I18nOptionsBeanInfo extends SimpleBeanInfo JavaDoc {
42     
43     /**
44      */

45     public BeanDescriptor JavaDoc getBeanDescriptor() {
46         BeanDescriptor JavaDoc descr = new BeanDescriptor JavaDoc(I18nOptions.class);
47         descr.setDisplayName(
48                 NbBundle.getMessage(I18nOptions.class,
49                                     "LBL_Internationalization")); //NOI18N
50
return descr;
51     }
52
53     /** Overrides superclass method. */
54     public PropertyDescriptor JavaDoc[] getPropertyDescriptors() {
55         try {
56             PropertyDescriptor JavaDoc advWizardPD = new PropertyDescriptor JavaDoc(I18nOptions.PROP_ADVANCED_WIZARD, I18nOptions.class);
57             PropertyDescriptor JavaDoc initCodePD = new PropertyDescriptor JavaDoc(I18nOptions.PROP_INIT_JAVA_CODE, I18nOptions.class);
58             PropertyDescriptor JavaDoc replaceCodePD = new PropertyDescriptor JavaDoc(I18nOptions.PROP_REPLACE_JAVA_CODE, I18nOptions.class);
59             PropertyDescriptor JavaDoc regExpPD = new PropertyDescriptor JavaDoc(I18nOptions.PROP_REGULAR_EXPRESSION, I18nOptions.class);
60             PropertyDescriptor JavaDoc i18nRegExpPD = new PropertyDescriptor JavaDoc(I18nOptions.PROP_I18N_REGULAR_EXPRESSION, I18nOptions.class);
61             PropertyDescriptor JavaDoc replaceValuePD = new PropertyDescriptor JavaDoc(I18nOptions.PROP_REPLACE_RESOURCE_VALUE, I18nOptions.class);
62             PropertyDescriptor JavaDoc lastResPD = new PropertyDescriptor JavaDoc(I18nOptions.PROP_LAST_RESOURCE2, I18nOptions.class);
63
64             // Set expert flags.
65
initCodePD.setExpert(true);
66             replaceCodePD.setExpert(true);
67             regExpPD.setExpert(true);
68             i18nRegExpPD.setExpert(true);
69
70             // Set last resource property as hidden.
71
lastResPD.setHidden(true);
72             
73             ResourceBundle JavaDoc bundle = NbBundle.getBundle(I18nOptionsBeanInfo.class);
74             
75             // Set display names.
76
advWizardPD.setDisplayName(bundle.getString("TXT_AdvancedWizard"));
77             initCodePD.setDisplayName(bundle.getString("TXT_InitCodeFormat"));
78             replaceCodePD.setDisplayName(bundle.getString("TXT_ReplaceCodeFormat"));
79             regExpPD.setDisplayName(bundle.getString("TXT_RegularExpression"));
80             replaceValuePD.setDisplayName(bundle.getString("TXT_ReplaceResourceValue"));
81             i18nRegExpPD.setDisplayName(bundle.getString("TXT_I18nRegularExpression"));
82
83             // Set short descriptions.
84
advWizardPD.setShortDescription(bundle.getString("TXT_AdvancedWizardDesc"));
85             initCodePD.setShortDescription(bundle.getString("TXT_InitCodeFormatDesc"));
86             replaceCodePD.setShortDescription(bundle.getString("TXT_ReplaceCodeFormatDesc"));
87             regExpPD.setShortDescription(bundle.getString("TXT_RegularExpressionDesc"));
88             replaceValuePD.setShortDescription(bundle.getString("TXT_ReplaceResourceValueDesc"));
89             i18nRegExpPD.setShortDescription(bundle.getString("TXT_I18nRegularExpressionDesc"));
90             
91             // Set property editors.
92
initCodePD.setPropertyEditorClass(HelpStringCustomEditor.InitCodeEditor.class);
93             replaceCodePD.setPropertyEditorClass(HelpStringCustomEditor.ReplaceCodeEditor.class);
94             regExpPD.setPropertyEditorClass(HelpStringCustomEditor.RegExpEditor.class);
95             i18nRegExpPD.setPropertyEditorClass(HelpStringCustomEditor.I18nRegExpEditor.class);
96             
97             return new PropertyDescriptor JavaDoc[] {
98                 advWizardPD, initCodePD, replaceCodePD, regExpPD, i18nRegExpPD, replaceValuePD, lastResPD
99             };
100         } catch(IntrospectionException JavaDoc ie) {
101             return null;
102         }
103     }
104
105     /** Overrides superclass method. */
106     public Image JavaDoc getIcon(int type) {
107         if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) {
108         return Utilities.loadImage("org/netbeans/modules/i18n/i18nAction.gif"); // NOI18N
109
} else { // 32
110
return Utilities.loadImage("org/netbeans/modules/properties/propertiesKey32.gif"); // NOI18N
111
}
112     }
113     
114 }
115
Popular Tags