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

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