home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1999 February / CDW0299.iso / Demos / Cafe / Source.bin / InvisibleHTMLLinkBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  7.2 KB  |  219 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 InvisibleHTMLLink.
  11.  *
  12.  */
  13. public class InvisibleHTMLLinkBeanInfo extends SimpleBeanInfo {
  14.  
  15.     /**
  16.      * Constructs a InvisibleHTMLLinkBeanInfo object.
  17.      */
  18.     public InvisibleHTMLLinkBeanInfo() {
  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.setWinHelp("0x12392");
  45.         bd.setFolder(s);
  46.         bd.setToolbar(s);
  47.  
  48.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  49.         s=conn.getString("currentFrame"); 
  50.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "String", "",
  51.                                                 "\"_self\"",s));
  52.  
  53.         s=conn.getString("parentFrame"); 
  54.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "String", "",
  55.                                                 "\"_parent\"",s));
  56.  
  57.         s=conn.getString("topmostFrame"); 
  58.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "String", "",
  59.                                                 "\"_top\"",s));
  60.  
  61.         s=conn.getString("unnamedFrame"); 
  62.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "String", "",
  63.                                                 "\"_blank\"",s));
  64.  
  65.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  66.  
  67.         return (BeanDescriptor) bd;
  68.     }
  69.  
  70.     /**
  71.      * Gets an image that may be used to visually represent this bean
  72.      * (in the toolbar, on a form, etc).
  73.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  74.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  75.      * @return an image for this bean, always color even if requested monochrome
  76.      * @see BeanInfo#ICON_MONO_16x16
  77.      * @see BeanInfo#ICON_COLOR_16x16
  78.      * @see BeanInfo#ICON_MONO_32x32
  79.      * @see BeanInfo#ICON_COLOR_32x32
  80.      */
  81.     public java.awt.Image getIcon(int iconKind) {
  82.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  83.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  84.             java.awt.Image img = loadImage("InvisibleHTMLLinkC16.gif");
  85.             return img;
  86.         }
  87.  
  88.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  89.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  90.             java.awt.Image img = loadImage("InvisibleHTMLLinkC32.gif");
  91.             return img;
  92.         }
  93.  
  94.         return null;
  95.     }
  96.  
  97.     /**
  98.      * Gets an array of descriptions of the methods used for "connections" by
  99.      * Visual CafΘ's Interaction Wizard.
  100.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  101.      * @return method descriptions for this bean
  102.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  103.      */
  104.     public MethodDescriptor[] getMethodDescriptors() {
  105.         Class[] args;
  106.         ConnectionDescriptor connection;
  107.         java.util.Vector connections;
  108.         java.util.Vector md = new java.util.Vector();
  109.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  110.         String s;
  111.  
  112.         try{
  113.             args = null;
  114.             MethodDescriptor getURL = new MethodDescriptor(beanClass.getMethod("getURL", args));
  115.  
  116.             connections = new java.util.Vector();
  117.             s=conn.getString("getURL"); 
  118.             connection = new ConnectionDescriptor("output", "URL", "",
  119.                                     "%name%.getURL()",s);
  120.             connections.addElement(connection);
  121.  
  122.             getURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  123.             md.addElement(getURL);
  124.         } catch (Exception e) { throw new Error("getURL:: " + e.toString()); }
  125.  
  126.         try{
  127.             args = new Class[1];
  128.             args[0] = java.net.URL.class ;
  129.             MethodDescriptor setURL = new MethodDescriptor(beanClass.getMethod("setURL", args));
  130.  
  131.             connections = new java.util.Vector();
  132.             s=conn.getString("setURLRelative"); 
  133.             connection = new ConnectionDescriptor("input", "RelativeURL", "",
  134.                                     "%name%.setURL(symantec.itools.net.RelativeURL.getURL(%arg%));",s);
  135.             connections.addElement(connection);
  136.  
  137.             s=conn.getString("setURL"); 
  138.             connection = new ConnectionDescriptor("input", "URL", "",
  139.                                     "%name%.setURL(%arg%);",s);
  140.             connections.addElement(connection);
  141.  
  142.             setURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  143.             md.addElement(setURL);
  144.         } catch (Exception e) { throw new Error("setURL:: " + e.toString()); }
  145.  
  146.         try{
  147.             args = new Class[1];
  148.             args[0] = java.lang.String.class ;
  149.             MethodDescriptor setFrame = new MethodDescriptor(beanClass.getMethod("setFrame", args));
  150.  
  151.             connections = new java.util.Vector();
  152.             s=conn.getString("setFrame"); 
  153.             connection = new ConnectionDescriptor("input", "String", "",
  154.                                     "%name%.setFrame(%arg%);",s);
  155.             connections.addElement(connection);
  156.  
  157.             setFrame.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  158.             md.addElement(setFrame);
  159.         } catch (Exception e) { throw new Error("setFrame:: " + e.toString()); }
  160.  
  161.         try{
  162.             args = null;
  163.             MethodDescriptor getFrame = new MethodDescriptor(beanClass.getMethod("getFrame", args));
  164.  
  165.             connections = new java.util.Vector();
  166.             s=conn.getString("getFrame"); 
  167.             connection = new ConnectionDescriptor("output", "String", "",
  168.                                     "%name%.getFrame()",s);
  169.             connections.addElement(connection);
  170.  
  171.             getFrame.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  172.             md.addElement(getFrame);
  173.         } catch (Exception e) { throw new Error("getFrame:: " + e.toString()); }
  174.  
  175.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  176.         md.copyInto(rv);
  177.  
  178.         return rv;
  179.     }
  180.  
  181.     /**
  182.      * Returns descriptions of this bean's properties.
  183.      */
  184.     public PropertyDescriptor[] getPropertyDescriptors() {
  185.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  186.         String s;
  187.  
  188.         try{
  189.         PropertyDescriptor defProperty = new PropertyDescriptor("uRL", beanClass);
  190.         defProperty.setBound(true);
  191.         defProperty.setConstrained(true);
  192.         s=prop.getString("linkURL"); 
  193.         defProperty.setDisplayName(s);
  194.         s=prop.getString("htmlURLFILTER"); 
  195.         defProperty.setValue("URLFILTER", s);
  196.  
  197.         PropertyDescriptor frame = new PropertyDescriptor("frame", beanClass);
  198.         frame.setBound(true);
  199.         frame.setConstrained(true);
  200.         s=prop.getString("frame"); 
  201.         frame.setDisplayName(s);
  202.  
  203.         PropertyDescriptor[] rv = {
  204.             defProperty,
  205.             frame};
  206.         return rv;
  207.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  208.     }
  209.  
  210.     /**
  211.      * Returns the index of the property expected to be changed most often by the designer.
  212.      */
  213.     public int getDefaultPropertyIndex() {
  214.         return 0;    //  the index for our default property is always 0
  215.     }
  216.  
  217.     private final static Class beanClass = InvisibleHTMLLink.class;
  218.  
  219.     }    //  end of class InvisibleHTMLLinkBeanInfo