org.netbeans.modules.xml.XMLDataLoaderBeanInfo Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.xml;
import java.beans.*;
import java.awt.Image;
import org.netbeans.modules.xml.util.Util;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
import org.openide.util.Utilities;
/**
* Loader BeanInfo adding metadata missing in org.openide.loaders.MultiFileLoaderBeanInfo.
*
* @author Petr Kuzel
*/
public class XMLDataLoaderBeanInfo extends SimpleBeanInfo {
private static final String ICON_DIR_BASE = "org/netbeans/modules/xml/resources/"; // NOI18N
private static final String PROP_EXT = Util.THIS.getString (
XMLDataLoaderBeanInfo.class, "PROP_Extensions"); // NOI18N
private static final String HINT_EXT = Util.THIS.getString (
XMLDataLoaderBeanInfo.class, "HINT_Extensions"); // NOI18N
/**
* Gets the bean's PropertyDescriptor
s.
*
* @return An array of PropertyDescriptors describing the editable
* properties supported by this bean. May return null if the
* information should be obtained by automatic analysis.
*
* If a property is indexed, then its entry in the result array will
* belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
* A client of getPropertyDescriptors can use "instanceof" to check
* if a given PropertyDescriptor is an IndexedPropertyDescriptor.
*/
public PropertyDescriptor[] getPropertyDescriptors() {
int PROPERTY_extensions = 0;
PropertyDescriptor[] properties = new PropertyDescriptor[1];
try {
properties[PROPERTY_extensions] = new PropertyDescriptor ( "extensions", XMLDataLoader.class, "getExtensions", "setExtensions" ); // NOI18N
properties[PROPERTY_extensions].setDisplayName ( PROP_EXT );
properties[PROPERTY_extensions].setShortDescription ( HINT_EXT );
} catch( IntrospectionException e) {
Exceptions.printStackTrace(e);
}
return properties;
}
/**
* Gets the bean's EventSetDescriptor
s.
*
* @return An array of EventSetDescriptors describing the kinds of
* events fired by this bean. May return null if the information
* should be obtained by automatic analysis.
*/
public EventSetDescriptor[] getEventSetDescriptors() {
int EVENT_propertyChangeListener = 0;
EventSetDescriptor[] eventSets = new EventSetDescriptor[1];
try {
eventSets[EVENT_propertyChangeListener] = new EventSetDescriptor ( XMLDataLoader.class, "propertyChangeListener", java.beans.PropertyChangeListener.class, new String[] {"propertyChange"}, "addPropertyChangeListener", "removePropertyChangeListener" ); // NOI18N
} catch( IntrospectionException e) {
Exceptions.printStackTrace(e);
}
return eventSets;
}
/**
* Gets the bean's MethodDescriptor
s.
*
* @return An array of MethodDescriptors describing the methods
* implemented by this bean. May return null if the information
* should be obtained by automatic analysis.
*/
public MethodDescriptor[] getMethodDescriptors() {
return new MethodDescriptor[0];
}
/** @param type Desired type of the icon
* @return returns the xml loader's icon
*/
public Image getIcon (int type) {
if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
(type == java.beans.BeanInfo.ICON_MONO_16x16)) {
return ImageUtilities.loadImage (ICON_DIR_BASE + "xmlObject.gif"); // NOI18N
} else {
return ImageUtilities.loadImage (ICON_DIR_BASE + "xmlObject32.gif"); // NOI18N
}
}
public BeanInfo[] getAdditionalBeanInfo() {
try {
return new BeanInfo[] {
java.beans.Introspector.getBeanInfo(org.openide.loaders.MultiFileLoader.class)
};
} catch (IntrospectionException e) {
// ignore
}
return super.getAdditionalBeanInfo();
}
}