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

  1. package symantec.itools.awt.util.spinner;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/11/97    LAB    Removed redundant orientation and editable properties and connections
  8. //                    (Addresses Mac Bug #7820).
  9.  
  10. /**
  11.  * BeanInfo for ListSpinner.
  12.  *
  13.  */
  14. public class ListSpinnerBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a ListSpinnerBeanInfo object.
  18.      */
  19.     public ListSpinnerBeanInfo() {
  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("GroupAdditional"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setCanAddChild(false);
  46.         bd.setFolder(s);
  47.         bd.setToolbar(s);
  48.         bd.setWinHelp("0x123A4");
  49.  
  50.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  51.  
  52.         return (BeanDescriptor) bd;
  53.     }
  54.  
  55.     /**
  56.      * Gets an image that may be used to visually represent this bean
  57.      * (in the toolbar, on a form, etc).
  58.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  59.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  60.      * @return an image for this bean, always color even if requested monochrome
  61.      * @see BeanInfo#ICON_MONO_16x16
  62.      * @see BeanInfo#ICON_COLOR_16x16
  63.      * @see BeanInfo#ICON_MONO_32x32
  64.      * @see BeanInfo#ICON_COLOR_32x32
  65.      */
  66.     public java.awt.Image getIcon(int iconKind) {
  67.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  68.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  69.             java.awt.Image img = loadImage("ListSpinnerC16.gif");
  70.             return img;
  71.         }
  72.  
  73.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  74.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  75.             java.awt.Image img = loadImage("ListSpinnerC32.gif");
  76.             return img;
  77.         }
  78.  
  79.         return null;
  80.     }
  81.  
  82.     /**
  83.      * Gets an array of descriptions of the methods used for "connections" by
  84.      * Visual CafΘ's Interaction Wizard.
  85.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  86.      * @return method descriptions for this bean
  87.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  88.      */
  89.     public MethodDescriptor[] getMethodDescriptors() {
  90.         Class[] args;
  91.         ConnectionDescriptor connection;
  92.         java.util.Vector connections;
  93.         java.util.Vector md = new java.util.Vector();
  94.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  95.  
  96.         try{
  97.             args = new Class[1];
  98.             args[0] = java.lang.String.class ;
  99.             MethodDescriptor addItem = new MethodDescriptor(beanClass.getMethod("addItem", args));
  100.             connections = new java.util.Vector();
  101.             connection = new ConnectionDescriptor("input", "String", "",
  102.                                     "%name%.addItem(%arg%);",
  103.                                     conn.getString("addItemSpinner"));
  104.             connections.addElement(connection);
  105.  
  106.             addItem.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  107.             md.addElement(addItem);
  108.         } catch (Exception e) { throw new Error("addItem:: " + e.toString()); }
  109.  
  110.         try{
  111.             args = null;
  112.             MethodDescriptor getCurrentText = new MethodDescriptor(beanClass.getMethod("getCurrentText", args));
  113.  
  114.             connections = new java.util.Vector();
  115.             connection = new ConnectionDescriptor("output", "String", "",
  116.                                     "%name%.getCurrentText()",
  117.                                     conn.getString("getCurrentText"));
  118.             connections.addElement(connection);
  119.  
  120.             getCurrentText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  121.             md.addElement(getCurrentText);
  122.         } catch (Exception e) { throw new Error("getCurrentText:: " + 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 listItems = new PropertyDescriptor("listItems", beanClass);
  138.         listItems.setBound(true);
  139.         listItems.setConstrained(true);
  140.         listItems.setDisplayName(prop.getString("listItems"));
  141.  
  142.         PropertyDescriptor allowDynamicResizing = new PropertyDescriptor("allowDynamicResizing", beanClass);
  143.         allowDynamicResizing.setBound(true);
  144.         allowDynamicResizing.setConstrained(true);
  145.         allowDynamicResizing.setDisplayName(prop.getString("allowDynamicResizing"));
  146.  
  147.         PropertyDescriptor[] rv = {
  148.             listItems,
  149.             allowDynamicResizing};
  150.         return rv;
  151.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  152.     }
  153.  
  154.     private final static Class beanClass = ListSpinner.class;
  155.  
  156.     }    //  end of class ListSpinnerBeanInfo