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 / JdbcConnectionBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  4.8 KB  |  169 lines

  1. /*
  2.  * @(#JdbcConnectionBeanInfo.java
  3.  *
  4.  * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
  5.  *
  6.  */
  7.  
  8. package symantec.itools.db.beans.jdbc;
  9.  
  10. import java.beans.*;
  11. import symantec.itools.beans.*;
  12.  
  13.  
  14. /**
  15.  * BeanInfo for JdbcConnection
  16.  *
  17.  */
  18.  
  19. public class JdbcConnectionBeanInfo extends SimpleBeanInfo {
  20.  
  21.     public BeanInfo[] getAdditionalBeanInfo() {
  22.         try {
  23.             java.util.Vector v = new java.util.Vector();
  24.             BeanInfo[] rv;
  25.             BeanInfo b;
  26.             Class c = beanClass.getSuperclass();
  27.  
  28.             while (c.isAssignableFrom(Object.class) != true) {
  29.                 b = Introspector.getBeanInfo(c);
  30.                 v.addElement(b);
  31.                 c = c.getSuperclass();
  32.             }
  33.             rv = new BeanInfo[v.size()];
  34.             v.copyInto(rv);
  35.  
  36.             return rv;
  37.         }
  38.         catch (IntrospectionException e) { throw new Error(e.toString());}
  39.     }
  40.  
  41.     public BeanDescriptor getBeanDescriptor() {
  42.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  43.         bd.setFolder("JDBC");
  44.         bd.setToolbar("JDBC");
  45.         bd.setValue("VPO_Object", new Boolean(true));
  46.         bd.setWinHelp("0x123CF");
  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("JDBCConnectionIconColor16.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("JDBCConnectionIconColor32.gif");
  61.             return img;
  62.         }
  63.  
  64.         return null;
  65.     }
  66.  
  67.     public EventSetDescriptor[] getEventSetDescriptors()
  68.     {
  69.         EventSetDescriptor event;
  70.         try {
  71.             event = new EventSetDescriptor(beanClass, "connectFailed",
  72.                 ConnectFailedListener.class, "connectFailed");
  73.         } catch (IntrospectionException e) {
  74.             throw new Error(e.toString());
  75.         }
  76.         EventSetDescriptor[] events = {event};
  77.         return events;
  78.     }
  79.  
  80.     public MethodDescriptor[] getMethodDescriptors() {
  81.         Class[] args;
  82.         ConnectionDescriptor connection;
  83.         java.util.Vector connections;
  84.         java.util.Vector md = new java.util.Vector();
  85.  
  86.         try{
  87.             args = null;
  88.             MethodDescriptor connect = new MethodDescriptor(beanClass.getMethod("connect", args));
  89.  
  90.             connections = new java.util.Vector();
  91.             connection = new ConnectionDescriptor("input", "void", "",
  92.                                     "%name%.connect();",
  93.                                     "Connect");
  94.             connections.addElement(connection);
  95.  
  96.             connect.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  97.             md.addElement(connect);
  98.         } catch (Exception e) { throw new Error("connect:: " + e.toString()); }
  99.  
  100.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  101.         md.copyInto(rv);
  102.  
  103.         return rv;
  104.     }
  105.  
  106.     public PropertyDescriptor[] getPropertyDescriptors() {
  107.         try{
  108.         PropertyDescriptor pd1 = new PropertyDescriptor("connectFailedListener", beanClass);
  109.         pd1.setBound(false);
  110.         pd1.setConstrained(false);
  111.         pd1.setDisplayName("Connect Failed Listener");
  112.  
  113.         PropertyDescriptor autoStart = new PropertyDescriptor("autoStart", beanClass);
  114.         autoStart.setBound(false);
  115.         autoStart.setConstrained(false);
  116.         autoStart.setDisplayName("autoStart");
  117.         autoStart.setHidden(true);
  118.  
  119.         PropertyDescriptor description = new PropertyDescriptor("description", beanClass);
  120.         description.setBound(false);
  121.         description.setConstrained(false);
  122.         description.setDisplayName("description");
  123.         description.setHidden(true);
  124.  
  125.         PropertyDescriptor debug = new PropertyDescriptor("debug", beanClass);
  126.         debug.setBound(false);
  127.         debug.setConstrained(false);
  128.         debug.setDisplayName("debug");
  129.         debug.setHidden(true);
  130.  
  131.         PropertyDescriptor pd2 = new PropertyDescriptor("transactionIsolation", beanClass);
  132.         pd2.setBound(false);
  133.         pd2.setConstrained(false);
  134.  
  135.         String levels = "TRANSACTION_NONE=0, ";
  136.         levels += "TRANSACTION_READ_UNCOMMITTED=1, ";
  137.         levels += "TRANSACTION_READ_COMMITTED=2, ";
  138.         levels += "TRANSACTION_REPEATABLE_READ=4, ";
  139.         levels += "TRANSACTION_SERIALIZABLE=8, ";
  140.         levels += "TRANSACTION_DEFAULT=16";
  141.  
  142.         pd2.setValue("ENUMERATION", levels);
  143.         pd2.setDisplayName("Transaction Isolation Level");
  144.         pd2.setHidden(true);
  145.  
  146.         PropertyDescriptor pd3 = new PropertyDescriptor("catalog", beanClass);
  147.         pd3.setBound(false);
  148.         pd3.setConstrained(false);
  149.         pd3.setDisplayName("catalog");
  150.  
  151.         PropertyDescriptor pd4 = new PropertyDescriptor("autoCommit", beanClass);
  152.         pd4.setBound(false);
  153.         pd4.setConstrained(false);
  154.         pd4.setDisplayName("Auto Commit");
  155.         pd4.setHidden(true);
  156.  
  157.         PropertyDescriptor[] rv = {pd1, autoStart, description, debug, pd2, pd3, pd4};
  158.  
  159.         return rv;
  160.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  161.     }
  162.  
  163.     public int getDefaultPropertyIndex() {
  164.         return 0;    //  the index for our default property is always 0
  165.     }
  166.  
  167.     private final static Class beanClass = JdbcConnection.class;
  168.  
  169. }    //  end of class ConnectionBeanInfo