home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / prosrc.bin / DBTstampBeanInfo.java < prev    next >
Text File  |  1998-03-18  |  10KB  |  300 lines

  1. /*
  2.  * @(#DBTstampBeanInfo.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 DBTstamp component.
  16.  *
  17.  */
  18.  
  19. public class DBTstampBeanInfo extends SimpleBeanInfo {
  20.  
  21.     /**
  22.      * Constructs a DBTstampBeanInfo object.
  23.      */
  24.     public DBTstampBeanInfo() {
  25.     }
  26.  
  27.     /**
  28.      * Gets BeanInfo for the superclass of this bean.
  29.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  30.      */
  31.     public BeanInfo[] getAdditionalBeanInfo() {
  32.         try {
  33.             java.util.Vector v = new java.util.Vector();
  34.             BeanInfo[] rv;
  35.             BeanInfo b;
  36.             Class c = beanClass.getSuperclass();
  37.  
  38.             while (c.isAssignableFrom(Object.class) != true) {
  39.                 b = Introspector.getBeanInfo(c);
  40.                 v.addElement(b);
  41.                 c = c.getSuperclass();
  42.             }
  43.             rv = new BeanInfo[v.size()];
  44.             v.copyInto(rv);
  45.  
  46.             return rv;
  47.         }
  48.         catch (IntrospectionException e) { throw new Error(e.toString());}
  49.     }
  50.  
  51.     /**
  52.      * Gets the SymantecBeanDescriptor for this bean.
  53.      * @return an object of type SymantecBeanDescriptor
  54.      * @see symantec.itools.beans.SymantecBeanDescriptor
  55.      */
  56.     public BeanDescriptor getBeanDescriptor() {
  57.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  58.         bd.setFolder("dbAWARE");
  59.         bd.setToolbar("dbAWARE");
  60.         bd.setWinHelp("0x12584");
  61.  
  62.         return (BeanDescriptor) bd;
  63.     }
  64.  
  65.     /**
  66.      * Gets an image that may be used to visually represent this bean
  67.      * (in the toolbar, on a form, etc).
  68.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  69.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  70.      * @return an image for this bean, always color even if requested monochrome
  71.      * @see BeanInfo#ICON_MONO_16x16
  72.      * @see BeanInfo#ICON_COLOR_16x16
  73.      * @see BeanInfo#ICON_MONO_32x32
  74.      * @see BeanInfo#ICON_COLOR_32x32
  75.      */
  76.     public java.awt.Image getIcon(int iconKind) {
  77.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  78.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  79.             java.awt.Image img = loadImage("DBTstampC16.gif");
  80.             return img;
  81.         }
  82.  
  83.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  84.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  85.             java.awt.Image img = loadImage("DBTstampC16.gif");
  86.             return img;
  87.         }
  88.  
  89.         return null;
  90.     }
  91.  
  92.     /**
  93.      * Gets an array of descriptions of the methods used for "connections" by
  94.      * Visual CafΘ's Interaction Wizard.
  95.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  96.      * @return method descriptions for this bean
  97.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  98.      */
  99.     public MethodDescriptor[] getMethodDescriptors() {
  100.         Class[] args;
  101.         ConnectionDescriptor connection;
  102.         java.util.Vector connections;
  103.         java.util.Vector md = new java.util.Vector();
  104.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.db.resources.ConnBundle");
  105.  
  106.         try{
  107.             args = new Class[1];
  108.             args[0] = java.awt.event.ActionEvent.class ;
  109.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("actionPerformed", args));
  110.  
  111.             connections = new java.util.Vector();
  112.             connection = new ConnectionDescriptor("input", "ActionEvent", "",
  113.                                     "%name%.actionPerformed(%arg%);",
  114.                                     conn.getString("actionPerformed"));
  115.             connections.addElement(connection);
  116.  
  117.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  118.             md.addElement(setStyle);
  119.         } catch (Exception e) { throw new Error("actionPerformed:: " + e.toString()); }
  120.  
  121.         try{
  122.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("printTstamp", null));
  123.  
  124.             connections = new java.util.Vector();
  125.             connection = new ConnectionDescriptor("input", "void", "",
  126.                                     "%name%.printTstamp();",
  127.                                     conn.getString("printTstamp"));
  128.             connections.addElement(connection);
  129.  
  130.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  131.             md.addElement(setStyle);
  132.         } catch (Exception e) { throw new Error("actionPerformed:: " + e.toString()); }
  133.  
  134.         try{
  135.             args = new Class[1];
  136.             args[0] = java.lang.String.class ;
  137.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setDisplayFormat", args));
  138.  
  139.             connections = new java.util.Vector();
  140.             connection = new ConnectionDescriptor("input", "String", "",
  141.                                     "%name%.setDisplayFormat(%arg%);",
  142.                                     conn.getString("setDisplayFormat"));
  143.             connections.addElement(connection);
  144.  
  145.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  146.             md.addElement(setStyle);
  147.         } catch (Exception e) { throw new Error("actionPerformed:: " + e.toString()); }
  148.  
  149.         try{
  150.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("getDisplayFormat", null));
  151.  
  152.             connections = new java.util.Vector();
  153.             connection = new ConnectionDescriptor("output", "String", "",
  154.                                     "%name%.getDisplayFormat()",
  155.                                     conn.getString("getDisplayFormat"));
  156.             connections.addElement(connection);
  157.  
  158.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  159.             md.addElement(setStyle);
  160.         } catch (Exception e) { throw new Error("actionPerformed:: " + e.toString()); }
  161.  
  162.         try{
  163.             args = new Class[1];
  164.             args[0] = java.lang.String.class ;
  165.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setEntryFormat", args));
  166.  
  167.             connections = new java.util.Vector();
  168.             connection = new ConnectionDescriptor("input", "String", "",
  169.                                     "%name%.setEntryFormat(%arg%);",
  170.                                     conn.getString("setEntryFormat"));
  171.             connections.addElement(connection);
  172.  
  173.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  174.             md.addElement(setStyle);
  175.         } catch (Exception e) { throw new Error("setEntryFormat:: " + e.toString()); }
  176.  
  177.         try{
  178.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("getEntryFormat", null));
  179.  
  180.             connections = new java.util.Vector();
  181.             connection = new ConnectionDescriptor("output", "String", "",
  182.                                     "%name%.getEntryFormat()",
  183.                                     conn.getString("getEntryFormat"));
  184.             connections.addElement(connection);
  185.  
  186.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  187.             md.addElement(setStyle);
  188.         } catch (Exception e) { throw new Error("getEntryFormat:: " + e.toString()); }
  189.  
  190.         try{
  191.             args = new Class[1];
  192.             args[0] = java.lang.String.class ;
  193.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setTstamp", args));
  194.  
  195.             connections = new java.util.Vector();
  196.             connection = new ConnectionDescriptor("input", "String", "",
  197.                                     "%name%.setTstamp(%arg%);",
  198.                                     conn.getString("setTstampString"));
  199.             connections.addElement(connection);
  200.  
  201.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  202.             md.addElement(setStyle);
  203.         } catch (Exception e) { throw new Error("setTstamp:: " + e.toString()); }
  204.  
  205.         try{
  206.             args = new Class[1];
  207.             args[0] = java.util.Date.class ;
  208.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setTstamp", args));
  209.  
  210.             connections = new java.util.Vector();
  211.             connection = new ConnectionDescriptor("input", "Date", "",
  212.                                     "%name%.setTstamp(%arg%);",
  213.                                     conn.getString("setTstampDate"));
  214.             connections.addElement(connection);
  215.  
  216.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  217.             md.addElement(setStyle);
  218.         } catch (Exception e) { throw new Error("setTstamp:: " + e.toString()); }
  219.  
  220.         try{
  221.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setinequalout", null));
  222.  
  223.             connections = new java.util.Vector();
  224.             connection = new ConnectionDescriptor("input", "void", "",
  225.                                     "%name%.setinequalout();",
  226.                                     conn.getString("setinequalout"));
  227.             connections.addElement(connection);
  228.  
  229.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  230.             md.addElement(setStyle);
  231.         } catch (Exception e) { throw new Error("setTstamp:: " + e.toString()); }
  232.  
  233.         try{
  234.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("getDate", null));
  235.  
  236.             connections = new java.util.Vector();
  237.             connection = new ConnectionDescriptor("output", "Date", "",
  238.                                     "%name%.getDate()",
  239.                                     conn.getString("getDate"));
  240.             connections.addElement(connection);
  241.  
  242.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  243.             md.addElement(setStyle);
  244.         } catch (Exception e) { throw new Error("getDate:: " + e.toString()); }
  245.  
  246.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  247.         md.copyInto(rv);
  248.  
  249.         return rv;
  250.     }
  251.  
  252.     /**
  253.      * Gets an array of descriptions of this bean's properties.
  254.      * @return property descriptions for this bean
  255.      */
  256.     public PropertyDescriptor[] getPropertyDescriptors() {
  257.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.db.resources.PropBundle");
  258.  
  259.         try{
  260.         /*PropertyDescriptor type = new PropertyDescriptor("type", beanClass);
  261.         type.setBound(true);
  262.         type.setConstrained(false);
  263.         type.setDisplayName("Data Type");
  264.         type.setValue("ENUMERATION", "Timestamp=0,Date=1,Time=2");*/
  265.  
  266.         PropertyDescriptor displayFormat = new PropertyDescriptor("displayFormat", beanClass);
  267.         displayFormat.setBound(true);
  268.         displayFormat.setConstrained(false);
  269.         displayFormat.setDisplayName(prop.getString("displayFormat"));
  270.  
  271.         PropertyDescriptor entryFormat = new PropertyDescriptor("entryFormat", beanClass);
  272.         entryFormat.setBound(true);
  273.         entryFormat.setConstrained(false);
  274.         entryFormat.setDisplayName(prop.getString("entryFormat"));
  275.  
  276.         PropertyDescriptor emptyData = new PropertyDescriptor("emptyMeansNull", beanClass);
  277.         emptyData.setBound(false);
  278.         emptyData.setConstrained(false);
  279.         emptyData.setDisplayName(prop.getString("emptyMeansNull"));
  280.  
  281.         PropertyDescriptor pd1 = new PropertyDescriptor("dataBinding", beanClass);
  282.         pd1.setBound(false);
  283.         pd1.setConstrained(false);
  284.         pd1.setDisplayName(prop.getString("dataBinding"));
  285.         pd1.setPropertyEditorClass(symantec.itools.db.beans.binding.NameEditor.class);
  286.  
  287.         PropertyDescriptor[] rv = {
  288.             emptyData,
  289.             displayFormat,
  290.             entryFormat,
  291.             pd1
  292.             };
  293.         return rv;
  294.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  295.     }
  296.  
  297.     private final static Class beanClass = DBTstamp.class;
  298.  
  299.     }    //  end of class DBTstampBeanInfo|
  300.