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

  1. package symantec.itools.awt.util;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //     09/19/97    RKM    Fixed connection that called deprecated code
  8.  
  9. /**
  10.  * BeanInfo for StatusScroller.
  11.  *
  12.  */
  13.  
  14. public class StatusScrollerBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a StatusScrollerBeanInfo object.
  18.      */
  19.     public StatusScrollerBeanInfo() {
  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("GroupUtility"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setFolder(s);
  46.         bd.setToolbar(s);
  47.         bd.setWinHelp("0x12396");
  48.  
  49.         return (BeanDescriptor) bd;
  50.     }
  51.  
  52.     /**
  53.      * Gets an image that may be used to visually represent this bean
  54.      * (in the toolbar, on a form, etc).
  55.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  56.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  57.      * @return an image for this bean, always color even if requested monochrome
  58.      * @see BeanInfo#ICON_MONO_16x16
  59.      * @see BeanInfo#ICON_COLOR_16x16
  60.      * @see BeanInfo#ICON_MONO_32x32
  61.      * @see BeanInfo#ICON_COLOR_32x32
  62.      */
  63.     public java.awt.Image getIcon(int iconKind) {
  64.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  65.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  66.             java.awt.Image img = loadImage("StatusScrollerC16.gif");
  67.             return img;
  68.         }
  69.  
  70.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  71.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  72.             java.awt.Image img = loadImage("StatusScrollerC32.gif");
  73.             return img;
  74.         }
  75.  
  76.         return null;
  77.     }
  78.  
  79.     /**
  80.      * Gets an array of descriptions of the methods used for "connections" by
  81.      * Visual CafΘ's Interaction Wizard.
  82.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  83.      * @return method descriptions for this bean
  84.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  85.      */
  86.     public MethodDescriptor[] getMethodDescriptors() {
  87.         Class[] args;
  88.         ConnectionDescriptor connection;
  89.         java.util.Vector connections;
  90.         java.util.Vector md = new java.util.Vector();
  91.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  92.  
  93.         try{
  94.             args = null;
  95.             MethodDescriptor isScrollClean = new MethodDescriptor(beanClass.getMethod("isScrollClean", args));
  96.  
  97.             connections = new java.util.Vector();
  98.             connection = new ConnectionDescriptor("output", "boolean", "",
  99.                                     "%name%.isScrollClean()",
  100.                                     conn.getString("isScrollClean"));
  101.             connections.addElement(connection);
  102.  
  103.             isScrollClean.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  104.             md.addElement(isScrollClean);
  105.         } catch (Exception e) { throw new Error("isScrollClean:: " + e.toString()); }
  106.  
  107.         try{
  108.             args = new Class[1];
  109.             args[0] = java.lang.Boolean.TYPE ;
  110.             MethodDescriptor setScrollClean = new MethodDescriptor(beanClass.getMethod("setScrollClean", args));
  111.  
  112.             connections = new java.util.Vector();
  113.             connection = new ConnectionDescriptor("input", "boolean", "",
  114.                                     "%name%.setScrollClean(%arg%);",
  115.                                     conn.getString("setScrollClean"));
  116.             connections.addElement(connection);
  117.  
  118.             setScrollClean.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  119.             md.addElement(setScrollClean);
  120.         } catch (Exception e) { throw new Error("setScrollClean:: " + e.toString()); }
  121.  
  122.         try{
  123.             args = new Class[1];
  124.             args[0] = java.lang.String.class ;
  125.             MethodDescriptor setString = new MethodDescriptor(beanClass.getMethod("setString", args));
  126.  
  127.             connections = new java.util.Vector();
  128.             connection = new ConnectionDescriptor("input", "String", "",
  129.                                     "%name%.setString(%arg%);",
  130.                                     conn.getString("setString"));
  131.             connections.addElement(connection);
  132.  
  133.             setString.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  134.             md.addElement(setString);
  135.         } catch (Exception e) { throw new Error("setString:: " + e.toString()); }
  136.  
  137.         try{
  138.             args = null;
  139.             MethodDescriptor isRightToLeft = new MethodDescriptor(beanClass.getMethod("isRightToLeft", args));
  140.  
  141.             connections = new java.util.Vector();
  142.             connection = new ConnectionDescriptor("output", "boolean", "",
  143.                                     "%name%.isRightToLeft()",
  144.                                     conn.getString("isRightToLeft"));
  145.             connections.addElement(connection);
  146.  
  147.             isRightToLeft.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  148.             md.addElement(isRightToLeft);
  149.         } catch (Exception e) { throw new Error("isRightToLeft:: " + e.toString()); }
  150.  
  151.         try{
  152.             args = new Class[1];
  153.             args[0] = java.lang.Boolean.TYPE ;
  154.             MethodDescriptor setRightToLeft = new MethodDescriptor(beanClass.getMethod("setRightToLeft", args));
  155.  
  156.             connections = new java.util.Vector();
  157.             connection = new ConnectionDescriptor("input", "void", "",
  158.                                     "%name%.setRightToLeft(%name%.isRightToLeft());",
  159.                                     conn.getString("setRightToLeftToggle"));
  160.             connections.addElement(connection);
  161.  
  162.             connection = new ConnectionDescriptor("input", "boolean", "",
  163.                                     "%name%.setRightToLeft(%arg%);",
  164.                                     conn.getString("setRightToLeft"));
  165.             connections.addElement(connection);
  166.  
  167.             setRightToLeft.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  168.             md.addElement(setRightToLeft);
  169.         } catch (Exception e) { throw new Error("setRightToLeft:: " + e.toString()); }
  170.  
  171.         try{
  172.             args = null;
  173.             MethodDescriptor isAutoStart = new MethodDescriptor(beanClass.getMethod("isAutoStart", args));
  174.  
  175.             connections = new java.util.Vector();
  176.             connection = new ConnectionDescriptor("output", "boolean", "",
  177.                                     "%name%.isAutoStart()",
  178.                                     conn.getString("isAutoStart"));
  179.             connections.addElement(connection);
  180.  
  181.             isAutoStart.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  182.             md.addElement(isAutoStart);
  183.         } catch (Exception e) { throw new Error("isAutoStart:: " + e.toString()); }
  184.  
  185.         try{
  186.             args = new Class[1];
  187.             args[0] = java.lang.Integer.TYPE ;
  188.             MethodDescriptor setDelay = new MethodDescriptor(beanClass.getMethod("setDelay", args));
  189.  
  190.             connections = new java.util.Vector();
  191.             connection = new ConnectionDescriptor("input", "int", "",
  192.                                     "%name%.setDelay(%arg%);",
  193.                                     conn.getString("setDelay"));
  194.             connections.addElement(connection);
  195.  
  196.             setDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  197.             md.addElement(setDelay);
  198.         } catch (Exception e) { throw new Error("setDelay:: " + e.toString()); }
  199.  
  200.         try{
  201.             args = null;
  202.             MethodDescriptor stop = new MethodDescriptor(beanClass.getMethod("stop", args));
  203.  
  204.             connections = new java.util.Vector();
  205.             connection = new ConnectionDescriptor("input", "void", "",
  206.                                     "%name%.stop();",
  207.                                     conn.getString("stop"));
  208.             connections.addElement(connection);
  209.  
  210.             stop.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  211.             md.addElement(stop);
  212.         } catch (Exception e) { throw new Error("stop:: " + e.toString()); }
  213.  
  214.         try{
  215.             args = new Class[1];
  216.             args[0] = java.lang.Boolean.TYPE ;
  217.             MethodDescriptor setRepeat = new MethodDescriptor(beanClass.getMethod("setRepeat", args));
  218.  
  219.             connections = new java.util.Vector();
  220.             connection = new ConnectionDescriptor("input", "boolean", "",
  221.                                     "%name%.setRepeat(%arg%);",
  222.                                     conn.getString("setRepeat"));
  223.             connections.addElement(connection);
  224.  
  225.             setRepeat.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  226.             md.addElement(setRepeat);
  227.         } catch (Exception e) { throw new Error("setRepeat:: " + e.toString()); }
  228.  
  229.         try{
  230.             args = null;
  231.             MethodDescriptor isRepeat = new MethodDescriptor(beanClass.getMethod("isRepeat", args));
  232.  
  233.             connections = new java.util.Vector();
  234.             connection = new ConnectionDescriptor("output", "boolean", "",
  235.                                     "%name%.isRepeat()",
  236.                                     conn.getString("isRepeat"));
  237.             connections.addElement(connection);
  238.  
  239.             isRepeat.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  240.             md.addElement(isRepeat);
  241.         } catch (Exception e) { throw new Error("isRepeat:: " + e.toString()); }
  242.  
  243.         try{
  244.             args = null;
  245.             MethodDescriptor getString = new MethodDescriptor(beanClass.getMethod("getString", args));
  246.  
  247.             connections = new java.util.Vector();
  248.             connection = new ConnectionDescriptor("output", "String", "",
  249.                                     "%name%.getString()",
  250.                                     conn.getString("getString"));
  251.             connections.addElement(connection);
  252.  
  253.             getString.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  254.             md.addElement(getString);
  255.         } catch (Exception e) { throw new Error("getString:: " + e.toString()); }
  256.  
  257.         try{
  258.             args = null;
  259.             MethodDescriptor getDelay = new MethodDescriptor(beanClass.getMethod("getDelay", args));
  260.  
  261.             connections = new java.util.Vector();
  262.             connection = new ConnectionDescriptor("output", "int", "",
  263.                                     "%name%.getDelay()",
  264.                                     conn.getString("getDelay"));
  265.             connections.addElement(connection);
  266.  
  267.             getDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  268.             md.addElement(getDelay);
  269.         } catch (Exception e) { throw new Error("getDelay:: " + e.toString()); }
  270.  
  271.         try{
  272.             args = null;
  273.             MethodDescriptor clear = new MethodDescriptor(beanClass.getMethod("clear", args));
  274.  
  275.             connections = new java.util.Vector();
  276.             connection = new ConnectionDescriptor("input", "void", "",
  277.                                     "%name%.clear();",
  278.                                     conn.getString("clearStatusArea"));
  279.             connections.addElement(connection);
  280.  
  281.             clear.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  282.             md.addElement(clear);
  283.         } catch (Exception e) { throw new Error("clear:: " + e.toString()); }
  284.  
  285.         try{
  286.             args = null;
  287.             MethodDescriptor start = new MethodDescriptor(beanClass.getMethod("start", args));
  288.  
  289.             connections = new java.util.Vector();
  290.             connection = new ConnectionDescriptor("input", "void", "",
  291.                                     "%name%.start();",
  292.                                     conn.getString("start"));
  293.             connections.addElement(connection);
  294.  
  295.             start.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  296.             md.addElement(start);
  297.         } catch (Exception e) { throw new Error("start:: " + e.toString()); }
  298.  
  299.         try{
  300.             args = new Class[1];
  301.             args[0] = java.lang.Boolean.TYPE ;
  302.             MethodDescriptor setAutoStart = new MethodDescriptor(beanClass.getMethod("setAutoStart", args));
  303.  
  304.             connections = new java.util.Vector();
  305.             connection = new ConnectionDescriptor("input", "boolean", "",
  306.                                     "%name%.setAutoStart(%arg%);",
  307.                                     conn.getString("setAutoStart"));
  308.             connections.addElement(connection);
  309.  
  310.             setAutoStart.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  311.             md.addElement(setAutoStart);
  312.         } catch (Exception e) { throw new Error("setAutoStart:: " + e.toString()); }
  313.  
  314.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  315.         md.copyInto(rv);
  316.  
  317.         return rv;
  318.     }
  319.  
  320.     /**
  321.      * Returns descriptions of this bean's properties.
  322.      */
  323.     public PropertyDescriptor[] getPropertyDescriptors() {
  324.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  325.  
  326.         try{
  327.         PropertyDescriptor defProperty = new PropertyDescriptor("string", beanClass);
  328.         defProperty.setBound(true);
  329.         defProperty.setConstrained(true);
  330.         defProperty.setDisplayName(prop.getString("string"));
  331.  
  332.         PropertyDescriptor delay = new PropertyDescriptor("delay", beanClass);
  333.         delay.setBound(true);
  334.         delay.setConstrained(true);
  335.         delay.setDisplayName(prop.getString("delay"));
  336.  
  337.         PropertyDescriptor repeat = new PropertyDescriptor("repeat", beanClass);
  338.         repeat.setBound(true);
  339.         repeat.setConstrained(true);
  340.         repeat.setDisplayName(prop.getString("repeat"));
  341.  
  342.         PropertyDescriptor rightToLeft = new PropertyDescriptor("rightToLeft", beanClass);
  343.         rightToLeft.setBound(true);
  344.         rightToLeft.setConstrained(true);
  345.         rightToLeft.setDisplayName(prop.getString("rightToLeft"));
  346.  
  347.         PropertyDescriptor scrollClean = new PropertyDescriptor("scrollClean", beanClass);
  348.         scrollClean.setBound(true);
  349.         scrollClean.setConstrained(true);
  350.         scrollClean.setDisplayName(prop.getString("scrollClean"));
  351.  
  352.         PropertyDescriptor autoStart = new PropertyDescriptor("autoStart", beanClass);
  353.         autoStart.setBound(true);
  354.         autoStart.setConstrained(true);
  355.         autoStart.setDisplayName(prop.getString("autoStart"));
  356.  
  357.         PropertyDescriptor[] rv = {
  358.             defProperty,
  359.             delay,
  360.             repeat,
  361.             rightToLeft,
  362.             scrollClean,
  363.             autoStart};
  364.         return rv;
  365.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  366.     }
  367.  
  368.     /**
  369.      * Returns the index of the property expected to be changed most often by the designer.
  370.      */
  371.     public int getDefaultPropertyIndex() {
  372.         return 0;    //  the index for our default property is always 0
  373.     }
  374.  
  375.     private final static Class beanClass = StatusScroller.class;
  376.  
  377.     }    //  end of class StatusScrollerBeanInfo