package Templates.API_Support.Options_API;

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

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

/** Description of {@link __NAME$BeanInfo$$MySystemOption__}.
 *
 * @author __USER__
 */
public class __Sample__SettingsBeanInfo extends SimpleBeanInfo {

    public PropertyDescriptor[] getPropertyDescriptors() {
        try {
            PropertyDescriptor propone = new PropertyDescriptor("propone", __NAME$BeanInfo$$MySystemOption__.class);
            propone.setDisplayName(NbBundle.getMessage(__NAME__.class, "PROP_propone"));
            propone.setShortDescription(NbBundle.getMessage(__NAME__.class, "HINT_propone"));
            PropertyDescriptor proptwo = new PropertyDescriptor("proptwo", __NAME$BeanInfo$$MySystemOption__.class);
            proptwo.setDisplayName(NbBundle.getMessage(__NAME__.class, "PROP_proptwo"));
            proptwo.setShortDescription(NbBundle.getMessage(__NAME__.class, "HINT_proptwo"));
            proptwo.setExpert(true);
            proptwo.setPropertyEditorClass(ProptwoEd.class);
            return new PropertyDescriptor[] {propone, proptwo};
        } 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$MyIcon__.gif", true);
        } else {
            return Utilities.loadImage("__PACKAGE_AND_NAME_SLASHES$BeanInfo$Icon32$MyIcon32__.gif", true);
        }
    }

    public static class ProptwoEd extends PropertyEditorSupport {

        private static final String[] tags = {
	    NbBundle.getMessage(__NAME__.class, "LBL_true"),
	    NbBundle.getMessage(__NAME__.class, "LBL_false")
	};

        public String[] getTags() {
            return tags;
        }

        public String getAsText() {
            return tags[((Boolean)getValue()).booleanValue() ? 0 : 1];
        }

        public void setAsText(String text) throws IllegalArgumentException {
            if (tags[0].equals(text))
                setValue(Boolean.TRUE);
            else if (tags[1].equals(text))
                setValue(Boolean.FALSE);
            else
                throw new IllegalArgumentException();
        }

    }

}
