package Templates.API_Support.Filesystems_API;

import java.awt.Image;
import java.beans.*;

import org.openide.ErrorManager;
import org.openide.filesystems.FileSystem;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;

/** Description of the filesystem.
 *
 * @author __USER__
 */
public class __Sample__FileSystemBeanInfo extends SimpleBeanInfo {

    public BeanInfo[] getAdditionalBeanInfo() {
        try {
            return new BeanInfo[] {Introspector.getBeanInfo(FileSystem.class)};
        } catch (IntrospectionException ie) {
            ErrorManager.getDefault().notify(ie);
            return null;
        }
    }

    /*
    // If you have a visual dialog to customize configuration of the filesystem:
    public BeanDescriptor getBeanDescriptor() {
	return new BeanDescriptor(__NAME$BeanInfo$$FileSystem__.class, __NAME$BeanInfo$Customizer$FileSystemCustomizer__.class);
    }
    */

    public PropertyDescriptor[] getPropertyDescriptors() {
        try {
            // Included only to make it a writable property (it is read-only in FileSystem):
            PropertyDescriptor readOnly = new PropertyDescriptor("readOnly", __NAME$BeanInfo$$FileSystem__.class);
            readOnly.setDisplayName(NbBundle.getMessage(__NAME__.class, "PROP_readOnly"));
            readOnly.setShortDescription(NbBundle.getMessage(__NAME__.class, "HINT_readOnly"));
            // This could be whatever properties you use to configure the filesystem:
            PropertyDescriptor rootDirectory = new PropertyDescriptor("rootDirectory", __NAME$BeanInfo$$FileSystem__.class);
            rootDirectory.setDisplayName(NbBundle.getMessage(__NAME__.class, "PROP_rootDirectory"));
            rootDirectory.setShortDescription(NbBundle.getMessage(__NAME__.class, "HINT_rootDirectory"));
            // Request to the property editor that it be permitted only to choose directories:
            rootDirectory.setValue("directories", Boolean.TRUE); // NOI18N
            rootDirectory.setValue("files", Boolean.FALSE); // NOI18N
            return new PropertyDescriptor[] {readOnly, rootDirectory};
        } catch (IntrospectionException ie) {
            ErrorManager.getDefault().notify(ie);
            return null;
        }
    }

    public Image getIcon(int type) {
        if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) {
            return Utilities.loadImage("__PACKAGE_AND_NAME_SLASHES$BeanInfo$Icon$FileSystemIcon__.gif");
        } else {
            return Utilities.loadImage("__PACKAGE_AND_NAME_SLASHES$BeanInfo$Icon32$FileSystemIcon32__.gif");
        }
    }

}
