home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1999 February / CDW0299.iso / Demos / Cafe / Source.bin / NumericSpinnerBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  4.9 KB  |  151 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 property and connections.  Removed redundant
  8. //                    max and min properties and connections.
  9.  
  10. /**
  11.  * BeanInfo for NumericSpinner.
  12.  *
  13.  */
  14. public class NumericSpinnerBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a NumericSpinnerBeanInfo object.
  18.      */
  19.     public NumericSpinnerBeanInfo() {
  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("0x123A8");
  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("NumericSpinnerC16.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("NumericSpinnerC32.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.Integer.TYPE ;
  99.             MethodDescriptor setIncrement = new MethodDescriptor(beanClass.getMethod("setIncrement", args));
  100.  
  101.             connections = new java.util.Vector();
  102.             connection = new ConnectionDescriptor("input", "int", "",
  103.                                     "%name%.setIncrement(%arg%);",
  104.                                     conn.getString("setIncrement"));
  105.             connections.addElement(connection);
  106.  
  107.             setIncrement.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  108.             md.addElement(setIncrement);
  109.         } catch (Exception e) { throw new Error("setIncrement:: " + e.toString()); }
  110.  
  111.         try{
  112.             args = null;
  113.             MethodDescriptor getIncrement = new MethodDescriptor(beanClass.getMethod("getIncrement", args));
  114.  
  115.             connections = new java.util.Vector();
  116.             connection = new ConnectionDescriptor("output", "int", "",
  117.                                     "%name%.getIncrement()",
  118.                                     conn.getString("getIncrement"));
  119.             connections.addElement(connection);
  120.  
  121.             getIncrement.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  122.             md.addElement(getIncrement);
  123.         } catch (Exception e) { throw new Error("getIncrement:: " + e.toString()); }
  124.  
  125.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  126.         md.copyInto(rv);
  127.  
  128.         return rv;
  129.     }
  130.  
  131.     /**
  132.      * Returns descriptions of this bean's properties.
  133.      */
  134.     public PropertyDescriptor[] getPropertyDescriptors() {
  135.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  136.  
  137.         try{
  138.         PropertyDescriptor increment = new PropertyDescriptor("increment", beanClass);
  139.         increment.setBound(true);
  140.         increment.setConstrained(true);
  141.         increment.setDisplayName(prop.getString("increment"));
  142.  
  143.         PropertyDescriptor[] rv = {
  144.             increment};
  145.         return rv;
  146.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  147.     }
  148.  
  149.     private final static Class beanClass = NumericSpinner.class;
  150.  
  151.     }    //  end of class NumericSpinnerBeanInfo