KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > merge > builtin > visualizer > GraphicalMergeVisualizerBeanInfo


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.merge.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 graphical merge visualizer.
29  *
30  * @author Martin Entlicher
31  */

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

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

111     public java.awt.Image JavaDoc getIcon(int iconKind) {
112         switch (iconKind) {
113             case ICON_COLOR_16x16:
114                 return Utilities.loadImage("org/netbeans/modules/merge/builtin/visualizer/mergeModeIcon.gif", true); // NOI18N
115
}
116         return null;
117     }
118     
119 }
120
Popular Tags