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 / GridBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  7.2 KB  |  207 lines

  1. /*
  2.  * @(#GridBeanInfo.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.  *    BeanInfo for the Grid component.
  16.  */
  17. public class GridBeanInfo extends SimpleBeanInfo
  18. {
  19.  
  20.     /**
  21.      * Constructs a GridBeanInfo object.
  22.      */
  23.     public GridBeanInfo() {
  24.     }
  25.  
  26.     /**
  27.      * Gets BeanInfo for the superclass of this bean.
  28.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  29.      */
  30.     public BeanInfo[] getAdditionalBeanInfo() {
  31.         try {
  32.             java.util.Vector v = new java.util.Vector();
  33.             BeanInfo[] rv;
  34.             BeanInfo b;
  35.             Class c = beanClass.getSuperclass();
  36.             //we don't want to introspect the TableView class, nor the panel
  37.             //and container class only 'higher' ones
  38.             c = c.getSuperclass();
  39.             c = c.getSuperclass();
  40.             c = c.getSuperclass();
  41.  
  42.             while (c.isAssignableFrom(Object.class) != true) {
  43.                 b = Introspector.getBeanInfo(c);
  44.                 v.addElement(b);
  45.                 c = c.getSuperclass();
  46.             }
  47.             rv = new BeanInfo[v.size()];
  48.             v.copyInto(rv);
  49.  
  50.             return rv;
  51.         }
  52.         catch (IntrospectionException e) { throw new Error(e.toString());}
  53.     }
  54.  
  55.     /**
  56.      * Gets the SymantecBeanDescriptor for this bean.
  57.      * @return an object of type SymantecBeanDescriptor
  58.      * @see symantec.itools.beans.SymantecBeanDescriptor
  59.      */
  60.     public BeanDescriptor getBeanDescriptor() {
  61.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  62.         bd.setFolder("dbAWARE");
  63.         bd.setToolbar("dbAWARE");
  64.         bd.setWinHelp("0x12523");
  65.  
  66.         return (BeanDescriptor) bd;
  67.     }
  68.  
  69.     // getIcon returns an image object which can be used by toolboxes, toolbars
  70.     // to represent this bean. Icon images are in GIF format.
  71.     /**
  72.      * Gets an image that may be used to visually represent this bean
  73.      * (in the toolbar, on a form, etc).
  74.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  75.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  76.      * @return an image for this bean, always color even if requested monochrome
  77.      * @see BeanInfo#ICON_MONO_16x16
  78.      * @see BeanInfo#ICON_COLOR_16x16
  79.      * @see BeanInfo#ICON_MONO_32x32
  80.      * @see BeanInfo#ICON_COLOR_32x32
  81.      */
  82.     public java.awt.Image getIcon(int iconKind)
  83.     {
  84.         if (iconKind == BeanInfo.ICON_COLOR_16x16 ||
  85.             iconKind == BeanInfo.ICON_MONO_16x16)
  86.         {
  87.             java.awt.Image img = loadImage("GridC16.gif");
  88.             return img;
  89.         }
  90.         if (iconKind == BeanInfo.ICON_COLOR_32x32 ||
  91.             iconKind == BeanInfo.ICON_MONO_32x32)
  92.         {
  93.             java.awt.Image img = loadImage("GridC32.gif");
  94.             return img;
  95.         }
  96.         return null;
  97.     }
  98.  
  99.     /**
  100.      * Gets an empty MethodDescriptor array.
  101.      * @return an empty array
  102.      */
  103.     public MethodDescriptor[] getMethodDescriptors() {
  104.         return new MethodDescriptor[0];
  105.     }
  106.  
  107.     // getPropertyDescriptors returns an array of PropertyDescriptors which describe
  108.     // the editable properties of this bean.
  109.     /**
  110.      * Gets an array of descriptions of this bean's properties.
  111.      * @return property descriptions for this bean
  112.      */
  113.     public PropertyDescriptor[] getPropertyDescriptors()
  114.     {
  115.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.db.resources.PropBundle");
  116.  
  117.         try
  118.         {
  119.             PropertyDescriptor dataBinding = new PropertyDescriptor("dataBinding", beanClass);
  120.             dataBinding.setBound(false);
  121.             dataBinding.setConstrained(false);
  122.             dataBinding.setDisplayName(prop.getString("dataBinding"));
  123.             dataBinding.setPropertyEditorClass(symantec.itools.db.beans.binding.NameEditor.class);
  124.  
  125.             PropertyDescriptor columns = new PropertyDescriptor("columnsNumber", beanClass);
  126.             columns.setBound(false);
  127.             columns.setConstrained(false);
  128.             columns.setDisplayName(prop.getString("columnsNumber"));
  129.  
  130.             PropertyDescriptor rows = new PropertyDescriptor("rowsNumber", beanClass);
  131.             rows.setBound(false);
  132.             rows.setConstrained(false);
  133.             rows.setDisplayName(prop.getString("rowsNumber"));
  134.  
  135.             /*PropertyDescriptor appendButton = new PropertyDescriptor("appendButton", beanClass);
  136.             appendButton.setBound(false);
  137.             appendButton.setConstrained(false);
  138.             appendButton.setDisplayName(prop.getString("appendButton"));*/
  139.  
  140.             PropertyDescriptor insertButton = new PropertyDescriptor("insertButton", beanClass);
  141.             insertButton.setBound(false);
  142.             insertButton.setConstrained(false);
  143.             insertButton.setDisplayName(prop.getString("insertButton"));
  144.  
  145.             PropertyDescriptor gotoButton = new PropertyDescriptor("gotoButton", beanClass);
  146.             gotoButton.setBound(false);
  147.             gotoButton.setConstrained(false);
  148.             gotoButton.setDisplayName(prop.getString("gotoButton"));
  149.  
  150.             PropertyDescriptor undoButton = new PropertyDescriptor("undoButton", beanClass);
  151.             undoButton.setBound(false);
  152.             undoButton.setConstrained(false);
  153.             undoButton.setDisplayName(prop.getString("undoButton"));
  154.  
  155.             PropertyDescriptor restartButton = new PropertyDescriptor("restartButton", beanClass);
  156.             restartButton.setBound(false);
  157.             restartButton.setConstrained(false);
  158.             restartButton.setDisplayName(prop.getString("restartButton"));
  159.  
  160.             PropertyDescriptor deleteButton = new PropertyDescriptor("deleteButton", beanClass);
  161.             deleteButton.setBound(false);
  162.             deleteButton.setConstrained(false);
  163.             deleteButton.setDisplayName(prop.getString("deleteButton"));
  164.  
  165.            /* PropertyDescriptor undeleteButton = new PropertyDescriptor("undeleteButton", beanClass);
  166.             undeleteButton.setBound(false);
  167.             undeleteButton.setConstrained(false);
  168.             undeleteButton.setDisplayName(prop.getString("undeleteButton"));*/
  169.  
  170.             PropertyDescriptor saveButton = new PropertyDescriptor("saveButton", beanClass);
  171.             saveButton.setBound(false);
  172.             saveButton.setConstrained(false);
  173.             saveButton.setDisplayName(prop.getString("saveButton"));
  174.  
  175.             PropertyDescriptor toolbarBackground = new PropertyDescriptor("toolbarBackground", beanClass);
  176.             toolbarBackground.setBound(false);
  177.             toolbarBackground.setConstrained(false);
  178.             toolbarBackground.setDisplayName(prop.getString("toolbarBackground"));
  179.  
  180.  
  181.             PropertyDescriptor rv[] = {dataBinding, columns, rows,
  182.                                         //appendButton,
  183.                                         insertButton,
  184.                                         gotoButton, undoButton,
  185.                                         restartButton, deleteButton,
  186.                                        // undeleteButton,
  187.                                         saveButton,
  188.                                         toolbarBackground};
  189.  
  190.             return rv;
  191.         }
  192.         catch (IntrospectionException e)
  193.         {
  194.             throw new Error(e.toString());
  195.         }
  196.     }
  197.  
  198.     /**
  199.      * Returns the index of the property expected to be changed most often by the designer.
  200.      */
  201.     public int getDefaultPropertyIndex() {
  202.         return 0;    //  the index for our default property is always 0
  203.     }
  204.  
  205.     private final static Class beanClass = Grid.class;
  206. }
  207.