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

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/08/97    LAB    Moved from Additional to Panels.  Hid layout property.
  8. //    09/20/97    RKM Fixed getAdditionalBeanInfo override
  9.  
  10. /**
  11.  * BeanInfo for InfoTipPanel.
  12.  *
  13.  */
  14. public class InfoTipPanelBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a TextScrollingButtonBeanIn object.
  18.      */
  19.     public InfoTipPanelBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets an array of BeanInfo on the superclasses of this object.
  24.      * The superclasses returned are all assignable from class Object
  25.      * (see isAssignableFrom).
  26.      * @return BeanInfo on this class's superclasses
  27.      * @see java.lang.Class#isAssignableFrom
  28.      */
  29.     public BeanInfo[] getAdditionalBeanInfo() {
  30.         try {
  31.             BeanInfo[] bi = new BeanInfo[1];
  32.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  33.             return bi;
  34.         }
  35.         catch (IntrospectionException e) { throw new Error(e.toString());}
  36.     }
  37.     
  38.     /**
  39.      * Gets the SymantecBeanDescriptor for this bean.
  40.      * @return an object of type SymantecBeanDescriptor
  41.      * @see symantec.itools.beans.SymantecBeanDescriptor
  42.      */
  43.     public BeanDescriptor getBeanDescriptor() {
  44.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  45.         String s=group.getString("GroupPanel"); 
  46.  
  47.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  48.         bd.setFolder(s);
  49.         bd.setToolbar(s);
  50.  
  51.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  52.         s=conn.getString(""); 
  53.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  54.                                                 "%name%.RIGHT_OF_COMPONENT",
  55.                                                 "RIGHT_OF_COMPONENT"));
  56.  
  57.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  58.                                                 "%name%.LEFT_OF_COMPONENT",
  59.                                                 "LEFT_OF_COMPONENT"));
  60.  
  61.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  62.                                                 "%name%.ABOVE_COMPONENT",
  63.                                                 "ABOVE_COMPONENT"));
  64.  
  65.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  66.                                                 "%name%.BELOW_COMPONENT",
  67.                                                 "BELOW_COMPONENT"));
  68.  
  69.         return (BeanDescriptor) bd;
  70.     }
  71.  
  72.     /**
  73.      * Gets an image that may be used to visually represent this bean
  74.      * (in the toolbar, on a form, etc).
  75.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  76.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  77.      * @return an image for this bean, always color even if requested monochrome
  78.      * @see BeanInfo#ICON_MONO_16x16
  79.      * @see BeanInfo#ICON_COLOR_16x16
  80.      * @see BeanInfo#ICON_MONO_32x32
  81.      * @see BeanInfo#ICON_COLOR_32x32
  82.      */
  83.     public java.awt.Image getIcon(int iconKind) {
  84.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  85.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  86.             java.awt.Image img = loadImage("InfoTipPanelC16.gif");
  87.             return img;
  88.         }
  89.  
  90.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  91.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  92.             java.awt.Image img = loadImage("InfoTipPanelC32.gif");
  93.             return img;
  94.         }
  95.  
  96.         return null;
  97.     }
  98.  
  99.     /**
  100.      * Gets an array of descriptions of the methods used for "connections" by
  101.      * Visual CafΘ's Interaction Wizard.
  102.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  103.      * @return method descriptions for this bean
  104.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  105.      */
  106.     public MethodDescriptor[] getMethodDescriptors() {
  107.         Class[] args;
  108.         ConnectionDescriptor connection;
  109.         java.util.Vector connections;
  110.         java.util.Vector md = new java.util.Vector();
  111.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  112.  
  113.         try{
  114.             args = new Class[1];
  115.             args[0] = java.lang.String.class ;
  116.             MethodDescriptor setText = new MethodDescriptor(beanClass.getMethod("setText", args));
  117.  
  118.             connections = new java.util.Vector();
  119.             connection = new ConnectionDescriptor("input", "String", "",
  120.                                     "%name%.setText(%arg%);",
  121.                                     conn.getString("setText"));
  122.             connections.addElement(connection);
  123.  
  124.             setText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  125.             md.addElement(setText);
  126.         } catch (Exception e) { throw new Error("setText:: " + e.toString()); }
  127.  
  128.         try{
  129.             args = null;
  130.             MethodDescriptor getText = new MethodDescriptor(beanClass.getMethod("getText", args));
  131.  
  132.             connections = new java.util.Vector();
  133.             connection = new ConnectionDescriptor("output", "String", "",
  134.                                     "%name%.getText()",
  135.                                     conn.getString("getText"));
  136.             connections.addElement(connection);
  137.  
  138.             getText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  139.             md.addElement(getText);
  140.         } catch (Exception e) { throw new Error("getText:: " + e.toString()); }
  141.  
  142.         try{
  143.             args = new Class[1];
  144.             args[0] = java.lang.Integer.TYPE ;
  145.             MethodDescriptor setTextLocation = new MethodDescriptor(beanClass.getMethod("setTextLocation", args));
  146.  
  147.             connections = new java.util.Vector();
  148.             connection = new ConnectionDescriptor("input", "int", "",
  149.                                     "%name%.setTextLocation(%arg%);",
  150.                                     conn.getString("setTextLocation"));
  151.             connections.addElement(connection);
  152.  
  153.             setTextLocation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  154.             md.addElement(setTextLocation);
  155.         } catch (Exception e) { throw new Error("setTextLocation:: " + e.toString()); }
  156.  
  157.         try{
  158.             args = null;
  159.             MethodDescriptor getTextLocation = new MethodDescriptor(beanClass.getMethod("getTextLocation", args));
  160.  
  161.             connections = new java.util.Vector();
  162.             connection = new ConnectionDescriptor("output", "int", "",
  163.                                     "%name%.getTextLocation()",
  164.                                     conn.getString("getTextLocation"));
  165.             connections.addElement(connection);
  166.  
  167.             getTextLocation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  168.             md.addElement(getTextLocation);
  169.         } catch (Exception e) { throw new Error("getTextLocation:: " + e.toString()); }
  170.  
  171.         try{
  172.             args = new Class[1];
  173.             args[0] = java.lang.Integer.TYPE ;
  174.             MethodDescriptor setTextDelay = new MethodDescriptor(beanClass.getMethod("setTextDelay", args));
  175.  
  176.             connections = new java.util.Vector();
  177.             connection = new ConnectionDescriptor("input", "int", "",
  178.                                     "%name%.setTextDelay(%arg%);",
  179.                                     conn.getString("setTextDelay"));
  180.             connections.addElement(connection);
  181.  
  182.             setTextDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  183.             md.addElement(setTextDelay);
  184.         } catch (Exception e) { throw new Error("setTextDelay:: " + e.toString()); }
  185.  
  186.         try{
  187.             args = null;
  188.             MethodDescriptor getTextDelay = new MethodDescriptor(beanClass.getMethod("getTextDelay", args));
  189.  
  190.             connections = new java.util.Vector();
  191.             connection = new ConnectionDescriptor("output", "int", "",
  192.                                     "%name%.getTextDelay()",
  193.                                     conn.getString("getTextDelay"));
  194.             connections.addElement(connection);
  195.  
  196.             getTextDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  197.             md.addElement(getTextDelay);
  198.         } catch (Exception e) { throw new Error("getTextDelay:: " + e.toString()); }
  199.  
  200.         try{
  201.             args = null;
  202.             MethodDescriptor getTextScrollsIn = new MethodDescriptor(beanClass.getMethod("getTextScrollsIn", args));
  203.  
  204.             connections = new java.util.Vector();
  205.             connection = new ConnectionDescriptor("output", "boolean", "",
  206.                                     "%name%.getTextScrollsIn()",
  207.                                     conn.getString("getTextScrollsIn"));
  208.             connections.addElement(connection);
  209.  
  210.             getTextScrollsIn.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  211.             md.addElement(getTextScrollsIn);
  212.         } catch (Exception e) { throw new Error("getTextScrollsIn:: " + e.toString()); }
  213.  
  214.         try{
  215.             args = new Class[1];
  216.             args[0] = java.lang.Boolean.TYPE ;
  217.             MethodDescriptor setTextScrollsIn = new MethodDescriptor(beanClass.getMethod("setTextScrollsIn", args));
  218.  
  219.             connections = new java.util.Vector();
  220.             connection = new ConnectionDescriptor("input", "boolean", "",
  221.                                     "%name%.setTextScrollsIn(%arg%);",
  222.                                     conn.getString("setTextScrollsIn"));
  223.             connections.addElement(connection);
  224.  
  225.             setTextScrollsIn.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  226.             md.addElement(setTextScrollsIn);
  227.         } catch (Exception e) { throw new Error("setTextScrollsIn:: " + e.toString()); }
  228.  
  229.         try{
  230.             args = null;
  231.             MethodDescriptor getHighlightText = new MethodDescriptor(beanClass.getMethod("getHighlightText", args));
  232.  
  233.             connections = new java.util.Vector();
  234.             connection = new ConnectionDescriptor("output", "boolean", "",
  235.                                     "%name%.getHighlightText()",
  236.                                     conn.getString("getHighlightText"));
  237.             connections.addElement(connection);
  238.  
  239.             getHighlightText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  240.             md.addElement(getHighlightText);
  241.         } catch (Exception e) { throw new Error("getHighlightText:: " + e.toString()); }
  242.  
  243.         try{
  244.             args = new Class[1];
  245.             args[0] = java.lang.Boolean.TYPE ;
  246.             MethodDescriptor setHighlightText = new MethodDescriptor(beanClass.getMethod("setHighlightText", args));
  247.  
  248.             connections = new java.util.Vector();
  249.             connection = new ConnectionDescriptor("input", "boolean", "",
  250.                                     "%name%.setHighlightText(%arg%);",
  251.                                     conn.getString("setHighlightText"));
  252.             connections.addElement(connection);
  253.  
  254.             setHighlightText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  255.             md.addElement(setHighlightText);
  256.         } catch (Exception e) { throw new Error("setHighlightText:: " + e.toString()); }
  257.  
  258.         try{
  259.             args = null;
  260.             MethodDescriptor getTextHighlightColor = new MethodDescriptor(beanClass.getMethod("getTextHighlightColor", args));
  261.  
  262.             connections = new java.util.Vector();
  263.             connection = new ConnectionDescriptor("output", "Color", "",
  264.                                     "%name%.getTextHighlightColor()",
  265.                                     conn.getString("getTextHighlightColor"));
  266.             connections.addElement(connection);
  267.  
  268.             getTextHighlightColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  269.             md.addElement(getTextHighlightColor);
  270.         } catch (Exception e) { throw new Error("getTextHighlightColor:: " + e.toString()); }
  271.  
  272.         try{
  273.             args = new Class[1];
  274.             args[0] = java.awt.Color.class ;
  275.             MethodDescriptor setTextHighlightColor = new MethodDescriptor(beanClass.getMethod("setTextHighlightColor", args));
  276.  
  277.             connections = new java.util.Vector();
  278.             connection = new ConnectionDescriptor("input", "Color", "",
  279.                                     "%name%.setTextHighlightColor(%arg%);",
  280.                                     conn.getString("setTextHighlightColor"));
  281.             connections.addElement(connection);
  282.  
  283.             setTextHighlightColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  284.             md.addElement(setTextHighlightColor);
  285.         } catch (Exception e) { throw new Error("setTextHighlightColor:: " + e.toString()); }
  286.  
  287.         try{
  288.             args = null;
  289.             MethodDescriptor getTextColor = new MethodDescriptor(beanClass.getMethod("getTextColor", args));
  290.  
  291.             connections = new java.util.Vector();
  292.             connection = new ConnectionDescriptor("output", "Color", "",
  293.                                     "%name%.getTextColor()",
  294.                                     conn.getString("getTextColor"));
  295.             connections.addElement(connection);
  296.  
  297.             getTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  298.             md.addElement(getTextColor);
  299.         } catch (Exception e) { throw new Error("getTextColor:: " + e.toString()); }
  300.  
  301.         try{
  302.             args = new Class[1];
  303.             args[0] = java.awt.Color.class ;
  304.             MethodDescriptor setTextColor = new MethodDescriptor(beanClass.getMethod("setTextColor", args));
  305.  
  306.             connections = new java.util.Vector();
  307.             connection = new ConnectionDescriptor("input", "Color", "",
  308.                                     "%name%.setTextColor(%arg%);",
  309.                                     conn.getString("setTextColor"));
  310.             connections.addElement(connection);
  311.  
  312.             setTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  313.             md.addElement(setTextColor);
  314.         } catch (Exception e) { throw new Error("setTextColor:: " + e.toString()); }
  315.  
  316.  
  317.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  318.         md.copyInto(rv);
  319.  
  320.         return rv;
  321.     }
  322.  
  323.     /**
  324.      * Returns desecriptions of this bean's properties.
  325.      */
  326.     public PropertyDescriptor[] getPropertyDescriptors() {
  327.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  328.  
  329.         try{
  330.         PropertyDescriptor defProperty = new PropertyDescriptor("text", beanClass);
  331.         defProperty.setBound(true);
  332.         defProperty.setConstrained(true);
  333.         defProperty.setDisplayName(prop.getString("text"));
  334.  
  335.         PropertyDescriptor textLocation = new PropertyDescriptor("textLocation", beanClass);
  336.         textLocation.setBound(true);
  337.         textLocation.setConstrained(true);
  338.         textLocation.setDisplayName(prop.getString("textLocation"));
  339.         textLocation.setValue("ENUMERATION", "RIGHT_OF_COMPONENT=0, LEFT_OF_COMPONENT=1, ABOVE_COMPONENT=2, BELOW_COMPONENT=3");
  340.  
  341.         PropertyDescriptor textDelay = new PropertyDescriptor("textDelay", beanClass);
  342.         textDelay.setBound(true);
  343.         textDelay.setConstrained(true);
  344.         textDelay.setDisplayName(prop.getString("textDelay"));
  345.  
  346.         PropertyDescriptor textScrollsIn = new PropertyDescriptor("textScrollsIn", beanClass);
  347.         textScrollsIn.setBound(true);
  348.         textScrollsIn.setConstrained(true);
  349.         textScrollsIn.setDisplayName(prop.getString("textScrollsIn"));
  350.  
  351.         PropertyDescriptor highlightText = new PropertyDescriptor("highlightText", beanClass);
  352.         highlightText.setBound(true);
  353.         highlightText.setConstrained(true);
  354.         highlightText.setDisplayName(prop.getString("highlightText"));
  355.  
  356.         PropertyDescriptor textHighlightColor = new PropertyDescriptor("textHighlightColor", beanClass);
  357.         textHighlightColor.setBound(true);
  358.         textHighlightColor.setConstrained(true);
  359.         textHighlightColor.setDisplayName(prop.getString("textHighlightColor"));
  360.  
  361.         PropertyDescriptor textColor = new PropertyDescriptor("textColor", beanClass);
  362.         textColor.setBound(true);
  363.         textColor.setConstrained(true);
  364.         textColor.setDisplayName(prop.getString("textColor"));
  365.  
  366.         PropertyDescriptor layout = new PropertyDescriptor("layout", beanClass);
  367.         layout.setHidden(true);
  368.  
  369.         PropertyDescriptor[] rv = {
  370.             defProperty,
  371.             textLocation,
  372.             textDelay,
  373.             textScrollsIn,
  374.             highlightText,
  375.             textHighlightColor,
  376.             textColor,
  377.             layout
  378.         };
  379.  
  380.         return rv;
  381.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  382.     }
  383.  
  384.     /**
  385.      * Returns the index of the property expected to be changed most often by the designer.
  386.      */
  387.     public int getDefaultPropertyIndex() {
  388.         return 0;    //  the index for our default property is always 0
  389.     }
  390.  
  391.     private final static Class beanClass = InfoTipPanel.class;
  392.  
  393.     }    //  end of class InfoTipPanelBeanInfo