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 / QueryNavigatorBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  9.4 KB  |  303 lines

  1. /*
  2.  * @(#QueryNavigatorBeanInfo.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.  
  13.  
  14. /**
  15.  * BeanInfo for QueryNavigator
  16.  *
  17.  */
  18.  
  19. public class QueryNavigatorBeanInfo 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.  
  47.         return (BeanDescriptor) bd;
  48.     }
  49.  
  50.     public java.awt.Image getIcon(int iconKind) {
  51.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  52.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  53.             java.awt.Image img = loadImage("DataSourceIconColor16.gif");
  54.             return img;
  55.         }
  56.  
  57.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  58.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  59.             java.awt.Image img = loadImage("DataSourceIconColor32.gif");
  60.             return img;
  61.         }
  62.  
  63.         return null;
  64.     }
  65.  
  66.     public MethodDescriptor[] getMethodDescriptors() {
  67.         Class[] args;
  68.         ConnectionDescriptor connection;
  69.         java.util.Vector connections;
  70.         java.util.Vector md = new java.util.Vector();
  71.  
  72.         try{
  73.             args = null;
  74.             MethodDescriptor next = new MethodDescriptor(beanClass.getMethod("next", args));
  75.  
  76.             connections = new java.util.Vector();
  77.             connection = new ConnectionDescriptor("input", "void", "",
  78.                                     "%name%.next();",
  79.                                     "next");
  80.             connections.addElement(connection);
  81.  
  82.             next.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  83.             md.addElement(next);
  84.         } catch (Exception e) { throw new Error("next:: " + e.toString()); }
  85.  
  86.         try{
  87.             args = null;
  88.             MethodDescriptor previous = new MethodDescriptor(beanClass.getMethod("previous", args));
  89.  
  90.             connections = new java.util.Vector();
  91.             connection = new ConnectionDescriptor("input", "void", "",
  92.                                     "%name%.previous();",
  93.                                     "previous");
  94.             connections.addElement(connection);
  95.  
  96.             previous.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  97.             md.addElement(previous);
  98.         } catch (Exception e) { throw new Error("previous:: " + e.toString()); }
  99.  
  100.         try{
  101.             args = null;
  102.             MethodDescriptor insert = new MethodDescriptor(beanClass.getMethod("insert", args));
  103.  
  104.             connections = new java.util.Vector();
  105.             connection = new ConnectionDescriptor("input", "void", "",
  106.                                     "%name%.insert();",
  107.                                     "insert");
  108.             connections.addElement(connection);
  109.  
  110.             insert.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  111.             md.addElement(insert);
  112.         } catch (Exception e) { throw new Error("insert:: " + e.toString()); }
  113.  
  114.         try{
  115.             args = null;
  116.             MethodDescriptor save = new MethodDescriptor(beanClass.getMethod("save", args));
  117.  
  118.             connections = new java.util.Vector();
  119.             connection = new ConnectionDescriptor("input", "void", "",
  120.                                     "%name%.save();",
  121.                                     "save");
  122.             connections.addElement(connection);
  123.  
  124.             save.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  125.             md.addElement(save);
  126.         } catch (Exception e) { throw new Error("save:: " + e.toString()); }
  127.  
  128.         try{
  129.             args = null;
  130.             MethodDescriptor saveAll = new MethodDescriptor(beanClass.getMethod("saveAll", args));
  131.  
  132.             connections = new java.util.Vector();
  133.             connection = new ConnectionDescriptor("input", "void", "",
  134.                                     "%name%.saveAll();",
  135.                                     "saveAll");
  136.             connections.addElement(connection);
  137.  
  138.             saveAll.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  139.             md.addElement(saveAll);
  140.         } catch (Exception e) { throw new Error("saveAll:: " + e.toString()); }
  141.  
  142.         try{
  143.             args = null;
  144.             MethodDescriptor saveAllLevels = new MethodDescriptor(beanClass.getMethod("saveAllLevels", args));
  145.  
  146.             connections = new java.util.Vector();
  147.             connection = new ConnectionDescriptor("input", "void", "",
  148.                                     "%name%.saveAllLevels();",
  149.                                     "saveAllLevels");
  150.             connections.addElement(connection);
  151.  
  152.             saveAllLevels.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  153.             md.addElement(saveAllLevels);
  154.         } catch (Exception e) { throw new Error("saveAllLevels:: " + e.toString()); }
  155.  
  156.         try{
  157.             args = null;
  158.             MethodDescriptor undoChanges = new MethodDescriptor(beanClass.getMethod("undoChanges", args));
  159.  
  160.             connections = new java.util.Vector();
  161.             connection = new ConnectionDescriptor("input", "void", "",
  162.                                     "%name%.undoChanges();",
  163.                                     "undoChanges");
  164.             connections.addElement(connection);
  165.  
  166.             undoChanges.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  167.             md.addElement(undoChanges);
  168.         } catch (Exception e) { throw new Error("save:: " + e.toString()); }
  169.  
  170.         try{
  171.             args = null;
  172.             MethodDescriptor first = new MethodDescriptor(beanClass.getMethod("first", args));
  173.  
  174.             connections = new java.util.Vector();
  175.             connection = new ConnectionDescriptor("input", "void", "",
  176.                                     "%name%.first();",
  177.                                     "first");
  178.             connections.addElement(connection);
  179.  
  180.             first.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  181.             md.addElement(first);
  182.         } catch (Exception e) { throw new Error("save:: " + e.toString()); }
  183.         try{
  184.             args = new Class[1];
  185.             args[0] = java.lang.Integer.TYPE ;
  186.             MethodDescriptor go_to = new MethodDescriptor(beanClass.getMethod("go_to", args));
  187.  
  188.             connections = new java.util.Vector();
  189.             connection = new ConnectionDescriptor("input", "int", "",
  190.                                     "%name%.go_to(%arg%);",
  191.                                     "go_to");
  192.             connections.addElement(connection);
  193.  
  194.             go_to.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  195.             md.addElement(go_to);
  196.         } catch (Exception e) { throw new Error("go_to:: " + e.toString()); }
  197.  
  198.         try{
  199.             args = null;
  200.             MethodDescriptor delete = new MethodDescriptor(beanClass.getMethod("delete", args));
  201.  
  202.             connections = new java.util.Vector();
  203.             connection = new ConnectionDescriptor("input", "void", "",
  204.                                     "%name%.delete();",
  205.                                     "delete");
  206.             connections.addElement(connection);
  207.  
  208.             delete.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  209.             md.addElement(delete);
  210.         } catch (Exception e) { throw new Error("save:: " + e.toString()); }
  211.  
  212.         try{
  213.             args = null;
  214.             MethodDescriptor restart = new MethodDescriptor(beanClass.getMethod("restart", args));
  215.  
  216.             connections = new java.util.Vector();
  217.             connection = new ConnectionDescriptor("input", "void", "",
  218.                                     "%name%.restart();",
  219.                                     "restart");
  220.             connections.addElement(connection);
  221.  
  222.             restart.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  223.             md.addElement(restart);
  224.         } catch (Exception e) { throw new Error("restart:: " + e.toString()); }
  225.  
  226.         try{
  227.             args = null;
  228.             MethodDescriptor startQueryByExample = new MethodDescriptor(beanClass.getMethod("startQueryByExample", args));
  229.  
  230.             connections = new java.util.Vector();
  231.             connection = new ConnectionDescriptor("input", "void", "",
  232.                                     "%name%.startQueryByExample();",
  233.                                     "startQueryByExample");
  234.             connections.addElement(connection);
  235.  
  236.             startQueryByExample.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  237.             md.addElement(startQueryByExample);
  238.         } catch (Exception e) { throw new Error("startQueryByExample:: " + e.toString()); }
  239.  
  240.  
  241.         try{
  242.             args = null;
  243.             MethodDescriptor executeQueryByExample = new MethodDescriptor(beanClass.getMethod("executeQueryByExample", args));
  244.  
  245.             connections = new java.util.Vector();
  246.             connection = new ConnectionDescriptor("input", "void", "",
  247.                                     "%name%.executeQueryByExample();",
  248.                                     "executeQueryByExample");
  249.             connections.addElement(connection);
  250.  
  251.             executeQueryByExample.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  252.             md.addElement(executeQueryByExample);
  253.         } catch (Exception e) { throw new Error("executeQueryByExample:: " + e.toString()); }
  254.  
  255.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  256.         md.copyInto(rv);
  257.  
  258.         return rv;
  259.     }
  260.  
  261.     public PropertyDescriptor[] getPropertyDescriptors() {
  262.         try{
  263.  
  264.         PropertyDescriptor className = new PropertyDescriptor("className", beanClass);
  265.         className.setBound(false);
  266.         className.setConstrained(false);
  267.         className.setDisplayName("Class Name");
  268.  
  269.         PropertyDescriptor aliasName = new PropertyDescriptor("aliasName", beanClass);
  270.         aliasName.setBound(false);
  271.         aliasName.setConstrained(false);
  272.         aliasName.setDisplayName("Alias Name");
  273.  
  274.  
  275.         PropertyDescriptor name = new PropertyDescriptor("name", beanClass);
  276.         name.setBound(false);
  277.         name.setConstrained(false);
  278.         name.setDisplayName("Name");
  279.  
  280.         PropertyDescriptor autoStart = new PropertyDescriptor("autoStart", beanClass);
  281.         autoStart.setBound(true);
  282.         autoStart.setConstrained(true);
  283.         autoStart.setDisplayName("AutoStart");
  284.  
  285.  
  286.         PropertyDescriptor[] rv = {
  287.             className,
  288.             aliasName,
  289.             name,
  290.             autoStart
  291.             };
  292.  
  293.         return rv;
  294.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  295.     }
  296.  
  297.     public int getDefaultPropertyIndex() {
  298.         return 0;    //  the index for our default property is always 0
  299.     }
  300.  
  301.     private final static Class beanClass = QueryNavigator.class;
  302.  
  303. }    //  end of class QueryNavigatorBeanInfo