001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019: package org.netbeans.modules.xslt.core;
020:
021: import java.awt.Image;
022: import java.beans.BeanDescriptor;
023: import java.beans.BeanInfo;
024: import java.beans.EventSetDescriptor;
025: import java.beans.Introspector;
026: import java.beans.SimpleBeanInfo;
027: import java.beans.IntrospectionException;
028: import java.beans.MethodDescriptor;
029: import java.beans.PropertyDescriptor;
030: import org.openide.ErrorManager;
031: import org.openide.loaders.DataLoader;
032: import org.openide.util.NbBundle;
033: import org.openide.util.Utilities;
034:
035: /**
036: * Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
037: *
038: * @author Vitaly Bychkov
039: * @version 1.0
040: */
041: public class XSLTDataLoaderBeanInfo extends SimpleBeanInfo {
042:
043: private static final String LOADER_DESC = "LBL_loader_desc"; // NOI18N
044: public static final String PATH_TO_IMAGE = "org/netbeans/modules/xslt/core/resources/xslt_file.gif"; // NOI18N
045:
046: /** {@inheritDoc} */
047: public BeanInfo[] getAdditionalBeanInfo() {
048: try {
049: return new BeanInfo[] { Introspector
050: .getBeanInfo(DataLoader.class) };
051: } catch (IntrospectionException ex) {
052: ErrorManager.getDefault().notify(ex);
053: return null;
054: }
055: }
056:
057: public Image getIcon(int type) {
058: if (type == BeanInfo.ICON_COLOR_16x16
059: || type == BeanInfo.ICON_MONO_16x16) {
060: return Utilities.loadImage(PATH_TO_IMAGE);
061: } else {
062: return null;
063: }
064:
065: }
066:
067: /** {@inheritDoc} */
068: public BeanDescriptor getBeanDescriptor() {
069: BeanDescriptor beanDescriptor = new BeanDescriptor(
070: XSLTDataLoader.class, null);
071: beanDescriptor.setDisplayName(NbBundle.getMessage(
072: XSLTDataLoaderBeanInfo.class,
073: XSLTDataLoader.LOADER_NAME));
074: beanDescriptor.setShortDescription(NbBundle.getMessage(
075: XSLTDataLoaderBeanInfo.class, LOADER_DESC));
076:
077: return beanDescriptor;
078: }
079:
080: /** {@inheritDoc} */
081: public PropertyDescriptor[] getPropertyDescriptors() {
082: // Make extensions into a r/o property.
083: // It will only contain the XSLT MIME type.
084: // Customizations should be done on the resolver object, not on the extension list.
085: // Does not work to just use additional bean info from UniFileLoader and return one extensions
086: // property with no setter--Introspector cleverly (!&#$@&) keeps your display name
087: // and everything and adds back in the setter from the superclass.
088: // So bypass UniFileLoader in the beaninfo search.
089: try {
090: PropertyDescriptor extensions = new PropertyDescriptor(
091: "extensions", XSLTDataLoader.class,
092: "getExtensions", null);// NOI18N
093: extensions.setDisplayName(NbBundle.getMessage(
094: XSLTDataLoader.class, "PROP_extensions"));
095: extensions.setShortDescription(NbBundle.getMessage(
096: XSLTDataLoader.class, "HINT_extensions"));
097: extensions.setExpert(true);
098: return new PropertyDescriptor[] { extensions };
099: } catch (IntrospectionException ie) {
100: ErrorManager.getDefault().notify(ie);
101: return null;
102: }
103: }
104:
105: /** {@inheritDoc} */
106: public MethodDescriptor[] getMethodDescriptors() {
107: return new MethodDescriptor[0];
108: }
109:
110: /** {@inheritDoc} */
111: public EventSetDescriptor[] getEventSetDescriptors() {
112: return new EventSetDescriptor[0];
113: }
114: }
|