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: package org.netbeans.modules.xml.catalog.impl.sun;
042:
043: import java.beans.*;
044: import java.awt.Image;
045:
046: import org.openide.util.Utilities;
047:
048: import org.netbeans.modules.xml.catalog.spi.*;
049: import org.openide.util.NbBundle;
050:
051: public class CatalogBeanInfo extends SimpleBeanInfo {
052:
053: private static final String ICON_DIR_BASE = "org/netbeans/modules/xml/catalog/impl/sun/"; // NOI18N
054:
055: /**
056: * Gets the bean's <code>BeanDescriptor</code>s.
057: *
058: * @return BeanDescriptor describing the editable
059: * properties of this bean. May return null if the
060: * information should be obtained by automatic analysis.
061: */
062: public BeanDescriptor getBeanDescriptor() {
063: BeanDescriptor beanDescriptor = new BeanDescriptor(
064: Catalog.class, CatalogCustomizer.class);
065: beanDescriptor.setDisplayName(NbBundle.getMessage(
066: CatalogBeanInfo.class, "PROP_Catalog"));
067: beanDescriptor.setShortDescription(NbBundle.getMessage(
068: CatalogBeanInfo.class, "PROP_Catalog_desc"));//GEN-HEADEREND:BeanDescriptor
069:
070: // Here you can add code for customizing the BeanDescriptor.
071:
072: return beanDescriptor;
073: }
074:
075: /**
076: * Gets the bean's <code>PropertyDescriptor</code>s.
077: *
078: * @return An array of PropertyDescriptors describing the editable
079: * properties supported by this bean. May return null if the
080: * information should be obtained by automatic analysis.
081: * <p>
082: * If a property is indexed, then its entry in the result array will
083: * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
084: * A client of getPropertyDescriptors can use "instanceof" to check
085: * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
086: */
087: public PropertyDescriptor[] getPropertyDescriptors() {
088: int PROPERTY_displayName = 0;
089: int PROPERTY_shortDescription = 1;
090: int PROPERTY_icon = 2;
091: PropertyDescriptor[] properties = new PropertyDescriptor[3];
092:
093: try {
094: properties[PROPERTY_displayName] = new PropertyDescriptor(
095: "displayName", Catalog.class, "getDisplayName",
096: null);
097: properties[PROPERTY_displayName].setDisplayName(NbBundle
098: .getMessage(CatalogBeanInfo.class,
099: "PROP_catalog_name"));
100: properties[PROPERTY_displayName]
101: .setShortDescription(NbBundle.getMessage(
102: CatalogBeanInfo.class,
103: "PROP_catalog_name_desc"));
104: properties[PROPERTY_shortDescription] = new PropertyDescriptor(
105: "shortDescription", Catalog.class,
106: "getShortDescription", null);
107: properties[PROPERTY_shortDescription]
108: .setDisplayName(NbBundle.getMessage(
109: CatalogBeanInfo.class, "PROP_catalog_info"));
110: properties[PROPERTY_shortDescription]
111: .setShortDescription(NbBundle.getMessage(
112: CatalogBeanInfo.class,
113: "PROP_catalog_info_desc"));
114: properties[PROPERTY_icon] = new IndexedPropertyDescriptor(
115: "icon", Catalog.class, null, null, "getIcon", null);
116: properties[PROPERTY_icon].setHidden(true);
117: } catch (IntrospectionException e) {
118: }//GEN-HEADEREND:Properties
119: properties[PROPERTY_shortDescription]
120: .setName(CatalogDescriptor.PROP_CATALOG_DESC);
121: properties[PROPERTY_displayName]
122: .setName(CatalogDescriptor.PROP_CATALOG_NAME);
123: properties[PROPERTY_icon]
124: .setName(CatalogDescriptor.PROP_CATALOG_ICON);
125:
126: return properties;
127: }
128:
129: /**
130: * Gets the bean's <code>EventSetDescriptor</code>s.
131: *
132: * @return An array of EventSetDescriptors describing the kinds of
133: * events fired by this bean. May return null if the information
134: * should be obtained by automatic analysis.
135: */
136: public EventSetDescriptor[] getEventSetDescriptors() {
137: return new EventSetDescriptor[0];
138: }
139:
140: /**
141: * Gets the bean's <code>MethodDescriptor</code>s.
142: *
143: * @return An array of MethodDescriptors describing the methods
144: * implemented by this bean. May return null if the information
145: * should be obtained by automatic analysis.
146: */
147: public MethodDescriptor[] getMethodDescriptors() {
148: return new MethodDescriptor[0];
149: }
150:
151: /**
152: * This method returns an image object that can be used to
153: * represent the bean in toolboxes, toolbars, etc. Icon images
154: * will typically be GIFs, but may in future include other formats.
155: * <p>
156: * Beans aren't required to provide icons and may return null from
157: * this method.
158: * <p>
159: * There are four possible flavors of icons (16x16 color,
160: * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
161: * support a single icon we recommend supporting 16x16 color.
162: * <p>
163: * We recommend that icons have a "transparent" background
164: * so they can be rendered onto an existing background.
165: *
166: * @param iconKind The kind of icon requested. This should be
167: * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
168: * ICON_MONO_16x16, or ICON_MONO_32x32.
169: * @return An image object representing the requested icon. May
170: * return null if no suitable icon is available.
171: */
172: public Image getIcon(int type) {
173: if ((type == java.beans.BeanInfo.ICON_COLOR_16x16)
174: || (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
175:
176: return Utilities
177: .loadImage(ICON_DIR_BASE + "sunCatalog.gif"); // NOI18N
178: } else {
179: return null;
180: }
181: }
182:
183: }
|