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 / ComboBoxBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  4.9 KB  |  167 lines

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