home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / Source.bin / SoundPlayerBeanInfo.java < prev    next >
Text File  |  1998-03-18  |  9KB  |  257 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 SoundPlayer.
  9.  *
  10.  */
  11.  
  12. public class SoundPlayerBeanInfo extends SimpleBeanInfo {
  13.  
  14.     /**
  15.      * Constructs a SoundPlayerBeanInfo object.
  16.      */
  17.     public SoundPlayerBeanInfo() {
  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.setFlags("invisible");
  44.         bd.setWinHelp("0x1238D");
  45.         bd.setFolder(s);
  46.         bd.setToolbar(s);
  47.  
  48.         return (BeanDescriptor) bd;
  49.     }
  50.  
  51.     /**
  52.      * Gets an image that may be used to visually represent this bean
  53.      * (in the toolbar, on a form, etc).
  54.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  55.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  56.      * @return an image for this bean, always color even if requested monochrome
  57.      * @see BeanInfo#ICON_MONO_16x16
  58.      * @see BeanInfo#ICON_COLOR_16x16
  59.      * @see BeanInfo#ICON_MONO_32x32
  60.      * @see BeanInfo#ICON_COLOR_32x32
  61.      */
  62.     public java.awt.Image getIcon(int iconKind) {
  63.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  64.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  65.             java.awt.Image img = loadImage("SoundPlayerC16.gif");
  66.             return img;
  67.         }
  68.  
  69.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  70.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  71.             java.awt.Image img = loadImage("SoundPlayerC32.gif");
  72.             return img;
  73.         }
  74.  
  75.         return null;
  76.     }
  77.  
  78.     /**
  79.      * Gets an array of descriptions of the methods used for "connections" by
  80.      * Visual CafΘ's Interaction Wizard.
  81.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  82.      * @return method descriptions for this bean
  83.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  84.      */
  85.     public MethodDescriptor[] getMethodDescriptors() {
  86.         Class[] args;
  87.         ConnectionDescriptor connection;
  88.         java.util.Vector connections;
  89.         java.util.Vector md = new java.util.Vector();
  90.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  91.  
  92.         try{
  93.             args = new Class[1];
  94.             args[0] = java.lang.String.class ;
  95.             MethodDescriptor addStringURL = new MethodDescriptor(beanClass.getMethod("addStringURL", args));
  96.  
  97.             connections = new java.util.Vector();
  98.             connection = new ConnectionDescriptor("input", "String", "",
  99.                                     "%name%.addStringURL(%arg%);",
  100.                                     conn.getString("addStringURL"));
  101.             connections.addElement(connection);
  102.  
  103.             addStringURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  104.             md.addElement(addStringURL);
  105.         } catch (Exception e) { throw new Error("addStringURL:: " + e.toString()); }
  106.  
  107.         try{
  108.             args = null;
  109.             MethodDescriptor getRepeat = new MethodDescriptor(beanClass.getMethod("getRepeat", args));
  110.  
  111.             connections = new java.util.Vector();
  112.             connection = new ConnectionDescriptor("output", "int", "",
  113.                                     "%name%.getRepeat()",
  114.                                     conn.getString("getRepeat"));
  115.             connections.addElement(connection);
  116.  
  117.             getRepeat.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  118.             md.addElement(getRepeat);
  119.         } catch (Exception e) { throw new Error("getRepeat:: " + e.toString()); }
  120.  
  121.         try{
  122.             args = null;
  123.             MethodDescriptor isSyncMode = new MethodDescriptor(beanClass.getMethod("isSyncMode", args));
  124.  
  125.             connections = new java.util.Vector();
  126.             connection = new ConnectionDescriptor("output", "boolean", "",
  127.                                     "%name%.isSyncMode()",
  128.                                     conn.getString("isSyncMode"));
  129.             connections.addElement(connection);
  130.  
  131.             isSyncMode.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  132.             md.addElement(isSyncMode);
  133.         } catch (Exception e) { throw new Error("isSyncMode:: " + e.toString()); }
  134.  
  135.         try{
  136.             args = new Class[1];
  137.             args[0] = java.lang.Boolean.TYPE ;
  138.             MethodDescriptor setSyncMode = new MethodDescriptor(beanClass.getMethod("setSyncMode", args));
  139.  
  140.             connections = new java.util.Vector();
  141.             connection = new ConnectionDescriptor("input", "boolean", "",
  142.                                     "%name%.setSyncMode(%arg%);",
  143.                                     conn.getString("setSyncMode"));
  144.             connections.addElement(connection);
  145.  
  146.             setSyncMode.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  147.             md.addElement(setSyncMode);
  148.         } catch (Exception e) { throw new Error("setSyncMode:: " + e.toString()); }
  149.  
  150.         try{
  151.             args = null;
  152.             MethodDescriptor stop = new MethodDescriptor(beanClass.getMethod("stop", args));
  153.  
  154.             connections = new java.util.Vector();
  155.             connection = new ConnectionDescriptor("input", "void", "",
  156.                                     "%name%.stop();",
  157.                                     conn.getString("stopSP"));
  158.             connections.addElement(connection);
  159.  
  160.             connection = new ConnectionDescriptor("input", "int", "",
  161.                                     "%name%.stop(%arg%);",
  162.                                     conn.getString("stopSPDelay"));
  163.             connections.addElement(connection);
  164.  
  165.             stop.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  166.             md.addElement(stop);
  167.         } catch (Exception e) { throw new Error("stop:: " + e.toString()); }
  168.  
  169.         try{
  170.             args = new Class[1];
  171.             args[0] = java.lang.Integer.TYPE ;
  172.             MethodDescriptor setRepeat = new MethodDescriptor(beanClass.getMethod("setRepeat", args));
  173.  
  174.             connections = new java.util.Vector();
  175.             connection = new ConnectionDescriptor("input", "int", "",
  176.                                     "%name%.setRepeat(%arg%);",
  177.                                     conn.getString("setRepeatSP"));
  178.             connections.addElement(connection);
  179.  
  180.             setRepeat.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  181.             md.addElement(setRepeat);
  182.         } catch (Exception e) { throw new Error("setRepeat:: " + e.toString()); }
  183.  
  184.         try{
  185.             args = null;
  186.             MethodDescriptor play = new MethodDescriptor(beanClass.getMethod("play", args));
  187.  
  188.             connections = new java.util.Vector();
  189.             connection = new ConnectionDescriptor("input", "void", "",
  190.                                     "%name%.play();",
  191.                                     conn.getString("play"));
  192.             connections.addElement(connection);
  193.  
  194.             play.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  195.             md.addElement(play);
  196.         } catch (Exception e) { throw new Error("play:: " + e.toString()); }
  197.  
  198.         try{
  199.             args = new Class[1];
  200.             args[0] = java.net.URL.class ;
  201.             MethodDescriptor addURL = new MethodDescriptor(beanClass.getMethod("addURL", args));
  202.  
  203.             connections = new java.util.Vector();
  204.             connection = new ConnectionDescriptor("input", "RelativeURL", "",
  205.                                     "%name%.addURL(symantec.itools.net.RelativeURL.getURL(%arg%));",
  206.                                     conn.getString("addURLRelative"));
  207.             connections.addElement(connection);
  208.  
  209.             connection = new ConnectionDescriptor("input", "URL", "",
  210.                                     "%name%.addURL(%arg%);",
  211.                                     conn.getString("addURL"));
  212.             connections.addElement(connection);
  213.  
  214.             addURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  215.             md.addElement(addURL);
  216.         } catch (Exception e) { throw new Error("addURL:: " + e.toString()); }
  217.  
  218.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  219.         md.copyInto(rv);
  220.  
  221.         return rv;
  222.     }
  223.  
  224.     /**
  225.      * Returns descriptions of this bean's properties.
  226.      */
  227.     public PropertyDescriptor[] getPropertyDescriptors() {
  228.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  229.  
  230.         try{
  231.         PropertyDescriptor syncMode = new PropertyDescriptor("syncMode", beanClass);
  232.         syncMode.setBound(true);
  233.         syncMode.setConstrained(true);
  234.         syncMode.setDisplayName(prop.getString("syncMode"));
  235.  
  236.         PropertyDescriptor repeat = new PropertyDescriptor("repeat", beanClass);
  237.         repeat.setBound(true);
  238.         repeat.setConstrained(true);
  239.         repeat.setDisplayName(prop.getString("repeatSP"));
  240.  
  241.         PropertyDescriptor uRLList = new PropertyDescriptor("uRLList", beanClass);
  242.         uRLList.setBound(true);
  243.         uRLList.setConstrained(true);
  244.         uRLList.setDisplayName(prop.getString("uRLList"));
  245.         uRLList.setValue("URLFILTER", prop.getString("soundURLFILTER"));
  246.  
  247.         PropertyDescriptor[] rv = {
  248.             syncMode,
  249.             repeat,
  250.             uRLList};
  251.         return rv;
  252.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  253.     }
  254.  
  255.     private final static Class beanClass = SoundPlayer.class;
  256.  
  257.     }    //  end of class SoundPlayerBeanInfo