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.bpel.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.IntrospectionException;
026: import java.beans.Introspector;
027: import java.beans.MethodDescriptor;
028: import java.beans.PropertyDescriptor;
029: import java.beans.SimpleBeanInfo;
030:
031: import org.openide.loaders.DataLoader;
032: import org.openide.util.NbBundle;
033: import org.openide.util.Utilities;
034: import org.openide.ErrorManager;
035:
036: /**
037: * Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
038: *
039: * @author ads
040: */
041: public class BPELDataLoaderBeanInfo extends SimpleBeanInfo {
042:
043: private static final String LOADER_DESC = "LBL_loader_desc"; // NOI18N
044:
045: private static final String PATH_TO_IMAGE = "org/netbeans/modules/bpel/core/resources/bpel_file.gif"; // NOI18N
046:
047: /** {@inheritDoc} */
048: public BeanInfo[] getAdditionalBeanInfo() {
049: try {
050: return new BeanInfo[] { Introspector
051: .getBeanInfo(DataLoader.class) };
052: } catch (IntrospectionException ie) {
053: ErrorManager.getDefault().notify(ie);
054: return null;
055: }
056: }
057:
058: /**
059: * Gets the bean's <code>BeanDescriptor</code>s.
060: *
061: * @return BeanDescriptor describing the editable
062: * properties of this bean. May return null if the
063: * information should be obtained by automatic analysis.
064: */
065: public BeanDescriptor getBeanDescriptor() {
066: BeanDescriptor beanDescriptor = new BeanDescriptor(
067: BPELDataLoader.class, null);
068: beanDescriptor.setDisplayName(NbBundle.getMessage(getClass(),
069: BPELDataLoader.LOADER_NAME));
070: beanDescriptor.setShortDescription(NbBundle.getMessage(
071: getClass(), LOADER_DESC));
072:
073: // Here you can add code for customizing the BeanDescriptor.
074:
075: return beanDescriptor;
076: }
077:
078: /** {@inheritDoc} */
079: public PropertyDescriptor[] getPropertyDescriptors() {
080: // Make extensions into a r/o property.
081: // It will only contain the BPEL MIME type.
082: // Customizations should be done on the resolver object, not on the extension list.
083: // Does not work to just use additional bean info from UniFileLoader and return one extensions
084: // property with no setter--Introspector cleverly (!&#$@&) keeps your display name
085: // and everything and adds back in the setter from the superclass.
086: // So bypass UniFileLoader in the beaninfo search.
087: try {
088: PropertyDescriptor extensions = new PropertyDescriptor(
089: "extensions", BPELDataLoader.class,
090: "getExtensions", null);// NOI18N
091: extensions.setDisplayName(NbBundle.getMessage(getClass(),
092: "PROP_extensions"));
093: extensions.setShortDescription(NbBundle.getMessage(
094: getClass(), "HINT_extensions"));
095: extensions.setExpert(true);
096: return new PropertyDescriptor[] { extensions };
097: } catch (IntrospectionException ie) {
098: ErrorManager.getDefault().notify(ie);
099: return null;
100: }
101: }
102:
103: /** {@inheritDoc} */
104: public MethodDescriptor[] getMethodDescriptors() {
105: return new MethodDescriptor[0];
106: }
107:
108: /** {@inheritDoc} */
109: public EventSetDescriptor[] getEventSetDescriptors() {
110: return new EventSetDescriptor[0];
111: }
112:
113: /** {@inheritDoc} */
114: public Image getIcon(int type) {
115: if (type == BeanInfo.ICON_COLOR_16x16
116: || type == BeanInfo.ICON_MONO_16x16) {
117: return Utilities.loadImage(PATH_TO_IMAGE);
118: } else {
119: return null;
120: }
121: }
122: }
|