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 / StateCheckBoxBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  8.4 KB  |  254 lines

  1. /*
  2.  * @(#StateChackBoxBeanInfo.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 StateCheckBox
  16.  *
  17.  */
  18.  
  19. public class StateCheckBoxBeanInfo extends SimpleBeanInfo {
  20.  
  21.     /**
  22.      * Constructs a StateCheckBoxBeanInfo object.
  23.      */
  24.     public StateCheckBoxBeanInfo() {
  25.     }
  26.  
  27.     /**
  28.      * Gets an array of BeanInfo on the superclasses of this object.
  29.      * The superclasses returned are all assignable from class Object
  30.      * (see isAssignableFrom).
  31.      * @return BeanInfo on this class's superclasses
  32.      * @see java.lang.Class#isAssignableFrom
  33.      */
  34.     public BeanInfo[] getAdditionalBeanInfo() {
  35.         try {
  36.             java.util.Vector v = new java.util.Vector();
  37.             BeanInfo[] rv;
  38.             BeanInfo b;
  39.             Class c = beanClass.getSuperclass();
  40.  
  41.             while (c.isAssignableFrom(Object.class) != true) {
  42.                 b = Introspector.getBeanInfo(c);
  43.                 v.addElement(b);
  44.                 c = c.getSuperclass();
  45.             }
  46.             rv = new BeanInfo[v.size()];
  47.             v.copyInto(rv);
  48.  
  49.             return rv;
  50.         }
  51.         catch (IntrospectionException e) { throw new Error(e.toString());}
  52.     }
  53.  
  54.     /**
  55.      * Gets the SymantecBeanDescriptor for this bean.
  56.      * @return an object of type SymantecBeanDescriptor
  57.      * @see symantec.itools.beans.SymantecBeanDescriptor
  58.      */
  59.     public BeanDescriptor getBeanDescriptor() {
  60.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  61.         bd.setFolder("dbAWARE");
  62.         bd.setToolbar("dbAWARE");
  63.  
  64.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.db.resources.ConnBundle");
  65.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  66.                                                 "%name%.TWO_STATE",
  67.                                                 conn.getString("TWO_STATE")));
  68.  
  69.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  70.                                                 "%name%.THREE_STATE",
  71.                                                 conn.getString("THREE_STATE")));
  72.  
  73.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  74.                                                 "%name%.STATE_UNCHECKED",
  75.                                                 conn.getString("STATE_UNCHECKED")));
  76.  
  77.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  78.                                                 "%name%.STATE_CHECKED",
  79.                                                 conn.getString("STATE_CHECKED")));
  80.  
  81.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  82.                                                 "%name%.STATE_DEFAULT",
  83.                                                 conn.getString("STATE_DEFAULT")));
  84.  
  85.  
  86.         return (BeanDescriptor) bd;
  87.     }
  88.  
  89.     /**
  90.      * Gets an image that may be used to visually represent this bean
  91.      * (in the toolbar, on a form, etc).
  92.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  93.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  94.      * @return an image for this bean, always color even if requested monochrome
  95.      * @see BeanInfo#ICON_MONO_16x16
  96.      * @see BeanInfo#ICON_COLOR_16x16
  97.      * @see BeanInfo#ICON_MONO_32x32
  98.      * @see BeanInfo#ICON_COLOR_32x32
  99.      */
  100.     public java.awt.Image getIcon(int iconKind) {
  101.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  102.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  103.             java.awt.Image img = loadImage("StateCheckBoxC16.gif");
  104.             return img;
  105.         }
  106.  
  107.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  108.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  109.             java.awt.Image img = loadImage("StateCheckBoxC32.gif");
  110.             return img;
  111.         }
  112.  
  113.         return null;
  114.     }
  115.  
  116.     /**
  117.      * Gets an array of descriptions of the methods used for "connections" by
  118.      * Visual CafΘ's Interaction Wizard.
  119.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  120.      * @return method descriptions for this bean
  121.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  122.      */
  123.     public MethodDescriptor[] getMethodDescriptors() {
  124.         Class[] args;
  125.         ConnectionDescriptor connection;
  126.         java.util.Vector connections;
  127.         java.util.Vector md = new java.util.Vector();
  128.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.db.resources.ConnBundle");
  129.  
  130.         try{
  131.             args = new Class[1];
  132.             args[0] = java.lang.Integer.TYPE ;
  133.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setStyle", args));
  134.  
  135.             connections = new java.util.Vector();
  136.             connection = new ConnectionDescriptor("input", "int", "",
  137.                                     "%name%.setStyle(%arg%);",
  138.                                     conn.getString("setStyle"));
  139.             connections.addElement(connection);
  140.  
  141.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  142.             md.addElement(setStyle);
  143.         } catch (Exception e) { throw new Error("setStyle:: " + e.toString()); }
  144.  
  145.         try{
  146.             args = null;
  147.             MethodDescriptor getStyle = new MethodDescriptor(beanClass.getMethod("getStyle", args));
  148.  
  149.             connections = new java.util.Vector();
  150.             connection = new ConnectionDescriptor("output", "int", "",
  151.                                     "%name%.getStyle()",
  152.                                     conn.getString("getStyle"));
  153.             connections.addElement(connection);
  154.  
  155.             getStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  156.             md.addElement(getStyle);
  157.         } catch (Exception e) { throw new Error("getStyle:: " + e.toString()); }
  158.  
  159.         try{
  160.             args = new Class[1];
  161.             args[0] = java.lang.Integer.TYPE ;
  162.             MethodDescriptor setState = new MethodDescriptor(beanClass.getMethod("setState", args));
  163.  
  164.             connections = new java.util.Vector();
  165.             connection = new ConnectionDescriptor("input", "int", "",
  166.                                     "%name%.setState(%arg%);",
  167.                                     conn.getString("setStateValue"));
  168.             connections.addElement(connection);
  169.  
  170.             connection = new ConnectionDescriptor("input", "void", "",
  171.                                     "%name%.setState(%name%.STATE_UNCHECKED);",
  172.                                     conn.getString("setStateUnCheck"));
  173.             connections.addElement(connection);
  174.  
  175.             connection = new ConnectionDescriptor("input", "void", "",
  176.                                     "%name%.setState(%name%.STATE_CHECKED);",
  177.                                     conn.getString("setStateCheck"));
  178.             connections.addElement(connection);
  179.  
  180.             setState.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  181.             md.addElement(setState);
  182.         } catch (Exception e) { throw new Error("setState:: " + e.toString()); }
  183.  
  184.         try{
  185.             args = null;
  186.             MethodDescriptor getState = new MethodDescriptor(beanClass.getMethod("getState", args));
  187.  
  188.             connections = new java.util.Vector();
  189.             connection = new ConnectionDescriptor("output", "int", "",
  190.                                     "%name%.getState()",
  191.                                     conn.getString("getState"));
  192.             connections.addElement(connection);
  193.  
  194.             connection = new ConnectionDescriptor("output", "boolean", "",
  195.                                     "(%name%.getState() == %name%.STATE_CHECKED)",
  196.                                     conn.getString("IscheckboxOn"));
  197.             connections.addElement(connection);
  198.  
  199.             connection = new ConnectionDescriptor("output", "boolean", "",
  200.                                     "(%name%.getState() == %name%.STATE_UNCHECKED)",
  201.                                     conn.getString("IscheckboxOff"));
  202.             connections.addElement(connection);
  203.  
  204.             getState.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  205.             md.addElement(getState);
  206.         } catch (Exception e) { throw new Error("getState:: " + e.toString()); }
  207.  
  208.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  209.         md.copyInto(rv);
  210.  
  211.         return rv;
  212.     }
  213.  
  214.     /**
  215.      * Returns descriptions of this bean's properties.
  216.      */
  217.     public PropertyDescriptor[] getPropertyDescriptors() {
  218.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.db.resources.PropBundle");
  219.  
  220.         try{
  221.         PropertyDescriptor style = new PropertyDescriptor("style", beanClass);
  222.         style.setBound(true);
  223.         style.setConstrained(true);
  224.         style.setDisplayName(prop.getString("style"));
  225.         style.setValue("ENUMERATION", "TWO_STATE=0, THREE_STATE=1");
  226.  
  227.         PropertyDescriptor state = new PropertyDescriptor("state", beanClass);
  228.         state.setBound(true);
  229.         state.setConstrained(true);
  230.         state.setDisplayName(prop.getString("state"));
  231.         state.setValue("ENUMERATION", "STATE_UNCHECKED=0, STATE_CHECKED=1, STATE_DEFAULT=2");
  232.  
  233.         PropertyDescriptor dynamicUpdate = new PropertyDescriptor("dynamicUpdate", beanClass);
  234.         dynamicUpdate.setBound(false);
  235.         dynamicUpdate.setConstrained(false);
  236.         dynamicUpdate.setDisplayName(prop.getString("dynamicUpdate"));
  237.  
  238.         PropertyDescriptor emptyData = new PropertyDescriptor("emptyMeansNull", beanClass);
  239.         emptyData.setBound(false);
  240.         emptyData.setConstrained(false);
  241.         emptyData.setDisplayName(prop.getString("emptyMeansNull"));
  242.  
  243.         PropertyDescriptor[] rv = {
  244.             style,
  245.             state,
  246.             dynamicUpdate,
  247.             emptyData};
  248.         return rv;
  249.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  250.     }
  251.  
  252.     private final static Class beanClass = StateCheckBox.class;
  253.  
  254.     }    //  end of class StateCheckBoxBeanInfo