home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / CheckboxBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  4.6 KB  |  158 lines

  1. /*
  2.  * @(#CheckboxBeanInfo.java
  3.  *
  4.  * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
  5.  *
  6.  */
  7.  
  8. package symantec.itools.db.awt;
  9.  
  10. import java.beans.*;
  11. import symantec.itools.beans.*;
  12. import java.util.ResourceBundle;
  13.  
  14.  
  15. /**
  16.  * BeanInfo for the Checkbox component.
  17.  *
  18.  */
  19.  
  20. public class CheckboxBeanInfo extends SimpleBeanInfo {
  21.  
  22.     /**
  23.      * Constructs a CheckboxBeanInfo object.
  24.      */
  25.     public CheckboxBeanInfo() {
  26.     }
  27.  
  28.     /**
  29.      * Gets BeanInfo for the superclass of this bean.
  30.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  31.      */
  32.     public BeanInfo[] getAdditionalBeanInfo() {
  33.         try {
  34.             java.util.Vector v = new java.util.Vector();
  35.             BeanInfo[] rv;
  36.             BeanInfo b;
  37.             Class c = beanClass.getSuperclass();
  38.  
  39.             while (c.isAssignableFrom(Object.class) != true) {
  40.                 b = Introspector.getBeanInfo(c);
  41.                 v.addElement(b);
  42.                 c = c.getSuperclass();
  43.             }
  44.             rv = new BeanInfo[v.size()];
  45.             v.copyInto(rv);
  46.  
  47.             return rv;
  48.         }
  49.         catch (IntrospectionException e) { throw new Error(e.toString());}
  50.     }
  51.  
  52.     /**
  53.      * Gets the SymantecBeanDescriptor for this bean.
  54.      * @return an object of type SymantecBeanDescriptor
  55.      * @see symantec.itools.beans.SymantecBeanDescriptor
  56.      */
  57.     public BeanDescriptor getBeanDescriptor() {
  58.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  59.         bd.setFolder("dbAWARE");
  60.         bd.setToolbar("dbAWARE");
  61.         // bd.setValue("VPO_Object", new Boolean(true));
  62.         bd.setWinHelp("0x1232C");
  63.  
  64.         return (BeanDescriptor) bd;
  65.     }
  66.  
  67.     /**
  68.      * Gets an image that may be used to visually represent this bean
  69.      * (in the toolbar, on a form, etc).
  70.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  71.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  72.      * @return an image for this bean, always color even if requested monochrome
  73.      * @see BeanInfo#ICON_MONO_16x16
  74.      * @see BeanInfo#ICON_COLOR_16x16
  75.      * @see BeanInfo#ICON_MONO_32x32
  76.      * @see BeanInfo#ICON_COLOR_32x32
  77.      */
  78.     public java.awt.Image getIcon(int iconKind) {
  79.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  80.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  81.             java.awt.Image img = loadImage("CheckboxC16.gif");
  82.             return img;
  83.         }
  84.  
  85.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  86.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  87.             java.awt.Image img = loadImage("CheckboxC32.gif");
  88.             return img;
  89.         }
  90.  
  91.         return null;
  92.     }
  93.  
  94.     /**
  95.      * Gets an empty MethodDescriptor array.
  96.      * @return an empty array
  97.      */
  98.     public MethodDescriptor[] getMethodDescriptors() {
  99.         return new MethodDescriptor[0];
  100.     }
  101.  
  102.     /**
  103.      * Gets an array of descriptions of this bean's properties.
  104.      * @return property descriptions for this bean
  105.      */
  106.     public PropertyDescriptor[] getPropertyDescriptors() {
  107.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.db.resources.PropBundle");
  108.  
  109.         try{
  110.  
  111.         PropertyDescriptor pd1 = new PropertyDescriptor("dataBinding", beanClass);
  112.         pd1.setBound(false);
  113.         pd1.setConstrained(false);
  114.         pd1.setDisplayName(prop.getString("dataBinding"));
  115.         pd1.setPropertyEditorClass(symantec.itools.db.beans.binding.NameEditor.class);
  116.  
  117.         PropertyDescriptor pd2 = new PropertyDescriptor("trueValue", beanClass);
  118.         pd2.setBound(false);
  119.         pd2.setConstrained(false);
  120.         pd2.setDisplayName(prop.getString("trueValue"));
  121.  
  122.         PropertyDescriptor pd3 = new PropertyDescriptor("falseValue", beanClass);
  123.         pd3.setBound(false);
  124.         pd3.setConstrained(false);
  125.         pd3.setDisplayName(prop.getString("falseValue"));
  126.  
  127.         PropertyDescriptor pd4 = new PropertyDescriptor("triggeringEvent", beanClass);
  128.         pd4.setBound(false);
  129.         pd4.setConstrained(false);
  130.         pd4.setDisplayName(prop.getString("triggeringEvent"));
  131.         pd4.setValue("ENUMERATION", "Focus_Event=1, Key_Event=2, Item_Event=5");
  132.  
  133.         PropertyDescriptor pd6 = new PropertyDescriptor("emptyMeansNull", beanClass);
  134.         pd6.setBound(false);
  135.         pd6.setConstrained(false);
  136.         pd6.setDisplayName(prop.getString("emptyMeansNull"));
  137.  
  138.         //Hide the checkboxGroup property from the base class
  139.         PropertyDescriptor group = new PropertyDescriptor(prop.getString("checkboxGroup"), beanClass);
  140.         group.setHidden(true);
  141.  
  142.         PropertyDescriptor[] rv = {pd1, pd2, pd3, pd4, pd6, group};
  143.  
  144.         return rv;
  145.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  146.     }
  147.  
  148.     /**
  149.      * Returns the index of the property expected to be changed most often by the designer.
  150.      */
  151.     public int getDefaultPropertyIndex() {
  152.         return 0;    //  the index for our default property is always 0
  153.     }
  154.  
  155.     private final static Class beanClass = Checkbox.class;
  156.  
  157. }    //  end of class CheckboxBeanInfo|
  158.