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

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