home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Main.bin / StateCheckBoxBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  8KB  |  227 lines

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