KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > diff > builtin > visualizer > TextDiffVisualizerBeanInfo


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

32 public class TextDiffVisualizerBeanInfo 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(TextDiffVisualizer.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 contextMode = new PropertyDescriptor("contextMode", TextDiffVisualizer.class);
62             contextMode.setDisplayName (NbBundle.getMessage(TextDiffVisualizerBeanInfo.class, "PROP_contextMode"));
63             contextMode.setShortDescription (NbBundle.getMessage(TextDiffVisualizerBeanInfo.class, "HINT_contextMode"));
64             PropertyDescriptor contextNumLines = new PropertyDescriptor("contextNumLines", TextDiffVisualizer.class);
65             contextNumLines.setDisplayName (NbBundle.getMessage(TextDiffVisualizerBeanInfo.class, "PROP_contextNumLines"));
66             contextNumLines.setShortDescription (NbBundle.getMessage(TextDiffVisualizerBeanInfo.class, "HINT_contextNumLines"));
67             desc = new PropertyDescriptor[] { contextMode, contextNumLines };//diffCommand };
68
} catch (IntrospectionException ex) {
69             org.openide.ErrorManager.getDefault().notify(ex);
70             desc = null;
71         }
72         return desc;
73     }
74     
75     /**
76      * A bean may have a "default" property that is the property that will
77      * mostly commonly be initially chosen for update by human's who are
78      * customizing the bean.
79      * @return Index of default property in the PropertyDescriptor array
80      * returned by getPropertyDescriptors.
81      * <P> Returns -1 if there is no default property.
82      */

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

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