home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / MediatorBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  4.5 KB  |  154 lines

  1. /*
  2.  * @(#MediatorBeanInfo.java
  3.  *
  4.  * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
  5.  *
  6.  */
  7.  
  8. package symantec.itools.db.beans.binding;
  9.  
  10. import java.beans.*;
  11. import symantec.itools.beans.*;
  12. import java.util.ResourceBundle;
  13.  
  14.  
  15. /**
  16.  * BeanInfo for Mediator
  17.  *
  18.  */
  19.  
  20. public class MediatorBeanInfo extends SimpleBeanInfo {
  21.  
  22.     public BeanInfo[] getAdditionalBeanInfo() {
  23.         try {
  24.             java.util.Vector v = new java.util.Vector();
  25.             BeanInfo[] rv;
  26.             BeanInfo b;
  27.             Class c = beanClass.getSuperclass();
  28.  
  29.             while (c.isAssignableFrom(Object.class) != true) {
  30.                 b = Introspector.getBeanInfo(c);
  31.                 v.addElement(b);
  32.                 c = c.getSuperclass();
  33.             }
  34.             rv = new BeanInfo[v.size()];
  35.             v.copyInto(rv);
  36.  
  37.             return rv;
  38.         }
  39.         catch (IntrospectionException e) { throw new Error(e.toString());}
  40.     }
  41.  
  42.     public BeanDescriptor getBeanDescriptor() {
  43.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  44.         bd.setFolder("JDBC");
  45.         bd.setToolbar("JDBC");
  46.         bd.setWinHelp("0x123CD");
  47.  
  48.         return (BeanDescriptor) bd;
  49.     }
  50.  
  51.     public java.awt.Image getIcon(int iconKind) {
  52.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  53.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  54.             java.awt.Image img = loadImage("MediatorIconColor16.gif");
  55.             return img;
  56.         }
  57.  
  58.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  59.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  60.             java.awt.Image img = loadImage("MediatorIconColor32.gif");
  61.             return img;
  62.         }
  63.  
  64.         return null;
  65.     }
  66.  
  67.     public MethodDescriptor[] getMethodDescriptors() {
  68.         Class[] args;
  69.         ConnectionDescriptor connection;
  70.         java.util.Vector connections;
  71.         java.util.Vector md = new java.util.Vector();
  72.  
  73.  
  74.         try{
  75.             args = null;
  76.             MethodDescriptor commit = new MethodDescriptor(beanClass.getMethod("commit", args));
  77.  
  78.             connections = new java.util.Vector();
  79.             connection = new ConnectionDescriptor("input", "void", "",
  80.                                     "%name%.commit();",
  81.                                     "Commit Data Changes");
  82.             connections.addElement(connection);
  83.  
  84.             commit.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  85.             md.addElement(commit);
  86.         } catch (Exception e) { throw new Error("commit:: " + e.toString()); }
  87.  
  88.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  89.         md.copyInto(rv);
  90.  
  91.         return rv;
  92.     }
  93.  
  94.     public PropertyDescriptor[] getPropertyDescriptors() {
  95.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.db.resources.PropBundle");
  96.  
  97.         try{
  98.         PropertyDescriptor output = new PropertyDescriptor("output", beanClass);
  99.         output.setBound(false);
  100.         output.setConstrained(false);
  101.         output.setDisplayName("Output");
  102.         output.setPropertyEditorClass(OutputEditor.class);
  103.  
  104.         PropertyDescriptor setMethods = new PropertyDescriptor("setMethods", beanClass);
  105.         setMethods.setBound(true);
  106.         setMethods.setConstrained(true);
  107.         setMethods.setDisplayName("Setter Methods");
  108.  
  109.         PropertyDescriptor getMethods = new PropertyDescriptor("getMethods", beanClass);
  110.         getMethods.setBound(true);
  111.         getMethods.setConstrained(true);
  112.         getMethods.setDisplayName("Getter Methods");
  113.  
  114.         PropertyDescriptor dataBinding = new PropertyDescriptor("dataBinding", beanClass);
  115.         dataBinding.setBound(false);
  116.         dataBinding.setConstrained(false);
  117.         dataBinding.setDisplayName("Data Binding");
  118.         dataBinding.setPropertyEditorClass(NameEditorMultiRow.class);
  119.  
  120.         /*PropertyDescriptor booleanTrueValue = new PropertyDescriptor("booleanTrueValue", beanClass);
  121.         booleanTrueValue.setBound(true);
  122.         booleanTrueValue.setConstrained(true);
  123.         booleanTrueValue.setDisplayName("Boolean True Value ");
  124.  
  125.         PropertyDescriptor booleanFalseValue = new PropertyDescriptor("booleanFalseValue", beanClass);
  126.         booleanFalseValue.setBound(true);
  127.         booleanFalseValue.setConstrained(true);
  128.         booleanFalseValue.setDisplayName("Boolean False Value ");*/
  129.  
  130.         PropertyDescriptor emptyMeansNull = new PropertyDescriptor("emptyMeansNull", beanClass);
  131.         emptyMeansNull.setBound(false);
  132.         emptyMeansNull.setConstrained(false);
  133.         emptyMeansNull.setDisplayName(prop.getString("emptyMeansNull"));
  134.  
  135.         PropertyDescriptor[] rv = {
  136.             output,
  137.             dataBinding,
  138.             setMethods,
  139.             getMethods,
  140.             //booleanTrueValue,
  141.             //booleanFalseValue,
  142.             emptyMeansNull  };
  143.  
  144.         return rv;
  145.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  146.     }
  147.  
  148.     public int getDefaultPropertyIndex() {
  149.         return 0;    //  the index for our default property is always 0
  150.     }
  151.  
  152.     private final static Class beanClass = Mediator.class;
  153.  
  154. }    //  end of class MediatorBeanInfo