home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1999 February / CDW0299.iso / Demos / Cafe / Source.bin / TabPanelBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  5.5 KB  |  171 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 TabPanel.
  9.  *
  10.  */
  11.  
  12. public class TabPanelBeanInfo extends SimpleBeanInfo {
  13.  
  14.     /**
  15.      * Constructs a TabPanelBeanInfo object.
  16.      */
  17.     public TabPanelBeanInfo() {
  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("GroupPanel"); 
  41.  
  42.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  43.         bd.setFolder(s);
  44.         bd.setToolbar(s);
  45.         bd.setWinHelp("0x123B2");
  46.  
  47.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  48.  
  49.         return (BeanDescriptor) bd;
  50.     }
  51.  
  52.     /**
  53.      * Gets an image that may be used to visually represent this bean
  54.      * (in the toolbar, on a form, etc).
  55.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  56.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  57.      * @return an image for this bean, always color even if requested monochrome
  58.      * @see BeanInfo#ICON_MONO_16x16
  59.      * @see BeanInfo#ICON_COLOR_16x16
  60.      * @see BeanInfo#ICON_MONO_32x32
  61.      * @see BeanInfo#ICON_COLOR_32x32
  62.      */
  63.     public java.awt.Image getIcon(int iconKind) {
  64.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  65.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  66.             java.awt.Image img = loadImage("TabPanelC16.gif");
  67.             return img;
  68.         }
  69.  
  70.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  71.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  72.             java.awt.Image img = loadImage("TabPanelC32.gif");
  73.             return img;
  74.         }
  75.  
  76.         return null;
  77.     }
  78.  
  79.     /**
  80.      * Gets an array of descriptions of the methods used for "connections" by
  81.      * Visual CafΘ's Interaction Wizard.
  82.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  83.      * @return method descriptions for this bean
  84.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  85.      */
  86.     public MethodDescriptor[] getMethodDescriptors() {
  87.         Class[] args;
  88.         ConnectionDescriptor connection;
  89.         java.util.Vector connections;
  90.         java.util.Vector md = new java.util.Vector();
  91.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  92.  
  93.         try{
  94.             args = new Class[1];
  95.             args[0] = java.lang.Integer.TYPE ;
  96.             MethodDescriptor setCurrentPanelNdx = new MethodDescriptor(beanClass.getMethod("setCurrentPanelNdx", args));
  97.  
  98.             connections = new java.util.Vector();
  99.             connection = new ConnectionDescriptor("input", "int", "",
  100.                                     "%name%.setCurrentPanelNdx(%arg%);",
  101.                                     conn.getString("setCurrentPanelNdx"));
  102.             connections.addElement(connection);
  103.  
  104.             setCurrentPanelNdx.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  105.             md.addElement(setCurrentPanelNdx);
  106.         } catch (Exception e) { throw new Error("setCurrentPanelNdx:: " + e.toString()); }
  107.  
  108.         try{
  109.             args = null;
  110.             MethodDescriptor getCurrentPanelNdx = new MethodDescriptor(beanClass.getMethod("getCurrentPanelNdx", args));
  111.  
  112.             connections = new java.util.Vector();
  113.             connection = new ConnectionDescriptor("output", "int", "",
  114.                                     "%name%.getCurrentPanelNdx()",
  115.                                     conn.getString("getCurrentPanelNdx"));
  116.             connections.addElement(connection);
  117.  
  118.             getCurrentPanelNdx.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  119.             md.addElement(getCurrentPanelNdx);
  120.         } catch (Exception e) { throw new Error("getCurrentPanelNdx:: " + e.toString()); }
  121.  
  122.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  123.         md.copyInto(rv);
  124.  
  125.         return rv;
  126.     }
  127.  
  128.     /**
  129.      * Returns descriptions of this bean's properties.
  130.      */
  131.     public PropertyDescriptor[] getPropertyDescriptors() {
  132.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  133.  
  134.         try{
  135.         PropertyDescriptor defProperty = new PropertyDescriptor("currentPanelNdx", beanClass);
  136.         defProperty.setBound(true);
  137.         defProperty.setConstrained(true);
  138.         defProperty.setDisplayName(prop.getString("currentPanelNdx"));
  139.  
  140.         PropertyDescriptor panelLabels = new PropertyDescriptor("panelLabels", beanClass);
  141.         panelLabels.setBound(true);
  142.         panelLabels.setConstrained(true);
  143.         panelLabels.setDisplayName(prop.getString("panelLabels"));
  144.  
  145.         PropertyDescriptor tabsOnBottom = new PropertyDescriptor("tabsOnBottom", beanClass);
  146.         tabsOnBottom.setBound(true);
  147.         tabsOnBottom.setConstrained(true);
  148.         tabsOnBottom.setDisplayName(prop.getString("tabsOnBottom"));
  149.  
  150.         PropertyDescriptor layout = new PropertyDescriptor("layout", beanClass);
  151.         layout.setHidden(true);
  152.  
  153.         PropertyDescriptor[] rv = {
  154.             defProperty,
  155.             panelLabels,
  156.             tabsOnBottom,
  157.             layout};
  158.         return rv;
  159.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  160.     }
  161.  
  162.     /**
  163.      * Returns the index of the property expected to be changed most often by the designer.
  164.      */
  165.     public int getDefaultPropertyIndex() {
  166.         return 0;    //  the index for our default property is always 0
  167.     }
  168.  
  169.     private final static Class beanClass = TabPanel.class;
  170.  
  171.     }    //  end of class TabPanelBeanInfo