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

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/07/97    LAB    Removed background, foreground, and font properties (Addresses Mac Bug #7668).
  8.  
  9. /**
  10.  * BeanInfo for DirectionButton.
  11.  *
  12.  */
  13.  
  14. public class DirectionButtonBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a DirectionButtonBeanInfo object.
  18.      */
  19.     public DirectionButtonBeanInfo() {
  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.setFolder(s);
  46.         bd.setToolbar(s);
  47.         bd.setWinHelp("0x123A2");
  48.  
  49.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  50.  
  51.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  52.                                                 "%name%.LEFT",
  53.                                                 conn.getString("LEFT")));
  54.  
  55.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  56.                                                 "%name%.RIGHT",
  57.                                                 conn.getString("RIGHT")));
  58.  
  59.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  60.                                                 "%name%.UP",
  61.                                                 conn.getString("UP")));
  62.  
  63.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  64.                                                 "%name%.DOWN",
  65.                                                 conn.getString("DOWN")));
  66.  
  67.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  68.  
  69.         return (BeanDescriptor) bd;
  70.     }
  71.  
  72.     /**
  73.      * Gets an image that may be used to visually represent this bean
  74.      * (in the toolbar, on a form, etc).
  75.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  76.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  77.      * @return an image for this bean, always color even if requested monochrome
  78.      * @see BeanInfo#ICON_MONO_16x16
  79.      * @see BeanInfo#ICON_COLOR_16x16
  80.      * @see BeanInfo#ICON_MONO_32x32
  81.      * @see BeanInfo#ICON_COLOR_32x32
  82.      */
  83.     public java.awt.Image getIcon(int iconKind) {
  84.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  85.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  86.             java.awt.Image img = loadImage("DirectionButtonC16.gif");
  87.             return img;
  88.         }
  89.  
  90.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  91.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  92.             java.awt.Image img = loadImage("DirectionButtonC32.gif");
  93.             return img;
  94.         }
  95.  
  96.         return null;
  97.     }
  98.  
  99.     /**
  100.      * Gets an array of descriptions of the methods used for "connections" by
  101.      * Visual CafΘ's Interaction Wizard.
  102.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  103.      * @return method descriptions for this bean
  104.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  105.      */
  106.     public MethodDescriptor[] getMethodDescriptors() {
  107.         Class[] args;
  108.         ConnectionDescriptor connection;
  109.         java.util.Vector connections;
  110.         java.util.Vector md = new java.util.Vector();
  111.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  112.  
  113.         try{
  114.             args = new Class[1];
  115.             args[0] = java.lang.Integer.TYPE ;
  116.             MethodDescriptor setDirection = new MethodDescriptor(beanClass.getMethod("setDirection", args));
  117.  
  118.             connections = new java.util.Vector();
  119.             connection = new ConnectionDescriptor("input", "int", "",
  120.                                     "%name%.setDirection(%arg%);",
  121.                                     conn.getString("setDirection"));
  122.             connections.addElement(connection);
  123.  
  124.             setDirection.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  125.             md.addElement(setDirection);
  126.         } catch (Exception e) { throw new Error("setDirection:: " + e.toString()); }
  127.  
  128.         try{
  129.             args = null;
  130.             MethodDescriptor getDirection = new MethodDescriptor(beanClass.getMethod("getDirection", args));
  131.  
  132.             connections = new java.util.Vector();
  133.             connection = new ConnectionDescriptor("output", "int", "",
  134.                                     "%name%.getDirection()",
  135.                                     conn.getString("getDirection"));
  136.             connections.addElement(connection);
  137.  
  138.             getDirection.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  139.             md.addElement(getDirection);
  140.         } catch (Exception e) { throw new Error("getDirection:: " + e.toString()); }
  141.  
  142.         try{
  143.             args = new Class[1];
  144.             args[0] = java.awt.Color.class ;
  145.             MethodDescriptor setArrowColor = new MethodDescriptor(beanClass.getMethod("setArrowColor", args));
  146.  
  147.             connections = new java.util.Vector();
  148.             connection = new ConnectionDescriptor("input", "Color", "",
  149.                                     "%name%.setArrowColor(%arg%);",
  150.                                     conn.getString("setArrowColor"));
  151.             connections.addElement(connection);
  152.  
  153.             setArrowColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  154.             md.addElement(setArrowColor);
  155.         } catch (Exception e) { throw new Error("setArrowColor:: " + e.toString()); }
  156.  
  157.         try{
  158.             args = null;
  159.             MethodDescriptor getArrowColor = new MethodDescriptor(beanClass.getMethod("getArrowColor", args));
  160.  
  161.             connections = new java.util.Vector();
  162.             connection = new ConnectionDescriptor("output", "Color", "",
  163.                                     "%name%.getArrowColor()",
  164.                                     conn.getString("getArrowColor"));
  165.             connections.addElement(connection);
  166.  
  167.             getArrowColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  168.             md.addElement(getArrowColor);
  169.         } catch (Exception e) { throw new Error("getArrowColor:: " + e.toString()); }
  170.  
  171.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  172.         md.copyInto(rv);
  173.  
  174.         return rv;
  175.     }
  176.  
  177.     /**
  178.      * Returns descriptions of this bean's properties.
  179.      */
  180.     public PropertyDescriptor[] getPropertyDescriptors() {
  181.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  182.  
  183.         try{
  184.         PropertyDescriptor direction = new PropertyDescriptor("direction", beanClass);
  185.         direction.setBound(true);
  186.         direction.setConstrained(true);
  187.         direction.setDisplayName(prop.getString("direction"));
  188.         direction.setValue("ENUMERATION", "LEFT=0, RIGHT=1, UP=2, DOWN=3");
  189.  
  190.         PropertyDescriptor arrowIndent = new PropertyDescriptor("arrowIndent", beanClass);
  191.         arrowIndent.setBound(true);
  192.         arrowIndent.setConstrained(true);
  193.         arrowIndent.setDisplayName(prop.getString("arrowIndent"));
  194.  
  195.         PropertyDescriptor arrowColor = new PropertyDescriptor("arrowColor", beanClass);
  196.         arrowColor.setBound(true);
  197.         arrowColor.setConstrained(true);
  198.         arrowColor.setDisplayName(prop.getString("arrowColor"));
  199.  
  200.         PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
  201.         background.setHidden(true);
  202.  
  203.         PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass);
  204.         foreground.setHidden(true);
  205.  
  206.         PropertyDescriptor font = new PropertyDescriptor("font", beanClass);
  207.         font.setHidden(true);
  208.  
  209.         PropertyDescriptor[] rv = {
  210.             direction,
  211.             arrowIndent,
  212.             arrowColor,
  213.             background,
  214.             foreground,
  215.             font};
  216.         return rv;
  217.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  218.     }
  219.  
  220.     private final static Class beanClass = DirectionButton.class;
  221.  
  222.     }    //  end of class DirectionButtonBeanInfo