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

  1. package symantec.itools.awt.util;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  07/24/97    LAB    Added Orientation property and connections.
  8. //  09/19/97    RKM    Hid the layout bean.
  9.  
  10. /**
  11.  * BeanInfo for ToolBarPanel.
  12.  *
  13.  */
  14.  
  15. public class ToolBarPanelBeanInfo extends SimpleBeanInfo {
  16.  
  17.     /**
  18.      * Constructs a ToolBarPanelBeanInfo object.
  19.      */
  20.     public ToolBarPanelBeanInfo() {
  21.     }
  22.  
  23.     /**
  24.      * Gets a BeanInfo for the superclass of this bean.
  25.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  26.      */
  27.     public BeanInfo[] getAdditionalBeanInfo() {
  28.         try {
  29.             BeanInfo[] bi = new BeanInfo[1];
  30.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  31.             return bi;
  32.         }
  33.         catch (IntrospectionException e) { throw new Error(e.toString());}
  34.     }
  35.  
  36.     public java.awt.Image getIcon(int iconKind) {
  37.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  38.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  39.             java.awt.Image img = loadImage("ToolBarPanelC16.gif");
  40.             return img;
  41.         }
  42.  
  43.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  44.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  45.             java.awt.Image img = loadImage("ToolBarPanelC32.gif");
  46.             return img;
  47.         }
  48.  
  49.         return null;
  50.     }
  51.  
  52.     /**
  53.      * Gets the SymantecBeanDescriptor for this bean.
  54.      * @return an object of type SymantecBeanDescriptor
  55.      * @see symantec.itools.beans.SymantecBeanDescriptor
  56.      */
  57.     public BeanDescriptor getBeanDescriptor() {
  58.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  59.         String s=group.getString("GroupPanel"); 
  60.  
  61.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  62.         bd.setFolder(s);
  63.         bd.setToolbar(s);
  64.         bd.setWinHelp("0x123B6");
  65.  
  66.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  67.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  68.                                                 "%name%.HORIZONTAL",
  69.                                                 conn.getString("HORIZONTAL")));
  70.  
  71.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  72.                                                 "%name%.VERTICAL",
  73.                                                 conn.getString("VERTICAL")));
  74.  
  75.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  76.  
  77.         return (BeanDescriptor) bd;
  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 = new Class[1];
  96.             args[0] = java.lang.Integer.TYPE;
  97.             MethodDescriptor setOrientation = new MethodDescriptor(beanClass.getMethod("setOrientation", args));
  98.  
  99.             connections = new java.util.Vector();
  100.             connection = new ConnectionDescriptor("input", "int", "",
  101.                                     "%name%.setOrientation(%arg%);",
  102.                                     conn.getString("setOrientation"));
  103.             connections.addElement(connection);
  104.  
  105.             setOrientation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  106.             md.addElement(setOrientation);
  107.         } catch (Exception e) { throw new Error("setOrientation:: " + e.toString()); }
  108.  
  109.         try{
  110.             args = null;
  111.             MethodDescriptor getOrientation = new MethodDescriptor(beanClass.getMethod("getOrientation", args));
  112.  
  113.             connections = new java.util.Vector();
  114.             connection = new ConnectionDescriptor("output", "int", "",
  115.                                     "%name%.getOrientation()",
  116.                                     conn.getString("getOrientation"));
  117.             connections.addElement(connection);
  118.  
  119.             getOrientation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  120.             md.addElement(getOrientation);
  121.         } catch (Exception e) { throw new Error("getOrientation:: " + e.toString()); }
  122.  
  123.  
  124.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  125.         md.copyInto(rv);
  126.  
  127.         return rv;
  128.     }
  129.  
  130.     /**
  131.      * Returns descriptions of this bean's properties.
  132.      */
  133.     public PropertyDescriptor[] getPropertyDescriptors() {
  134.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  135.  
  136.         try{
  137.         PropertyDescriptor orientation = new PropertyDescriptor("orientation", beanClass);
  138.         orientation.setBound(true);
  139.         orientation.setConstrained(true);
  140.         orientation.setDisplayName(prop.getString("orientation"));
  141.         orientation.setValue("ENUMERATION", "HORIZONTAL=0, VERTICAL=1");
  142.  
  143.         PropertyDescriptor bevelStyle = new PropertyDescriptor("bevelStyle", beanClass);
  144.         bevelStyle.setBound(true);
  145.         bevelStyle.setConstrained(true);
  146.         bevelStyle.setDisplayName(prop.getString("bevelStyle"));
  147.         bevelStyle.setValue("ENUMERATION", "BEVEL_LOWERED=0, BEVEL_RAISED=1, BEVEL_LINE=2, BEVEL_NONE=3");
  148.  
  149.         PropertyDescriptor paddingTop = new PropertyDescriptor("paddingTop", beanClass);
  150.         paddingTop.setBound(true);
  151.         paddingTop.setConstrained(true);
  152.         paddingTop.setDisplayName(prop.getString("paddingTop"));
  153.  
  154.         PropertyDescriptor paddingBottom = new PropertyDescriptor("paddingBottom", beanClass);
  155.         paddingBottom.setBound(true);
  156.         paddingBottom.setConstrained(true);
  157.         paddingBottom.setDisplayName(prop.getString("paddingBottom"));
  158.  
  159.         PropertyDescriptor paddingLeft = new PropertyDescriptor("paddingLeft", beanClass);
  160.         paddingLeft.setBound(true);
  161.         paddingLeft.setConstrained(true);
  162.         paddingLeft.setDisplayName(prop.getString("paddingLeft"));
  163.  
  164.         PropertyDescriptor paddingRight = new PropertyDescriptor("paddingRight", beanClass);
  165.         paddingRight.setBound(true);
  166.         paddingRight.setConstrained(true);
  167.         paddingRight.setDisplayName(prop.getString("paddingRight"));
  168.  
  169.         PropertyDescriptor iPadTop = new PropertyDescriptor("iPadTop", beanClass);
  170.         iPadTop.setBound(true);
  171.         iPadTop.setConstrained(true);
  172.         iPadTop.setDisplayName(prop.getString("iPadTop"));
  173.  
  174.         PropertyDescriptor iPadBottom = new PropertyDescriptor("iPadBottom", beanClass);
  175.         iPadBottom.setBound(true);
  176.         iPadBottom.setConstrained(true);
  177.         iPadBottom.setDisplayName(prop.getString("iPadBottom"));
  178.  
  179.         PropertyDescriptor iPadSides = new PropertyDescriptor("iPadSides", beanClass);
  180.         iPadSides.setBound(true);
  181.         iPadSides.setConstrained(true);
  182.         iPadSides.setDisplayName(prop.getString("iPadSides"));
  183.         
  184.         PropertyDescriptor layout = new PropertyDescriptor("layout", beanClass);
  185.         layout.setHidden(true);
  186.  
  187.         PropertyDescriptor[] rv = {
  188.             orientation,
  189.             bevelStyle,
  190.             paddingTop,
  191.             paddingBottom,
  192.             paddingLeft,
  193.             paddingRight,
  194.             iPadTop,
  195.             iPadBottom,
  196.             iPadSides,
  197.             layout};
  198.         return rv;
  199.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  200.     }
  201.  
  202.     private final static Class beanClass = ToolBarPanel.class;
  203.  
  204.     }    //  end of class ToolBarPanelBeanInfo