home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1999 February / CDW0299.iso / Demos / Cafe / Source.bin / RadioButtonGroupPanelBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  5.2 KB  |  150 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/11/97    LAB    Added selectedRadioButtonIndex property and connections.
  8. //  09/13/97    LAB    Removed extranious getPropertyDescriptors method and
  9. //                    removed extranious getMethodDescriptors method.
  10.  
  11. /**
  12.  * BeanInfo for RadioButtonGroupPanel.
  13.  *
  14.  */
  15. public class RadioButtonGroupPanelBeanInfo extends SimpleBeanInfo {
  16.  
  17.     /**
  18.      * Constructs a RadioButtonGroupPanelBeanInfo object.
  19.      */
  20.     public RadioButtonGroupPanelBeanInfo() {
  21.     }
  22.  
  23.     /**
  24.      * Gets a BeanInfo for the superclass of this bean.
  25.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  26.      */
  27.     public BeanInfo[] getAdditionalBeanInfo() {
  28.         try {
  29.             BeanInfo[] bi = new BeanInfo[1];
  30.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  31.             return bi;
  32.         }
  33.         catch (IntrospectionException e) { throw new Error(e.toString());}
  34.     }
  35.  
  36.     /**
  37.      * Gets the SymantecBeanDescriptor for this bean.
  38.      * @return an object of type SymantecBeanDescriptor
  39.      * @see symantec.itools.beans.SymantecBeanDescriptor
  40.      */
  41.     public BeanDescriptor getBeanDescriptor() {
  42.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  43.         String s=group.getString("GroupPanel"); 
  44.  
  45.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  46.         bd.setFolder(s);
  47.         bd.setToolbar(s);
  48.         bd.setWinHelp("0x123B8");
  49.  
  50.         return (BeanDescriptor) bd;
  51.     }
  52.  
  53.     /**
  54.      * Gets an image that may be used to visually represent this bean
  55.      * (in the toolbar, on a form, etc).
  56.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  57.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  58.      * @return an image for this bean, always color even if requested monochrome
  59.      * @see BeanInfo#ICON_MONO_16x16
  60.      * @see BeanInfo#ICON_COLOR_16x16
  61.      * @see BeanInfo#ICON_MONO_32x32
  62.      * @see BeanInfo#ICON_COLOR_32x32
  63.      */
  64.     public java.awt.Image getIcon(int iconKind) {
  65.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  66.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  67.             java.awt.Image img = loadImage("RadioButtonGroupPanelC16.gif");
  68.             return img;
  69.         }
  70.  
  71.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  72.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  73.             java.awt.Image img = loadImage("RadioButtonGroupPanelC32.gif");
  74.             return img;
  75.         }
  76.  
  77.         return null;
  78.     }
  79.  
  80.     /**
  81.      * Gets an array of descriptions of the methods used for "connections" by
  82.      * Visual CafΘ's Interaction Wizard.
  83.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  84.      * @return method descriptions for this bean
  85.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  86.      */
  87.     public MethodDescriptor[] getMethodDescriptors() {
  88.         Class[] args;
  89.         ConnectionDescriptor connection;
  90.         java.util.Vector connections;
  91.         java.util.Vector md = new java.util.Vector();
  92.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  93.  
  94.         try{
  95.             args = new Class[1];
  96.             args[0] = java.lang.Integer.TYPE ;
  97.             MethodDescriptor setSelectedRadioButtonIndex = new MethodDescriptor(beanClass.getMethod("setSelectedRadioButtonIndex", args));
  98.  
  99.             connections = new java.util.Vector();
  100.             connection = new ConnectionDescriptor("input", "int", "",
  101.                                     "%name%.setSelectedRadioButtonIndex(%arg%);",
  102.                                     conn.getString("setSelectedRadioButtonIndex"));
  103.             connections.addElement(connection);
  104.  
  105.             setSelectedRadioButtonIndex.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  106.             md.addElement(setSelectedRadioButtonIndex);
  107.         } catch (Exception e) { throw new Error("setSelectedRadioButtonIndex:: " + e.toString()); }
  108.  
  109.  
  110.         try{
  111.             args = null;
  112.             MethodDescriptor getSelectedRadioButtonIndex = new MethodDescriptor(beanClass.getMethod("getSelectedRadioButtonIndex", args));
  113.  
  114.             connections = new java.util.Vector();
  115.             connection = new ConnectionDescriptor("output", "int", "",
  116.                                     "%name%.getSelectedRadioButtonIndex()",
  117.                                     conn.getString("getSelectedRadioButtonIndex"));
  118.             connections.addElement(connection);
  119.  
  120.             getSelectedRadioButtonIndex.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  121.             md.addElement(getSelectedRadioButtonIndex);
  122.         } catch (Exception e) { throw new Error("getSelectedRadioButtonIndex:: " + e.toString()); }
  123.  
  124.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  125.         md.copyInto(rv);
  126.  
  127.         return rv;
  128.     }
  129.  
  130.     /**
  131.      * Returns descriptions of this bean's properties.
  132.      */
  133.     public PropertyDescriptor[] getPropertyDescriptors() {
  134.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  135.  
  136.         try{
  137.         PropertyDescriptor selectedRadioButtonIndex = new PropertyDescriptor("selectedRadioButtonIndex", beanClass);
  138.         selectedRadioButtonIndex.setBound(true);
  139.         selectedRadioButtonIndex.setConstrained(true);
  140.         selectedRadioButtonIndex.setDisplayName(prop.getString("selectedRadioButtonIndex"));
  141.  
  142.         PropertyDescriptor[] rv = {
  143.             selectedRadioButtonIndex};
  144.         return rv;
  145.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  146.     }
  147.  
  148.     private final static Class beanClass = RadioButtonGroupPanel.class;
  149.  
  150.     }    //  end of class RadioButtonGroupPanelBeanInfo