home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / Source.bin / ImageViewerBeanInfo.java < prev    next >
Text File  |  1998-03-18  |  9KB  |  254 lines

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