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.diff.cmdline;
043:
044: import java.beans.*;
045:
046: import org.openide.util.NbBundle;
047: import org.openide.util.Utilities;
048:
049: /**
050: * BeanInfo for command-line diff provider.
051: *
052: * @author Martin Entlicher
053: */
054: public class CmdlineDiffProviderBeanInfo 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(CmdlineDiffProvider.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 diffCommand = new PropertyDescriptor(
083: "diffCommand", CmdlineDiffProvider.class);
084: diffCommand.setDisplayName(NbBundle.getMessage(
085: CmdlineDiffProviderBeanInfo.class, "PROP_diffCmd"));
086: diffCommand.setShortDescription(NbBundle.getMessage(
087: CmdlineDiffProviderBeanInfo.class, "HINT_diffCmd"));
088: desc = new PropertyDescriptor[] { diffCommand };
089: } catch (IntrospectionException ex) {
090: org.openide.ErrorManager.getDefault().notify(ex);
091: desc = null;
092: }
093: return desc;
094: }
095:
096: /**
097: * A bean may have a "default" property that is the property that will
098: * mostly commonly be initially chosen for update by human's who are
099: * customizing the bean.
100: * @return Index of default property in the PropertyDescriptor array
101: * returned by getPropertyDescriptors.
102: * <P> Returns -1 if there is no default property.
103: */
104: public int getDefaultPropertyIndex() {
105: return 0;
106: }
107:
108: /**
109: * This method returns an image object that can be used to
110: * represent the bean in toolboxes, toolbars, etc. Icon images
111: * will typically be GIFs, but may in future include other formats.
112: * <p>
113: * Beans aren't required to provide icons and may return null from
114: * this method.
115: * <p>
116: * There are four possible flavors of icons (16x16 color,
117: * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
118: * support a single icon we recommend supporting 16x16 color.
119: * <p>
120: * We recommend that icons have a "transparent" background
121: * so they can be rendered onto an existing background.
122: *
123: * @param iconKind The kind of icon requested. This should be
124: * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
125: * ICON_MONO_16x16, or ICON_MONO_32x32.
126: * @return An image object representing the requested icon. May
127: * return null if no suitable icon is available.
128: */
129: public java.awt.Image getIcon(int iconKind) {
130: switch (iconKind) {
131: case ICON_COLOR_16x16:
132: return Utilities.loadImage(
133: "org/netbeans/modules/diff/diffSettingsIcon.gif",
134: true); // NOI18N
135: }
136: return null;
137: }
138:
139: }
|