KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > diff > cmdline > CmdlineDiffProviderBeanInfo


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

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

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

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

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