home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 10.4 KB | 293 lines |
- package symantec.itools.awt;
-
- import java.beans.*;
- import symantec.itools.beans.*;
- import java.util.ResourceBundle;
-
- // 09/07/97 LAB Fixed misspelling of descriptions. Removed background and foreground properties.
-
- /**
- * BeanInfo for LabelButton.
- *
- */
- public class LabelButtonBeanInfo extends SimpleBeanInfo {
-
- /**
- * Constructs a LabelButtonBeanInfo object.
- */
- public LabelButtonBeanInfo() {
- }
-
- /**
- * 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("0x123A6");
-
- ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
- s=conn.getString("ALIGN_LEFT");
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.ALIGN_LEFT",s));
-
- s=conn.getString("ALIGN_CENTERED");
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.ALIGN_CENTERED",s));
-
- s=conn.getString("ALIGN_RIGHT");
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.ALIGN_RIGHT",s));
-
- s=conn.getString("ALIGN_TOP");
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.ALIGN_TOP",s));
-
- s=conn.getString("ALIGN_BOTTOM");
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.ALIGN_BOTTOM",s));
-
-
- 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("LabelButtonC16.gif");
- return img;
- }
-
- if (iconKind == BeanInfo.ICON_MONO_32x32 ||
- iconKind == BeanInfo.ICON_COLOR_32x32) {
- java.awt.Image img = loadImage("LabelButtonC32.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.String.class ;
- MethodDescriptor setText = new MethodDescriptor(beanClass.getMethod("setText", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "String", "",
- "%name%.setText(%arg%);",
- conn.getString("setText"));
- connections.addElement(connection);
-
- setText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setText);
- } catch (Exception e) { throw new Error("setText:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getVerticalAlignStyle = new MethodDescriptor(beanClass.getMethod("getVerticalAlignStyle", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.getVerticalAlignStyle()",
- conn.getString("getVerticalAlignStyle"));
- connections.addElement(connection);
-
- getVerticalAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getVerticalAlignStyle);
- } catch (Exception e) { throw new Error("getVerticalAlignStyle:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.awt.Color.class ;
- MethodDescriptor setTextColor = new MethodDescriptor(beanClass.getMethod("setTextColor", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "Color", "",
- "%name%.setTextColor(%arg%);",
- conn.getString("setTextColorLBtn"));
- connections.addElement(connection);
-
- setTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setTextColor);
- } catch (Exception e) { throw new Error("setTextColor:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor setAlignStyle = new MethodDescriptor(beanClass.getMethod("setAlignStyle", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setAlignStyle(%arg%);",
- conn.getString("setAlignStyleLBtn"));
- connections.addElement(connection);
-
- setAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setAlignStyle);
- } catch (Exception e) { throw new Error("setAlignStyle:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor setVerticalAlignStyle = new MethodDescriptor(beanClass.getMethod("setVerticalAlignStyle", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setVerticalAlignStyle(%arg%);",
- conn.getString("setVerticalAlignStyle"));
- connections.addElement(connection);
-
- setVerticalAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setVerticalAlignStyle);
- } catch (Exception e) { throw new Error("setVerticalAlignStyle:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getTextColor = new MethodDescriptor(beanClass.getMethod("getTextColor", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "Color", "",
- "%name%.getTextColor()",
- conn.getString("getTextColorLBtn"));
- connections.addElement(connection);
-
- getTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getTextColor);
- } catch (Exception e) { throw new Error("getTextColor:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getText = new MethodDescriptor(beanClass.getMethod("getText", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "String", "",
- "%name%.getText()",
- conn.getString("getTextLBtn"));
- connections.addElement(connection);
-
- getText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getText);
- } catch (Exception e) { throw new Error("getText:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getAlignStyle = new MethodDescriptor(beanClass.getMethod("getAlignStyle", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.getAlignStyle()",
- conn.getString("getAlignStyleLBtn"));
- connections.addElement(connection);
-
- getAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getAlignStyle);
- } catch (Exception e) { throw new Error("getAlignStyle:: " + 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 defProperty = new PropertyDescriptor("text", beanClass);
- defProperty.setBound(true);
- defProperty.setConstrained(true);
- defProperty.setDisplayName(prop.getString("text"));
-
- PropertyDescriptor textColor = new PropertyDescriptor("textColor", beanClass);
- textColor.setBound(true);
- textColor.setConstrained(true);
- textColor.setDisplayName(prop.getString("textColor"));
-
- PropertyDescriptor alignStyle = new PropertyDescriptor("alignStyle", beanClass);
- alignStyle.setBound(true);
- alignStyle.setConstrained(true);
- alignStyle.setDisplayName(prop.getString("alignStyle"));
- alignStyle.setValue("ENUMERATION", "ALIGN_LEFT=0, ALIGN_CENTERED=1, ALIGN_RIGHT=2");
-
- PropertyDescriptor verticalAlignStyle = new PropertyDescriptor("verticalAlignStyle", beanClass);
- verticalAlignStyle.setBound(true);
- verticalAlignStyle.setConstrained(true);
- verticalAlignStyle.setDisplayName(prop.getString("verticalAlignStyle"));
- verticalAlignStyle.setValue("ENUMERATION", "ALIGN_TOP=0, ALIGN_CENTERED=1, ALIGN_BOTTOM=2");
-
- PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
- background.setHidden(true);
-
- PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass);
- foreground.setHidden(true);
-
- PropertyDescriptor[] rv = {
- defProperty,
- textColor,
- alignStyle,
- verticalAlignStyle,
- background,
- foreground};
- return rv;
- } catch (IntrospectionException e) { throw new Error(e.toString()); }
- }
-
- /**
- * Returns the index of the property expected to be changed most often by the designer.
- */
- public int getDefaultPropertyIndex() {
- return 0; // the index for our default property is always 0
- }
-
- private final static Class beanClass = LabelButton.class;
-
- } // end of class LabelButtonBeanInfo