001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.merge.builtin.visualizer;
043:
044: import java.beans.*;
045:
046: import org.openide.util.NbBundle;
047: import org.openide.util.Utilities;
048:
049: /**
050: * BeanInfo for graphical merge visualizer.
051: *
052: * @author Martin Entlicher
053: */
054: public class GraphicalMergeVisualizerBeanInfo extends SimpleBeanInfo {
055:
056: /**
057: * Gets the bean's <code>BeanDescriptor</code>s.
058: *
059: * @return BeanDescriptor describing the editable
060: * properties of this bean. May return null if the
061: * information should be obtained by automatic analysis.
062: */
063: public BeanDescriptor getBeanDescriptor() {
064: return new BeanDescriptor(GraphicalMergeVisualizer.class);
065: }
066:
067: /**
068: * Gets the bean's <code>PropertyDescriptor</code>s.
069: *
070: * @return An array of PropertyDescriptors describing the editable
071: * properties supported by this bean. May return null if the
072: * information should be obtained by automatic analysis.
073: * <p>
074: * If a property is indexed, then its entry in the result array will
075: * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
076: * A client of getPropertyDescriptors can use "instanceof" to check
077: * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
078: */
079: public PropertyDescriptor[] getPropertyDescriptors() {
080: PropertyDescriptor[] desc;
081: try {
082: PropertyDescriptor colorUnresolvedConflict = new PropertyDescriptor(
083: "colorUnresolvedConflict",
084: GraphicalMergeVisualizer.class);
085: colorUnresolvedConflict.setDisplayName(NbBundle.getMessage(
086: GraphicalMergeVisualizerBeanInfo.class,
087: "PROP_colorUnresolvedConflict"));
088: colorUnresolvedConflict.setShortDescription(NbBundle
089: .getMessage(GraphicalMergeVisualizerBeanInfo.class,
090: "HINT_colorUnresolvedConflict"));
091: PropertyDescriptor colorResolvedConflict = new PropertyDescriptor(
092: "colorResolvedConflict",
093: GraphicalMergeVisualizer.class);
094: colorResolvedConflict.setDisplayName(NbBundle.getMessage(
095: GraphicalMergeVisualizerBeanInfo.class,
096: "PROP_colorResolvedConflict"));
097: colorResolvedConflict.setShortDescription(NbBundle
098: .getMessage(GraphicalMergeVisualizerBeanInfo.class,
099: "HINT_colorResolvedConflict"));
100: PropertyDescriptor colorOtherConflict = new PropertyDescriptor(
101: "colorOtherConflict",
102: GraphicalMergeVisualizer.class);
103: colorOtherConflict.setDisplayName(NbBundle.getMessage(
104: GraphicalMergeVisualizerBeanInfo.class,
105: "PROP_colorOtherConflict"));
106: colorOtherConflict.setShortDescription(NbBundle.getMessage(
107: GraphicalMergeVisualizerBeanInfo.class,
108: "HINT_colorOtherConflict"));
109: desc = new PropertyDescriptor[] { colorUnresolvedConflict,
110: colorResolvedConflict, colorOtherConflict };
111: } catch (IntrospectionException ex) {
112: org.openide.ErrorManager.getDefault().notify(ex);
113: desc = null;
114: }
115: return desc;
116: }
117:
118: /**
119: * A bean may have a "default" property that is the property that will
120: * mostly commonly be initially chosen for update by human's who are
121: * customizing the bean.
122: * @return Index of default property in the PropertyDescriptor array
123: * returned by getPropertyDescriptors.
124: * <P> Returns -1 if there is no default property.
125: */
126: public int getDefaultPropertyIndex() {
127: return 0;
128: }
129:
130: /**
131: * This method returns an image object that can be used to
132: * represent the bean in toolboxes, toolbars, etc. Icon images
133: * will typically be GIFs, but may in future include other formats.
134: * <p>
135: * Beans aren't required to provide icons and may return null from
136: * this method.
137: * <p>
138: * There are four possible flavors of icons (16x16 color,
139: * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
140: * support a single icon we recommend supporting 16x16 color.
141: * <p>
142: * We recommend that icons have a "transparent" background
143: * so they can be rendered onto an existing background.
144: *
145: * @param iconKind The kind of icon requested. This should be
146: * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
147: * ICON_MONO_16x16, or ICON_MONO_32x32.
148: * @return An image object representing the requested icon. May
149: * return null if no suitable icon is available.
150: */
151: public java.awt.Image getIcon(int iconKind) {
152: switch (iconKind) {
153: case ICON_COLOR_16x16:
154: return Utilities
155: .loadImage(
156: "org/netbeans/modules/merge/builtin/visualizer/mergeModeIcon.gif",
157: true); // NOI18N
158: }
159: return null;
160: }
161:
162: }
|