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

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