home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 11.7 KB | 335 lines |
- package symantec.itools.awt.util.spinner;
-
- import java.beans.*;
- import symantec.itools.beans.*;
- import java.util.ResourceBundle;
-
- // 10/06/97 LAB Added semicolons to setEditable connections (Addresses Mac Bug #9004).
-
- /**
- * BeanInfo for Spinner.
- *
- */
-
- public class SpinnerBeanInfo extends SimpleBeanInfo {
-
- /**
- * Constructs a SpinnerBeanInfo object.
- */
- public SpinnerBeanInfo() {
- }
-
- /**
- * Gets a BeanInfo for the superclass of this bean.
- * @return BeanInfo[] containing this bean's superclass BeanInfo
- */
- public BeanInfo[] getAdditionalBeanInfo() {
- try {
- BeanInfo[] bi = new BeanInfo[1];
- bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
- return bi;
- }
- catch (IntrospectionException e) { throw new Error(e.toString());}
- }
-
- /**
- * Gets the SymantecBeanDescriptor for this bean.
- * @return an object of type SymantecBeanDescriptor
- * @see symantec.itools.beans.SymantecBeanDescriptor
- */
- public BeanDescriptor getBeanDescriptor() {
- SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
- bd.setCanAddChild(false);
-
- ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.ORIENTATION_VERTICAL",
- conn.getString("ORIENTATION_VERTICAL")));
-
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.ORIENTATION_HORIZONTAL",
- conn.getString("ORIENTATION_HORIZONTAL")));
-
- return (BeanDescriptor) bd;
- }
-
- /**
- * Gets an array of descriptions of the methods used for "connections" by
- * Visual CafΘ's Interaction Wizard.
- * Included in each method description is a CONNECTIONS ConnectionDescriptor.
- * @return method descriptions for this bean
- * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
- */
- public MethodDescriptor[] getMethodDescriptors() {
- Class[] args;
- ConnectionDescriptor connection;
- java.util.Vector connections;
- java.util.Vector md = new java.util.Vector();
- ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
-
- try{
- args = null;
- MethodDescriptor isEditable = new MethodDescriptor(beanClass.getMethod("isEditable", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "boolean", "",
- "%name%.isEditable()",
- conn.getString("isEditable"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("output", "boolean", "",
- "!%name%.isEditable()",
- conn.getString("isNonEditable"));
- connections.addElement(connection);
-
- isEditable.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(isEditable);
- } catch (Exception e) { throw new Error("isEditable:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getOrientation = new MethodDescriptor(beanClass.getMethod("getOrientation", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.getOrientation()",
- conn.getString("getOrientation"));
- connections.addElement(connection);
-
- getOrientation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getOrientation);
- } catch (Exception e) { throw new Error("getOrientation:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Boolean.TYPE ;
- MethodDescriptor setWrappable = new MethodDescriptor(beanClass.getMethod("setWrappable", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "boolean", "",
- "%name%.setWrappable(%arg%);",
- conn.getString("setWrappable"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setWrappable(true);",
- conn.getString("setWrappableTrue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setWrappable(false);",
- conn.getString("setWrappableFalse"));
- connections.addElement(connection);
-
- setWrappable.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setWrappable);
- } catch (Exception e) { throw new Error("setWrappable:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getMax = new MethodDescriptor(beanClass.getMethod("getMax", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.getMax()",
- conn.getString("getMax"));
- connections.addElement(connection);
-
- getMax.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getMax);
- } catch (Exception e) { throw new Error("getMax:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor setMax = new MethodDescriptor(beanClass.getMethod("setMax", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setMax(%arg%);",
- conn.getString("setMax"));
- connections.addElement(connection);
-
- setMax.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setMax);
- } catch (Exception e) { throw new Error("setMax:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor setOrientation = new MethodDescriptor(beanClass.getMethod("setOrientation", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setOrientation(%arg%);",
- conn.getString("setOrientation"));
- connections.addElement(connection);
-
- setOrientation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setOrientation);
- } catch (Exception e) { throw new Error("setOrientation:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor setCurrent = new MethodDescriptor(beanClass.getMethod("setCurrent", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setCurrent(%arg%);",
- conn.getString("setCurrent"));
- connections.addElement(connection);
-
- setCurrent.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setCurrent);
- } catch (Exception e) { throw new Error("setCurrent:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getMin = new MethodDescriptor(beanClass.getMethod("getMin", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.getMin()",
- conn.getString("getMin"));
- connections.addElement(connection);
-
- getMin.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getMin);
- } catch (Exception e) { throw new Error("getMin:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor setMin = new MethodDescriptor(beanClass.getMethod("setMin", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setMin(%arg%);",
- conn.getString("setMin"));
- connections.addElement(connection);
-
- setMin.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setMin);
- } catch (Exception e) { throw new Error("setMin:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Boolean.TYPE ;
- MethodDescriptor setEditable = new MethodDescriptor(beanClass.getMethod("setEditable", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "boolean", "",
- "%name%.setEditable(%arg%);",
- conn.getString("setEditable"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setEditable(true);",
- conn.getString("setEditableTrue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setEditable(false);",
- conn.getString("setEditableFalse"));
- connections.addElement(connection);
-
- setEditable.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setEditable);
- } catch (Exception e) { throw new Error("setEditable:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor isWrappable = new MethodDescriptor(beanClass.getMethod("isWrappable", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "boolean", "",
- "%name%.isWrappable()",
- conn.getString("isWrappable"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("output", "boolean", "",
- "!%name%.isWrappable()",
- conn.getString("isNotWrappable"));
- connections.addElement(connection);
-
- isWrappable.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(isWrappable);
- } catch (Exception e) { throw new Error("isWrappable:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getCurrent = new MethodDescriptor(beanClass.getMethod("getCurrent", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.getCurrent()",
- conn.getString("getCurrent"));
- connections.addElement(connection);
-
- getCurrent.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getCurrent);
- } catch (Exception e) { throw new Error("getCurrent:: " + e.toString()); }
-
- MethodDescriptor[] rv = new MethodDescriptor[md.size()];
- md.copyInto(rv);
-
- return rv;
- }
-
- /**
- * Returns descriptions of this bean's properties.
- */
- public PropertyDescriptor[] getPropertyDescriptors() {
- ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
-
- try{
- PropertyDescriptor orientation = new PropertyDescriptor("orientation", beanClass);
- orientation.setBound(true);
- orientation.setConstrained(true);
- orientation.setDisplayName(prop.getString("orientation"));
- orientation.setValue("ENUMERATION", "ORIENTATION_VERTICAL=0, ORIENTATION_HORIZONTAL=1");
-
- PropertyDescriptor min = new PropertyDescriptor("min", beanClass);
- min.setBound(true);
- min.setConstrained(true);
- min.setDisplayName(prop.getString("minimum"));
-
- PropertyDescriptor max = new PropertyDescriptor("max", beanClass);
- max.setBound(true);
- max.setConstrained(true);
- max.setDisplayName(prop.getString("maximum"));
-
- PropertyDescriptor current = new PropertyDescriptor("current", beanClass);
- current.setBound(true);
- current.setConstrained(true);
- current.setDisplayName(prop.getString("value"));
-
- PropertyDescriptor editable = new PropertyDescriptor("editable", beanClass);
- editable.setBound(true);
- editable.setConstrained(true);
- editable.setDisplayName(prop.getString("editable"));
-
- PropertyDescriptor wrappable = new PropertyDescriptor("wrappable", beanClass);
- wrappable.setBound(true);
- wrappable.setConstrained(true);
- wrappable.setDisplayName(prop.getString("wrappable"));
-
- PropertyDescriptor layout = new PropertyDescriptor("layout", beanClass);
- layout.setHidden(true);
-
- PropertyDescriptor[] rv = {
- orientation,
- min,
- max,
- current,
- editable,
- wrappable,
- layout};
- return rv;
- } catch (IntrospectionException e) { throw new Error(e.toString()); }
- }
-
- private final static Class beanClass = Spinner.class;
-
- } // end of class SpinnerBeanInfo