home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1999 February / CDW0299.iso / Demos / Cafe / Source.bin / PlasmaBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  4.5 KB  |  145 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 Plasma.
  9.  *
  10.  */
  11.  
  12. public class PlasmaBeanInfo extends SimpleBeanInfo {
  13.  
  14.     /**
  15.      * Constructs a PlasmaBeanInfo object.
  16.      */
  17.     public PlasmaBeanInfo() {
  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("0x1239B");
  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("PlasmaC16.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("PlasmaC32.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 startPlasma = new MethodDescriptor(beanClass.getMethod("startPlasma", args));
  94.  
  95.             connections = new java.util.Vector();
  96.             connection = new ConnectionDescriptor("input", "void", "",
  97.                                     "%name%.startPlasma();",
  98.                                     conn.getString("startPlasma"));
  99.             connections.addElement(connection);
  100.  
  101.             startPlasma.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  102.             md.addElement(startPlasma);
  103.         } catch (Exception e) { throw new Error("startPlasma:: " + e.toString()); }
  104.  
  105.         try{
  106.             args = null;
  107.             MethodDescriptor stopPlasma = new MethodDescriptor(beanClass.getMethod("stopPlasma", args));
  108.  
  109.             connections = new java.util.Vector();
  110.             connection = new ConnectionDescriptor("input", "void", "",
  111.                                     "%name%.stopPlasma();",
  112.                                     conn.getString("stopPlasma"));
  113.             connections.addElement(connection);
  114.  
  115.             stopPlasma.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  116.             md.addElement(stopPlasma);
  117.         } catch (Exception e) { throw new Error("stopPlasma:: " + e.toString()); }
  118.  
  119.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  120.         md.copyInto(rv);
  121.  
  122.         return rv;
  123.     }
  124.  
  125.     /**
  126.      * Returns descriptions of this bean's properties.
  127.      */
  128.     public PropertyDescriptor[] getPropertyDescriptors() {
  129.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  130.  
  131.         try{
  132.         PropertyDescriptor previewMode = new PropertyDescriptor("previewMode", beanClass);
  133.         previewMode.setBound(true);
  134.         previewMode.setConstrained(false);
  135.         previewMode.setDisplayName(prop.getString("previewMode"));
  136.  
  137.         PropertyDescriptor[] rv = {
  138.             previewMode};
  139.         return rv;
  140.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  141.     }
  142.  
  143.     private final static Class beanClass = Plasma.class;
  144.  
  145.     }    //  end of class PlasmaBeanInfo