KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > options > BasePrintOptionsBeanInfo


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.editor.options;
21
22 import java.beans.*;
23 import java.awt.Image JavaDoc;
24 import org.openide.util.NbBundle;
25
26 /** BeanInfo for plain options
27 *
28 * @author Miloslav Metelka, Ales Novak
29 */

30 public class BasePrintOptionsBeanInfo extends SimpleBeanInfo {
31
32     /** Prefix of the icon location. */
33     private String JavaDoc iconPrefix;
34
35     /** Icons for compiler settings objects. */
36     private Image JavaDoc icon;
37     private Image JavaDoc icon32;
38
39     public BasePrintOptionsBeanInfo() {
40         this("/org/netbeans/modules/editor/resources/baseOptions"); // NOI18N
41
}
42
43     public BasePrintOptionsBeanInfo(String JavaDoc iconPrefix) {
44         this.iconPrefix = iconPrefix;
45     }
46
47     /*
48     * @return Returns an array of PropertyDescriptors
49     * describing the editable properties supported by this bean.
50     */

51     public PropertyDescriptor[] getPropertyDescriptors () {
52         PropertyDescriptor[] descriptors;
53         String JavaDoc[] propNames = getPropNames();
54         try {
55             descriptors = new PropertyDescriptor[propNames.length];
56
57             for (int i = 0; i < propNames.length; i++) {
58                 descriptors[i] = new PropertyDescriptor(propNames[i], getBeanClass());
59                 descriptors[i].setDisplayName(getString("PROP_" + propNames[i])); // NOI18N
60
descriptors[i].setShortDescription(getString("HINT_" + propNames[i])); // NOI18N
61
if (BasePrintOptions.PRINT_COLORING_MAP_PROP.equals(propNames[i])) {
62                     descriptors[i].setPropertyEditorClass(ColoringArrayEditor.class);
63                 }
64             }
65         } catch (IntrospectionException e) {
66             descriptors = new PropertyDescriptor[0];
67         }
68         return descriptors;
69     }
70
71     protected String JavaDoc getString(String JavaDoc s) {
72         return NbBundle.getMessage(BasePrintOptionsBeanInfo.class, s);
73     }
74
75     protected Class JavaDoc getBeanClass() {
76         return BasePrintOptions.class;
77     }
78
79     protected String JavaDoc[] getPropNames() {
80         return BasePrintOptions.BASE_PROP_NAMES;
81     }
82
83     /* @param type Desired type of the icon
84     * @return returns the Java loader's icon
85     */

86     public Image JavaDoc getIcon(final int type) {
87         if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) {
88             if (icon == null)
89                 icon = loadImage(iconPrefix + ".gif"); // NOI18N
90
return icon;
91         }
92         else {
93             if (icon32 == null)
94                 icon32 = loadImage(iconPrefix + "32.gif"); // NOI18N
95
return icon32;
96         }
97     }
98 }
99
Popular Tags