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.tmap;
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.IntrospectionException;
026: import java.beans.Introspector;
027: import java.beans.MethodDescriptor;
028: import java.beans.PropertyDescriptor;
029: import java.beans.SimpleBeanInfo;
030: import org.openide.ErrorManager;
031: import org.openide.loaders.UniFileLoader;
032: import org.openide.util.NbBundle;
033: import org.openide.util.Utilities;
034:
035: /**
036: * @author Vitaly Bychkov
037: * @version 1.0
038: */
039: public class TMapDataLoaderBeanInfo extends SimpleBeanInfo {
040:
041: private static final String LOADER_DESC = "LBL_loader_desc"; // NOI18N
042: public static final String PATH_TO_IMAGE = "org/netbeans/modules/xslt/core/resources/xslt_file.gif"; // NOI18N
043:
044: @Override
045: public BeanInfo[] getAdditionalBeanInfo() {
046: try {
047: return new BeanInfo[] { Introspector
048: .getBeanInfo(UniFileLoader.class) };
049: } catch (IntrospectionException e) {
050: throw new AssertionError(e);
051: }
052: }
053:
054: @Override
055: public Image getIcon(int type) {
056: if (type == BeanInfo.ICON_COLOR_16x16
057: || type == BeanInfo.ICON_MONO_16x16) {
058: return Utilities
059: .loadImage("org/netbeans/modules/xslt/tmap/resources/tmap.png");
060: } else {
061: return null;
062: }
063: }
064:
065: /** {@inheritDoc} */
066: @Override
067: public BeanDescriptor getBeanDescriptor() {
068: BeanDescriptor beanDescriptor = new BeanDescriptor(
069: TMapDataLoader.class, null);
070: beanDescriptor.setDisplayName(NbBundle.getMessage(
071: TMapDataLoaderBeanInfo.class,
072: TMapDataLoader.LOADER_NAME));
073: beanDescriptor.setShortDescription(NbBundle.getMessage(
074: TMapDataLoaderBeanInfo.class, LOADER_DESC));
075:
076: return beanDescriptor;
077: }
078:
079: /** {@inheritDoc} */
080: @Override
081: public PropertyDescriptor[] getPropertyDescriptors() {
082: // Make extensions into a r/o property.
083: // It will only contain the TRANSFORMMAP 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", TMapDataLoader.class,
092: "getExtensions", null);// NOI18N
093: extensions.setDisplayName(NbBundle.getMessage(
094: TMapDataLoader.class, "PROP_extensions"));
095: extensions.setShortDescription(NbBundle.getMessage(
096: TMapDataLoader.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: @Override
107: public MethodDescriptor[] getMethodDescriptors() {
108: return new MethodDescriptor[0];
109: }
110:
111: /** {@inheritDoc} */
112: @Override
113: public EventSetDescriptor[] getEventSetDescriptors() {
114: return new EventSetDescriptor[0];
115: }
116:
117: }
|