home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 7.2 KB | 207 lines |
- /*
- * @(#GridBeanInfo.java
- *
- * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
- *
- */
-
- package symantec.itools.db.awt;
-
- import java.beans.*;
- import symantec.itools.beans.*;
- import java.util.ResourceBundle;
-
- /**
- * BeanInfo for the Grid component.
- */
- public class GridBeanInfo extends SimpleBeanInfo
- {
-
- /**
- * Constructs a GridBeanInfo object.
- */
- public GridBeanInfo() {
- }
-
- /**
- * Gets BeanInfo for the superclass of this bean.
- * @return BeanInfo[] containing this bean's superclass BeanInfo
- */
- public BeanInfo[] getAdditionalBeanInfo() {
- try {
- java.util.Vector v = new java.util.Vector();
- BeanInfo[] rv;
- BeanInfo b;
- Class c = beanClass.getSuperclass();
- //we don't want to introspect the TableView class, nor the panel
- //and container class only 'higher' ones
- c = c.getSuperclass();
- c = c.getSuperclass();
- c = c.getSuperclass();
-
- while (c.isAssignableFrom(Object.class) != true) {
- b = Introspector.getBeanInfo(c);
- v.addElement(b);
- c = c.getSuperclass();
- }
- rv = new BeanInfo[v.size()];
- v.copyInto(rv);
-
- return rv;
- }
- 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.setFolder("dbAWARE");
- bd.setToolbar("dbAWARE");
- bd.setWinHelp("0x12523");
-
- return (BeanDescriptor) bd;
- }
-
- // getIcon returns an image object which can be used by toolboxes, toolbars
- // to represent this bean. Icon images are in GIF format.
- /**
- * 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_COLOR_16x16 ||
- iconKind == BeanInfo.ICON_MONO_16x16)
- {
- java.awt.Image img = loadImage("GridC16.gif");
- return img;
- }
- if (iconKind == BeanInfo.ICON_COLOR_32x32 ||
- iconKind == BeanInfo.ICON_MONO_32x32)
- {
- java.awt.Image img = loadImage("GridC32.gif");
- return img;
- }
- return null;
- }
-
- /**
- * Gets an empty MethodDescriptor array.
- * @return an empty array
- */
- public MethodDescriptor[] getMethodDescriptors() {
- return new MethodDescriptor[0];
- }
-
- // getPropertyDescriptors returns an array of PropertyDescriptors which describe
- // the editable properties of this bean.
- /**
- * Gets an array of descriptions of this bean's properties.
- * @return property descriptions for this bean
- */
- public PropertyDescriptor[] getPropertyDescriptors()
- {
- ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.db.resources.PropBundle");
-
- try
- {
- PropertyDescriptor dataBinding = new PropertyDescriptor("dataBinding", beanClass);
- dataBinding.setBound(false);
- dataBinding.setConstrained(false);
- dataBinding.setDisplayName(prop.getString("dataBinding"));
- dataBinding.setPropertyEditorClass(symantec.itools.db.beans.binding.NameEditor.class);
-
- PropertyDescriptor columns = new PropertyDescriptor("columnsNumber", beanClass);
- columns.setBound(false);
- columns.setConstrained(false);
- columns.setDisplayName(prop.getString("columnsNumber"));
-
- PropertyDescriptor rows = new PropertyDescriptor("rowsNumber", beanClass);
- rows.setBound(false);
- rows.setConstrained(false);
- rows.setDisplayName(prop.getString("rowsNumber"));
-
- /*PropertyDescriptor appendButton = new PropertyDescriptor("appendButton", beanClass);
- appendButton.setBound(false);
- appendButton.setConstrained(false);
- appendButton.setDisplayName(prop.getString("appendButton"));*/
-
- PropertyDescriptor insertButton = new PropertyDescriptor("insertButton", beanClass);
- insertButton.setBound(false);
- insertButton.setConstrained(false);
- insertButton.setDisplayName(prop.getString("insertButton"));
-
- PropertyDescriptor gotoButton = new PropertyDescriptor("gotoButton", beanClass);
- gotoButton.setBound(false);
- gotoButton.setConstrained(false);
- gotoButton.setDisplayName(prop.getString("gotoButton"));
-
- PropertyDescriptor undoButton = new PropertyDescriptor("undoButton", beanClass);
- undoButton.setBound(false);
- undoButton.setConstrained(false);
- undoButton.setDisplayName(prop.getString("undoButton"));
-
- PropertyDescriptor restartButton = new PropertyDescriptor("restartButton", beanClass);
- restartButton.setBound(false);
- restartButton.setConstrained(false);
- restartButton.setDisplayName(prop.getString("restartButton"));
-
- PropertyDescriptor deleteButton = new PropertyDescriptor("deleteButton", beanClass);
- deleteButton.setBound(false);
- deleteButton.setConstrained(false);
- deleteButton.setDisplayName(prop.getString("deleteButton"));
-
- /* PropertyDescriptor undeleteButton = new PropertyDescriptor("undeleteButton", beanClass);
- undeleteButton.setBound(false);
- undeleteButton.setConstrained(false);
- undeleteButton.setDisplayName(prop.getString("undeleteButton"));*/
-
- PropertyDescriptor saveButton = new PropertyDescriptor("saveButton", beanClass);
- saveButton.setBound(false);
- saveButton.setConstrained(false);
- saveButton.setDisplayName(prop.getString("saveButton"));
-
- PropertyDescriptor toolbarBackground = new PropertyDescriptor("toolbarBackground", beanClass);
- toolbarBackground.setBound(false);
- toolbarBackground.setConstrained(false);
- toolbarBackground.setDisplayName(prop.getString("toolbarBackground"));
-
-
- PropertyDescriptor rv[] = {dataBinding, columns, rows,
- //appendButton,
- insertButton,
- gotoButton, undoButton,
- restartButton, deleteButton,
- // undeleteButton,
- saveButton,
- toolbarBackground};
-
- 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 = Grid.class;
- }
-