KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > diff > builtin > DefaultDiffBeanInfo


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.diff.builtin;
21
22 import java.beans.*;
23
24 import org.openide.util.NbBundle;
25 import org.openide.util.Utilities;
26
27 /**
28  * BeanInfo for built in diff provider.
29  *
30  * @author Martin Entlicher
31  */

32 public class DefaultDiffBeanInfo extends SimpleBeanInfo {
33
34     /**
35      * Gets the bean's <code>BeanDescriptor</code>s.
36      *
37      * @return BeanDescriptor describing the editable
38      * properties of this bean. May return null if the
39      * information should be obtained by automatic analysis.
40      */

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

58     public PropertyDescriptor[] getPropertyDescriptors() {
59         PropertyDescriptor[] desc;
60         try {
61             PropertyDescriptor showDiffSelector = new PropertyDescriptor("showDiffSelector", DefaultDiff.class);
62             showDiffSelector.setDisplayName (NbBundle.getMessage(DefaultDiffBeanInfo.class, "PROP_showDiffSelector"));
63             showDiffSelector.setShortDescription (NbBundle.getMessage(DefaultDiffBeanInfo.class, "HINT_showDiffSelector"));
64             desc = new PropertyDescriptor[] { showDiffSelector };
65         } catch (IntrospectionException ex) {
66             org.openide.ErrorManager.getDefault().notify(ex);
67             desc = null;
68         }
69         return desc;
70     }
71     
72     /**
73      * A bean may have a "default" property that is the property that will
74      * mostly commonly be initially chosen for update by human's who are
75      * customizing the bean.
76      * @return Index of default property in the PropertyDescriptor array
77      * returned by getPropertyDescriptors.
78      * <P> Returns -1 if there is no default property.
79      */

80     public int getDefaultPropertyIndex() {
81         return 0;
82     }
83     
84     /**
85      * This method returns an image object that can be used to
86      * represent the bean in toolboxes, toolbars, etc. Icon images
87      * will typically be GIFs, but may in future include other formats.
88      * <p>
89      * Beans aren't required to provide icons and may return null from
90      * this method.
91      * <p>
92      * There are four possible flavors of icons (16x16 color,
93      * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
94      * support a single icon we recommend supporting 16x16 color.
95      * <p>
96      * We recommend that icons have a "transparent" background
97      * so they can be rendered onto an existing background.
98      *
99      * @param iconKind The kind of icon requested. This should be
100      * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
101      * ICON_MONO_16x16, or ICON_MONO_32x32.
102      * @return An image object representing the requested icon. May
103      * return null if no suitable icon is available.
104      */

105     public java.awt.Image JavaDoc getIcon(int iconKind) {
106         switch (iconKind) {
107             case ICON_COLOR_16x16:
108                 return Utilities.loadImage("org/netbeans/modules/diff/diffSettingsIcon.gif", true); // NOI18N
109
}
110         return null;
111     }
112     
113 }
114
Popular Tags