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

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. /**
  8.  * BeanInfo for StatusBar.
  9.  *
  10.  */
  11.  
  12. public class StatusBarBeanInfo extends SimpleBeanInfo {
  13.  
  14.     /**
  15.      * Constructs a StatusBarBeanInfo object.
  16.      */
  17.     public StatusBarBeanInfo() {
  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("GroupAdditional"); 
  41.  
  42.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  43.         bd.setCanAddChild(false);
  44.         bd.setWinHelp("0x12390");
  45.         bd.setFolder(s);
  46.         bd.setToolbar(s);
  47.  
  48.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  49.  
  50.         return (BeanDescriptor) bd;
  51.     }
  52.  
  53.     /**
  54.      * Gets an image that may be used to visually represent this bean
  55.      * (in the toolbar, on a form, etc).
  56.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  57.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  58.      * @return an image for this bean, always color even if requested monochrome
  59.      * @see BeanInfo#ICON_MONO_16x16
  60.      * @see BeanInfo#ICON_COLOR_16x16
  61.      * @see BeanInfo#ICON_MONO_32x32
  62.      * @see BeanInfo#ICON_COLOR_32x32
  63.      */
  64.     public java.awt.Image getIcon(int iconKind) {
  65.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  66.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  67.             java.awt.Image img = loadImage("StatusBarC16.gif");
  68.             return img;
  69.         }
  70.  
  71.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  72.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  73.             java.awt.Image img = loadImage("StatusBarC32.gif");
  74.             return img;
  75.         }
  76.  
  77.         return null;
  78.     }
  79.  
  80.     /**
  81.      * Gets an array of descriptions of the methods used for "connections" by
  82.      * Visual CafΘ's Interaction Wizard.
  83.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  84.      * @return method descriptions for this bean
  85.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  86.      */
  87.     public MethodDescriptor[] getMethodDescriptors() {
  88.         Class[] args;
  89.         ConnectionDescriptor connection;
  90.         java.util.Vector connections;
  91.         java.util.Vector md = new java.util.Vector();
  92.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  93.  
  94.         try{
  95.             args = null;
  96.             MethodDescriptor getStatusTextColor = new MethodDescriptor(beanClass.getMethod("getStatusTextColor", args));
  97.  
  98.             connections = new java.util.Vector();
  99.             connection = new ConnectionDescriptor("output", "Color", "",
  100.                                     "%name%.getStatusTextColor();",
  101.                                     conn.getString("getStatusTextColor"));
  102.             connections.addElement(connection);
  103.  
  104.             getStatusTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  105.             md.addElement(getStatusTextColor);
  106.         } catch (Exception e) { throw new Error("getStatusTextColor:: " + e.toString()); }
  107.  
  108.         try{
  109.             args = new Class[1];
  110.             args[0] = java.lang.String.class ;
  111.             MethodDescriptor setStatusText = new MethodDescriptor(beanClass.getMethod("setStatusText", args));
  112.  
  113.             connections = new java.util.Vector();
  114.             connection = new ConnectionDescriptor("input", "String", "",
  115.                                     "%name%.setStatusText(%arg%);",
  116.                                     conn.getString("setStatusText"));
  117.             connections.addElement(connection);
  118.  
  119.             setStatusText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  120.             md.addElement(setStatusText);
  121.         } catch (Exception e) { throw new Error("setStatusText:: " + e.toString()); }
  122.  
  123.         try{
  124.             args = null;
  125.             MethodDescriptor getStatusText = new MethodDescriptor(beanClass.getMethod("getStatusText", args));
  126.  
  127.             connections = new java.util.Vector();
  128.             connection = new ConnectionDescriptor("output", "String", "",
  129.                                     "%name%.getStatusText()",
  130.                                     conn.getString("getStatusText"));
  131.             connections.addElement(connection);
  132.  
  133.             getStatusText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  134.             md.addElement(getStatusText);
  135.         } catch (Exception e) { throw new Error("getStatusText:: " + e.toString()); }
  136.  
  137.         try{
  138.             args = new Class[1];
  139.             args[0] = java.awt.Color.class ;
  140.             MethodDescriptor setStatusTextColor = new MethodDescriptor(beanClass.getMethod("setStatusTextColor", args));
  141.  
  142.             connections = new java.util.Vector();
  143.             connection = new ConnectionDescriptor("input", "Color", "",
  144.                                     "%name%.setStatusTextColor(%arg%);",
  145.                                     conn.getString("setStatusTextColor"));
  146.             connections.addElement(connection);
  147.  
  148.             setStatusTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  149.             md.addElement(setStatusTextColor);
  150.         } catch (Exception e) { throw new Error("setStatusTextColor:: " + e.toString()); }
  151.  
  152.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  153.         md.copyInto(rv);
  154.  
  155.         return rv;
  156.     }
  157.  
  158.     /**
  159.      * Returns descriptions of this bean's properties.
  160.      */
  161.     public PropertyDescriptor[] getPropertyDescriptors() {
  162.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  163.  
  164.         try{
  165.         PropertyDescriptor defProperty = new PropertyDescriptor("statusText", beanClass);
  166.         defProperty.setBound(true);
  167.         defProperty.setConstrained(true);
  168.         defProperty.setDisplayName(prop.getString("statusText"));
  169.  
  170.         PropertyDescriptor statusTextColor = new PropertyDescriptor("statusTextColor", beanClass);
  171.         statusTextColor.setBound(true);
  172.         statusTextColor.setConstrained(true);
  173.         statusTextColor.setDisplayName(prop.getString("statusTextColor"));
  174.  
  175.         PropertyDescriptor paddingTop = new PropertyDescriptor("paddingTop", beanClass);
  176.         paddingTop.setBound(true);
  177.         paddingTop.setConstrained(true);
  178.         paddingTop.setDisplayName(prop.getString("paddingTop"));
  179.  
  180.         PropertyDescriptor paddingBottom = new PropertyDescriptor("paddingBottom", beanClass);
  181.         paddingBottom.setBound(true);
  182.         paddingBottom.setConstrained(true);
  183.         paddingBottom.setDisplayName(prop.getString("paddingBottom"));
  184.  
  185.         PropertyDescriptor paddingLeft = new PropertyDescriptor("paddingLeft", beanClass);
  186.         paddingLeft.setBound(true);
  187.         paddingLeft.setConstrained(true);
  188.         paddingLeft.setDisplayName(prop.getString("paddingLeft"));
  189.  
  190.         PropertyDescriptor paddingRight = new PropertyDescriptor("paddingRight", beanClass);
  191.         paddingRight.setBound(true);
  192.         paddingRight.setConstrained(true);
  193.         paddingRight.setDisplayName(prop.getString("paddingRight"));
  194.  
  195.         PropertyDescriptor iPadTop = new PropertyDescriptor("iPadTop", beanClass);
  196.         iPadTop.setBound(true);
  197.         iPadTop.setConstrained(true);
  198.         iPadTop.setDisplayName(prop.getString("iPadTop"));
  199.  
  200.         PropertyDescriptor iPadBottom = new PropertyDescriptor("iPadBottom", beanClass);
  201.         iPadBottom.setBound(true);
  202.         iPadBottom.setConstrained(true);
  203.         iPadBottom.setDisplayName(prop.getString("iPadBottom"));
  204.  
  205.         PropertyDescriptor iPadSides = new PropertyDescriptor("iPadSides", beanClass);
  206.         iPadSides.setBound(true);
  207.         iPadSides.setConstrained(true);
  208.         iPadSides.setDisplayName(prop.getString("iPadSides"));
  209.  
  210.         PropertyDescriptor borderColor = new PropertyDescriptor("borderColor", beanClass);
  211.         borderColor.setBound(true);
  212.         borderColor.setConstrained(true);
  213.         borderColor.setDisplayName(prop.getString("borderColor"));
  214.  
  215.         PropertyDescriptor bevelStyle = new PropertyDescriptor("bevelStyle", beanClass);
  216.         bevelStyle.setBound(true);
  217.         bevelStyle.setConstrained(true);
  218.         bevelStyle.setDisplayName(prop.getString("bevelStyle"));
  219.         bevelStyle.setValue("ENUMERATION", "BEVEL_LOWERED=0, BEVEL_RAISED=1, BEVEL_LINE=2, BEVEL_NONE=3");
  220.  
  221.         PropertyDescriptor[] rv = {
  222.             defProperty,
  223.             statusTextColor,
  224.             paddingTop,
  225.             paddingBottom,
  226.             paddingLeft,
  227.             paddingRight,
  228.             iPadTop,
  229.             iPadBottom,
  230.             iPadSides,
  231.             borderColor,
  232.             bevelStyle};
  233.         return rv;
  234.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  235.     }
  236.  
  237.     /**
  238.      * Returns the index of the property expected to be changed most often by the designer.
  239.      */
  240.     public int getDefaultPropertyIndex() {
  241.         return 0;    //  the index for our default property is always 0
  242.     }
  243.  
  244.     private final static Class beanClass = StatusBar.class;
  245.  
  246.     }    //  end of class StatusBarBeanInfo