home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 22.2 KB | 601 lines |
- package symantec.itools.awt;
-
- import java.beans.*;
- import symantec.itools.beans.*;
- import java.util.ResourceBundle;
-
-
- // 08/09/97 LAB Added ListDown property. Added connections for ListDown. Removed dropList
- // connections.
-
- /**
- * BeanInfo for ComboBox.
- *
- */
-
- public class ComboBoxBeanInfo extends SimpleBeanInfo {
-
- /**
- * Constructs a ComboBoxBeanInfo object.
- */
- public ComboBoxBeanInfo() {
- }
-
- /**
- * 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.setCanAddChild(false);
- bd.setWinHelp("0x1238E");
- bd.setFolder(s);
- bd.setToolbar(s);
-
- 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("ComboBoxC16.gif");
- return img;
- }
-
- if (iconKind == BeanInfo.ICON_MONO_32x32 ||
- iconKind == BeanInfo.ICON_COLOR_32x32) {
- java.awt.Image img = loadImage("ComboBoxC32.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");
- String s;
-
- try{
- args = new Class[1];
- args[0] = java.lang.Boolean.TYPE ;
- MethodDescriptor setListDown = new MethodDescriptor(beanClass.getMethod("setListDown", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "boolean", "",
- "%name%.setListDown(%arg%);",
- conn.getString("setListDown"));
- connections.addElement(connection);
-
- setListDown.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setListDown);
- } catch (Exception e) { throw new Error("setListDown:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor isListDown = new MethodDescriptor(beanClass.getMethod("isListDown", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "boolean", "",
- "%name%.isListDown()",
- conn.getString("isListDown"));
- connections.addElement(connection);
-
- isListDown.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(isListDown);
- } catch (Exception e) { throw new Error("isListDown:: " + e.toString()); }
-
- 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 = new Class[1];
- args[0] = java.lang.String.class ;
- MethodDescriptor addItem = new MethodDescriptor(beanClass.getMethod("addItem", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "String", "",
- "%name%.addItem(%arg%);",
- conn.getString("addItem"));
- connections.addElement(connection);
-
- addItem.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(addItem);
- } catch (Exception e) { throw new Error("addItem:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Boolean.TYPE ;
- MethodDescriptor setSearchable = new MethodDescriptor(beanClass.getMethod("setSearchable", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "boolean", "",
- "%name%.setSearchable(%arg%);",
- conn.getString("setSearchableValue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setSearchable(true);",
- conn.getString("setSearchableTrue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setSearchable(false);",
- conn.getString("setSearchableFalse"));
- connections.addElement(connection);
-
- setSearchable.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setSearchable);
- } catch (Exception e) { throw new Error("setSearchable:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor isCaseSensitive = new MethodDescriptor(beanClass.getMethod("isCaseSensitive", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "boolean", "",
- "%name%.isCaseSensitive()",
- conn.getString("isCaseSensitive"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("output", "boolean", "",
- "!%name%.isCaseSensitive()",
- conn.getString("isNonCaseSensitive"));
- connections.addElement(connection);
-
- isCaseSensitive.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(isCaseSensitive);
- } catch (Exception e) { throw new Error("isCaseSensitive:: " + e.toString()); }
-
- 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("setTextCB"));
- connections.addElement(connection);
-
- setText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setText);
- } catch (Exception e) { throw new Error("setText:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Boolean.TYPE ;
- MethodDescriptor setCaseSensitive = new MethodDescriptor(beanClass.getMethod("setCaseSensitive", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "boolean", "",
- "%name%.setCaseSensitive(%arg%);",
- conn.getString("setCaseSensitiveValue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setCaseSensitive(true);",
- conn.getString("setCaseSensitiveTrue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setCaseSensitive(false);",
- conn.getString("setCaseSensitiveFalse"));
- connections.addElement(connection);
-
- setCaseSensitive.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setCaseSensitive);
- } catch (Exception e) { throw new Error("setCaseSensitive:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor isShowVerticalScroll = new MethodDescriptor(beanClass.getMethod("isShowVerticalScroll", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "boolean", "",
- "%name%.isShowVerticalScroll()",
- conn.getString("isShowVerticalScrollVisible"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("output", "boolean", "",
- "!%name%.isShowVerticalScroll()",
- conn.getString("isShowVerticalScrollHidden"));
- connections.addElement(connection);
-
- isShowVerticalScroll.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(isShowVerticalScroll);
- } catch (Exception e) { throw new Error("isShowVerticalScroll:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor select = new MethodDescriptor(beanClass.getMethod("select", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.select(%arg%);",
- conn.getString("selectIndex"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "String", "",
- "%name%.select(%arg%);",
- conn.getString("selectString"));
- connections.addElement(connection);
-
- select.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(select);
- } catch (Exception e) { throw new Error("select:: " + 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("setEditableValue"));
- 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 delSelectedItem = new MethodDescriptor(beanClass.getMethod("delSelectedItem", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.delSelectedItem();",
- conn.getString("delSelectedItem"));
- connections.addElement(connection);
-
- delSelectedItem.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(delSelectedItem);
- } catch (Exception e) { throw new Error("delSelectedItem:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor isShowHorizontalScroll = new MethodDescriptor(beanClass.getMethod("isShowHorizontalScroll", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "boolean", "",
- "%name%.isShowHorizontalScroll()",
- conn.getString("isShowHorizontalScrollVisible"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("output", "boolean", "",
- "!%name%.isShowHorizontalScroll()",
- conn.getString("isShowHorizontalScrollHidden"));
- connections.addElement(connection);
-
- isShowHorizontalScroll.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(isShowHorizontalScroll);
- } catch (Exception e) { throw new Error("isShowHorizontalScroll:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor delItem = new MethodDescriptor(beanClass.getMethod("delItem", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.delItem(%arg%);",
- conn.getString("delItem"));
- connections.addElement(connection);
-
- delItem.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(delItem);
- } catch (Exception e) { throw new Error("delItem:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Boolean.TYPE ;
- MethodDescriptor setShowVerticalScroll = new MethodDescriptor(beanClass.getMethod("setShowVerticalScroll", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "boolean", "",
- "%name%.setShowVerticalScroll(%arg%);",
- conn.getString("setShowVerticalScrollValue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setShowVerticalScroll(true);",
- conn.getString("setShowVerticalScrollTrue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setShowVerticalScroll(false);",
- conn.getString("setShowVerticalScrollFalse"));
- connections.addElement(connection);
-
- setShowVerticalScroll.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setShowVerticalScroll);
- } catch (Exception e) { throw new Error("setShowVerticalScroll:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor isSearchable = new MethodDescriptor(beanClass.getMethod("isSearchable", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "boolean", "",
- "%name%.isSearchable()",
- conn.getString("isSearchable"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("output", "boolean", "",
- "!%name%.isSearchable()",
- conn.getString("isNonSearchable"));
- connections.addElement(connection);
-
- isSearchable.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(isSearchable);
- } catch (Exception e) { throw new Error("isSearchable:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getSelectedItem = new MethodDescriptor(beanClass.getMethod("getSelectedItem", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "String", "",
- "%name%.getSelectedItem()",
- conn.getString("getSelectedItem"));
- connections.addElement(connection);
-
- getSelectedItem.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getSelectedItem);
- } catch (Exception e) { throw new Error("getSelectedItem:: " + 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("getTextCB"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("output", "int", "",
- "Integer.parseInt(%name%.getText())",
- conn.getString("parseInt"));
- connections.addElement(connection);
-
- getText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getText);
- } catch (Exception e) { throw new Error("getText:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor countItems = new MethodDescriptor(beanClass.getMethod("countItems", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.countItems()",
- conn.getString("countItems"));
- connections.addElement(connection);
-
- countItems.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(countItems);
- } catch (Exception e) { throw new Error("countItems:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Boolean.TYPE ;
- MethodDescriptor setShowHorizontalScroll = new MethodDescriptor(beanClass.getMethod("setShowHorizontalScroll", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "boolean", "",
- "%name%.setShowHorizontalScroll(%arg%);",
- conn.getString("setShowHorizontalScrollValue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setShowHorizontalScroll(true);",
- conn.getString("setShowHorizontalScrollTrue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "void", "",
- "%name%.setShowHorizontalScroll(false);",
- conn.getString("setShowHorizontalScrollFalse"));
- connections.addElement(connection);
-
- setShowHorizontalScroll.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setShowHorizontalScroll);
- } catch (Exception e) { throw new Error("setShowHorizontalScroll:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor deselect = new MethodDescriptor(beanClass.getMethod("deselect", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.deselect(%arg%);",
- conn.getString("deselect"));
- connections.addElement(connection);
-
- deselect.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(deselect);
- } catch (Exception e) { throw new Error("deselect:: " + e.toString()); }
-
- try{
- args = new Class[2];
- args[0] = java.lang.Integer.TYPE ;
- args[1] = java.lang.Boolean.TYPE ;
- MethodDescriptor setEnabled = new MethodDescriptor(beanClass.getMethod("setEnabled", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setEnabled(%arg%, true);",
- conn.getString("setEnabledTrue"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setEnabled(%arg%, false);",
- conn.getString("setEnabledFalse"));
- connections.addElement(connection);
-
- setEnabled.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setEnabled);
- } catch (Exception e) { throw new Error("setEnabled:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getSelectedIndex = new MethodDescriptor(beanClass.getMethod("getSelectedIndex", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.getSelectedIndex()",
- conn.getString("getSelectedIndex"));
- connections.addElement(connection);
-
- getSelectedIndex.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getSelectedIndex);
- } catch (Exception e) { throw new Error("getSelectedIndex:: " + 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 listDown = new PropertyDescriptor("listDown", beanClass);
- listDown.setBound(true);
- listDown.setConstrained(true);
- listDown.setDisplayName(prop.getString("listDown"));
-
- PropertyDescriptor caseSensitive = new PropertyDescriptor("caseSensitive", beanClass);
- caseSensitive.setBound(true);
- caseSensitive.setConstrained(true);
- caseSensitive.setDisplayName(prop.getString("caseSensitive"));
-
- PropertyDescriptor editable = new PropertyDescriptor("editable", beanClass);
- editable.setBound(true);
- editable.setConstrained(true);
- editable.setDisplayName(prop.getString("editable"));
-
- PropertyDescriptor listItems = new PropertyDescriptor("listItems", beanClass);
- listItems.setBound(true);
- listItems.setConstrained(true);
- listItems.setDisplayName(prop.getString("listItems"));
-
- PropertyDescriptor searchable = new PropertyDescriptor("searchable", beanClass);
- searchable.setBound(true);
- searchable.setConstrained(true);
- searchable.setDisplayName(prop.getString("searchable"));
-
- PropertyDescriptor showHorizontalScroll = new PropertyDescriptor("showHorizontalScroll", beanClass);
- showHorizontalScroll.setBound(true);
- showHorizontalScroll.setConstrained(true);
- showHorizontalScroll.setDisplayName(prop.getString("showHorizontalScroll"));
-
- PropertyDescriptor showVerticalScroll = new PropertyDescriptor("showVerticalScroll", beanClass);
- showVerticalScroll.setBound(true);
- showVerticalScroll.setConstrained(true);
- showVerticalScroll.setDisplayName(prop.getString("showVerticalScroll"));
-
- PropertyDescriptor layout = new PropertyDescriptor("layout", beanClass);
- layout.setHidden(true);
-
- PropertyDescriptor[] rv = {
- defProperty,
- listDown,
- caseSensitive,
- editable,
- listItems,
- searchable,
- showHorizontalScroll,
- showVerticalScroll,
- layout};
- 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 = ComboBox.class;
-
- } // end of class ComboBoxBeanInfo