home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 4.8 KB | 169 lines |
- /*
- * @(#JdbcConnectionBeanInfo.java
- *
- * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
- *
- */
-
- package symantec.itools.db.beans.jdbc;
-
- import java.beans.*;
- import symantec.itools.beans.*;
-
-
- /**
- * BeanInfo for JdbcConnection
- *
- */
-
- public class JdbcConnectionBeanInfo extends SimpleBeanInfo {
-
- public BeanInfo[] getAdditionalBeanInfo() {
- try {
- java.util.Vector v = new java.util.Vector();
- BeanInfo[] rv;
- BeanInfo b;
- Class c = beanClass.getSuperclass();
-
- while (c.isAssignableFrom(Object.class) != true) {
- b = Introspector.getBeanInfo(c);
- v.addElement(b);
- c = c.getSuperclass();
- }
- rv = new BeanInfo[v.size()];
- v.copyInto(rv);
-
- return rv;
- }
- catch (IntrospectionException e) { throw new Error(e.toString());}
- }
-
- public BeanDescriptor getBeanDescriptor() {
- SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
- bd.setFolder("JDBC");
- bd.setToolbar("JDBC");
- bd.setValue("VPO_Object", new Boolean(true));
- bd.setWinHelp("0x123CF");
-
- return (BeanDescriptor) bd;
- }
-
- public java.awt.Image getIcon(int iconKind) {
- if (iconKind == BeanInfo.ICON_MONO_16x16 ||
- iconKind == BeanInfo.ICON_COLOR_16x16) {
- java.awt.Image img = loadImage("JDBCConnectionIconColor16.gif");
- return img;
- }
-
- if (iconKind == BeanInfo.ICON_MONO_32x32 ||
- iconKind == BeanInfo.ICON_COLOR_32x32) {
- java.awt.Image img = loadImage("JDBCConnectionIconColor32.gif");
- return img;
- }
-
- return null;
- }
-
- public EventSetDescriptor[] getEventSetDescriptors()
- {
- EventSetDescriptor event;
- try {
- event = new EventSetDescriptor(beanClass, "connectFailed",
- ConnectFailedListener.class, "connectFailed");
- } catch (IntrospectionException e) {
- throw new Error(e.toString());
- }
- EventSetDescriptor[] events = {event};
- return events;
- }
-
- public MethodDescriptor[] getMethodDescriptors() {
- Class[] args;
- ConnectionDescriptor connection;
- java.util.Vector connections;
- java.util.Vector md = new java.util.Vector();
-
- try{
- args = null;
- MethodDescriptor connect = new MethodDescriptor(beanClass.getMethod("connect", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.connect();",
- "Connect");
- connections.addElement(connection);
-
- connect.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(connect);
- } catch (Exception e) { throw new Error("connect:: " + e.toString()); }
-
- MethodDescriptor[] rv = new MethodDescriptor[md.size()];
- md.copyInto(rv);
-
- return rv;
- }
-
- public PropertyDescriptor[] getPropertyDescriptors() {
- try{
- PropertyDescriptor pd1 = new PropertyDescriptor("connectFailedListener", beanClass);
- pd1.setBound(false);
- pd1.setConstrained(false);
- pd1.setDisplayName("Connect Failed Listener");
-
- PropertyDescriptor autoStart = new PropertyDescriptor("autoStart", beanClass);
- autoStart.setBound(false);
- autoStart.setConstrained(false);
- autoStart.setDisplayName("autoStart");
- autoStart.setHidden(true);
-
- PropertyDescriptor description = new PropertyDescriptor("description", beanClass);
- description.setBound(false);
- description.setConstrained(false);
- description.setDisplayName("description");
- description.setHidden(true);
-
- PropertyDescriptor debug = new PropertyDescriptor("debug", beanClass);
- debug.setBound(false);
- debug.setConstrained(false);
- debug.setDisplayName("debug");
- debug.setHidden(true);
-
- PropertyDescriptor pd2 = new PropertyDescriptor("transactionIsolation", beanClass);
- pd2.setBound(false);
- pd2.setConstrained(false);
-
- String levels = "TRANSACTION_NONE=0, ";
- levels += "TRANSACTION_READ_UNCOMMITTED=1, ";
- levels += "TRANSACTION_READ_COMMITTED=2, ";
- levels += "TRANSACTION_REPEATABLE_READ=4, ";
- levels += "TRANSACTION_SERIALIZABLE=8, ";
- levels += "TRANSACTION_DEFAULT=16";
-
- pd2.setValue("ENUMERATION", levels);
- pd2.setDisplayName("Transaction Isolation Level");
- pd2.setHidden(true);
-
- PropertyDescriptor pd3 = new PropertyDescriptor("catalog", beanClass);
- pd3.setBound(false);
- pd3.setConstrained(false);
- pd3.setDisplayName("catalog");
-
- PropertyDescriptor pd4 = new PropertyDescriptor("autoCommit", beanClass);
- pd4.setBound(false);
- pd4.setConstrained(false);
- pd4.setDisplayName("Auto Commit");
- pd4.setHidden(true);
-
- PropertyDescriptor[] rv = {pd1, autoStart, description, debug, pd2, pd3, pd4};
-
- return rv;
- } catch (IntrospectionException e) { throw new Error(e.toString()); }
- }
-
- public int getDefaultPropertyIndex() {
- return 0; // the index for our default property is always 0
- }
-
- private final static Class beanClass = JdbcConnection.class;
-
- } // end of class ConnectionBeanInfo