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.xsl;
042:
043: import java.beans.*;
044: import java.awt.Image;
045: import org.openide.util.Utilities;
046: import org.openide.loaders.MultiFileLoader;
047: import org.openide.util.Exceptions;
048: import org.openide.util.NbBundle;
049:
050: /**
051: * Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
052: *
053: * @author Libor Kramolis
054: */
055: public class XSLDataLoaderBeanInfo extends SimpleBeanInfo {
056: /* Icon base dir. */
057: private static final String ICON_DIR_BASE = "org/netbeans/modules/xsl/resources/"; // NOI18N
058:
059: /**
060: * Gets the bean's <code>BeanDescriptor</code>s.
061: *
062: * @return BeanDescriptor describing the editable
063: * properties of this bean. May return null if the
064: * information should be obtained by automatic analysis.
065: */
066: public BeanDescriptor getBeanDescriptor() {
067: BeanDescriptor beanDescriptor = new BeanDescriptor(
068: XSLDataLoader.class, null);
069: beanDescriptor.setDisplayName(NbBundle.getMessage(
070: XSLDataLoaderBeanInfo.class, "NAME_XSLDataLoader"));//GEN-HEADEREND:BeanDescriptor
071:
072: // Here you can add code for customizing the BeanDescriptor.
073:
074: return beanDescriptor;
075: }
076:
077: /**
078: * Gets the bean's <code>PropertyDescriptor</code>s.
079: *
080: * @return An array of PropertyDescriptors describing the editable
081: * properties supported by this bean. May return null if the
082: * information should be obtained by automatic analysis.
083: * <p>
084: * If a property is indexed, then its entry in the result array will
085: * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
086: * A client of getPropertyDescriptors can use "instanceof" to check
087: * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
088: */
089: public PropertyDescriptor[] getPropertyDescriptors() {
090: int PROPERTY_extensions = 0;
091: PropertyDescriptor[] properties = new PropertyDescriptor[1];
092:
093: try {
094: properties[PROPERTY_extensions] = new PropertyDescriptor(
095: "extensions", XSLDataLoader.class, "getExtensions",
096: "setExtensions");
097: properties[PROPERTY_extensions].setDisplayName(NbBundle
098: .getMessage(XSLDataLoaderBeanInfo.class,
099: "PROP_XSL_Extensions"));
100: properties[PROPERTY_extensions]
101: .setShortDescription(NbBundle.getMessage(
102: XSLDataLoaderBeanInfo.class,
103: "HINT_XSL_Extensions"));
104: } catch (IntrospectionException e) {
105: Exceptions.printStackTrace(e);
106: }
107: return properties;
108: }
109:
110: /**
111: * Gets the bean's <code>EventSetDescriptor</code>s.
112: *
113: * @return An array of EventSetDescriptors describing the kinds of
114: * events fired by this bean. May return null if the information
115: * should be obtained by automatic analysis.
116: */
117: public EventSetDescriptor[] getEventSetDescriptors() {
118: return new EventSetDescriptor[0];
119: }
120:
121: /**
122: * Gets the bean's <code>MethodDescriptor</code>s.
123: *
124: * @return An array of MethodDescriptors describing the methods
125: * implemented by this bean. May return null if the information
126: * should be obtained by automatic analysis.
127: */
128: public MethodDescriptor[] getMethodDescriptors() {
129: return new MethodDescriptor[0];
130: }
131:
132: /** @param type Desired type of the icon
133: * @return returns the Entity loader's icon
134: */
135: public Image getIcon(final int type) {
136: if ((type == java.beans.BeanInfo.ICON_COLOR_16x16)
137: || (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
138:
139: return Utilities.loadImage(ICON_DIR_BASE + "xslObject.gif"); // NOI18N
140: } else {
141: return Utilities.loadImage(ICON_DIR_BASE
142: + "xslObject32.gif"); // NOI18N
143: }
144: }
145:
146: public BeanInfo[] getAdditionalBeanInfo() {
147: try {
148: return new BeanInfo[] { java.beans.Introspector
149: .getBeanInfo(MultiFileLoader.class) };
150: } catch (IntrospectionException e) {
151: Exceptions.printStackTrace(e);
152: }
153: return super.getAdditionalBeanInfo();
154: }
155:
156: }
|