home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 7.5 KB | 222 lines |
- package symantec.itools.awt;
-
- import java.beans.*;
- import symantec.itools.beans.*;
- import java.util.ResourceBundle;
-
- // 09/07/97 LAB Removed background, foreground, and font properties (Addresses Mac Bug #7668).
-
- /**
- * BeanInfo for DirectionButton.
- *
- */
-
- public class DirectionButtonBeanInfo extends SimpleBeanInfo {
-
- /**
- * Constructs a DirectionButtonBeanInfo object.
- */
- public DirectionButtonBeanInfo() {
- }
-
- /**
- * 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() {
- ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
- String s=group.getString("GroupAdditional");
-
- SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
- bd.setFolder(s);
- bd.setToolbar(s);
- bd.setWinHelp("0x123A2");
-
- ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
-
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.LEFT",
- conn.getString("LEFT")));
-
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.RIGHT",
- conn.getString("RIGHT")));
-
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.UP",
- conn.getString("UP")));
-
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.DOWN",
- conn.getString("DOWN")));
-
- bd.addAdditionalConnections(getAdditionalBeanInfo());
-
- return (BeanDescriptor) bd;
- }
-
- /**
- * Gets an image that may be used to visually represent this bean
- * (in the toolbar, on a form, etc).
- * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
- * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
- * @return an image for this bean, always color even if requested monochrome
- * @see BeanInfo#ICON_MONO_16x16
- * @see BeanInfo#ICON_COLOR_16x16
- * @see BeanInfo#ICON_MONO_32x32
- * @see BeanInfo#ICON_COLOR_32x32
- */
- public java.awt.Image getIcon(int iconKind) {
- if (iconKind == BeanInfo.ICON_MONO_16x16 ||
- iconKind == BeanInfo.ICON_COLOR_16x16) {
- java.awt.Image img = loadImage("DirectionButtonC16.gif");
- return img;
- }
-
- if (iconKind == BeanInfo.ICON_MONO_32x32 ||
- iconKind == BeanInfo.ICON_COLOR_32x32) {
- java.awt.Image img = loadImage("DirectionButtonC32.gif");
- return img;
- }
-
- return null;
- }
-
- /**
- * 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 = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor setDirection = new MethodDescriptor(beanClass.getMethod("setDirection", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setDirection(%arg%);",
- conn.getString("setDirection"));
- connections.addElement(connection);
-
- setDirection.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setDirection);
- } catch (Exception e) { throw new Error("setDirection:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getDirection = new MethodDescriptor(beanClass.getMethod("getDirection", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.getDirection()",
- conn.getString("getDirection"));
- connections.addElement(connection);
-
- getDirection.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getDirection);
- } catch (Exception e) { throw new Error("getDirection:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.awt.Color.class ;
- MethodDescriptor setArrowColor = new MethodDescriptor(beanClass.getMethod("setArrowColor", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "Color", "",
- "%name%.setArrowColor(%arg%);",
- conn.getString("setArrowColor"));
- connections.addElement(connection);
-
- setArrowColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setArrowColor);
- } catch (Exception e) { throw new Error("setArrowColor:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getArrowColor = new MethodDescriptor(beanClass.getMethod("getArrowColor", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "Color", "",
- "%name%.getArrowColor()",
- conn.getString("getArrowColor"));
- connections.addElement(connection);
-
- getArrowColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getArrowColor);
- } catch (Exception e) { throw new Error("getArrowColor:: " + 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 direction = new PropertyDescriptor("direction", beanClass);
- direction.setBound(true);
- direction.setConstrained(true);
- direction.setDisplayName(prop.getString("direction"));
- direction.setValue("ENUMERATION", "LEFT=0, RIGHT=1, UP=2, DOWN=3");
-
- PropertyDescriptor arrowIndent = new PropertyDescriptor("arrowIndent", beanClass);
- arrowIndent.setBound(true);
- arrowIndent.setConstrained(true);
- arrowIndent.setDisplayName(prop.getString("arrowIndent"));
-
- PropertyDescriptor arrowColor = new PropertyDescriptor("arrowColor", beanClass);
- arrowColor.setBound(true);
- arrowColor.setConstrained(true);
- arrowColor.setDisplayName(prop.getString("arrowColor"));
-
- PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
- background.setHidden(true);
-
- PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass);
- foreground.setHidden(true);
-
- PropertyDescriptor font = new PropertyDescriptor("font", beanClass);
- font.setHidden(true);
-
- PropertyDescriptor[] rv = {
- direction,
- arrowIndent,
- arrowColor,
- background,
- foreground,
- font};
- return rv;
- } catch (IntrospectionException e) { throw new Error(e.toString()); }
- }
-
- private final static Class beanClass = DirectionButton.class;
-
- } // end of class DirectionButtonBeanInfo