/*
* Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
*
* This SOURCE CODE FILE, which has been provided by Borland as part
* of a Borland product for use ONLY by licensed users of the product,
* includes CONFIDENTIAL and PROPRIETARY information of Borland.
*
* USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
* OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
* THE PRODUCT.
*
* IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
* COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
* OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
* OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
* OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
* OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
* CODE FILE.
*/
//
// BeanInfo for DateBean. It only surfaces those properties that "make sense"
// in the designer. The Style of the bean is handled via an enumeration and any
// design tool that understands this Beans concept will allow for the generation
// of "good looking" or "readable" code when one of these is used.
//
// There are two customizers to choose from in this bean. One is a "batch mode"
// customizer which uses an <apply> button to control when propertyChangeEvents
// get fired. The other is a "live mode" customizer which fires the propertyChangeEvents
// whenever the UI of the Customizer is tickled. There are times when you might
// want one or the other. By changing the value of "livemode" in the BeanInfo
// and recompiling, you can see the different Customizers in action.
//
package borland.samples.beans.customizer;
import java.beans.*;
public class DateBeanBeanInfo extends SimpleBeanInfo {
Class beanClass = DateBean.class;
String iconColor16x16Filename = "DateBean16x16.gif";
String iconColor32x32Filename = "DateBean32x32.gif";
String iconMono16x16Filename;
String iconMono32x32Filename;
// to switch between 'batch' and 'live' customizers, adjust livemode
// livemode = false means show customizer that batches up changes and uses an "apply"
// button to fire the property change events
// livemode = true means show customizer that is "alive" and each UI change in the
// customizer fires the property change events
static final boolean livemode = true;
public DateBeanBeanInfo() {
}
public BeanDescriptor getBeanDescriptor(){
if(livemode)
return new BeanDescriptor(DateBean.class, DateBeanCustomizer_live.class);
else
return new BeanDescriptor(DateBean.class, DateBeanCustomizer_batch.class);
}
public PropertyDescriptor[] getPropertyDescriptors() {
try {
PropertyDescriptor _background = new PropertyDescriptor("background", beanClass, "getBackground", "setBackground");
_background.setDisplayName("background");
_background.setShortDescription("background");
PropertyDescriptor _font = new PropertyDescriptor("font", beanClass, "getFont", "setFont");
_font.setDisplayName("font");
_font.setShortDescription("font");
PropertyDescriptor _fontColor = new PropertyDescriptor("fontColor", beanClass, "getFontColor", "setFontColor");
_fontColor.setDisplayName("color for font");
_fontColor.setShortDescription("font color");
PropertyDescriptor _style = new PropertyDescriptor("style", beanClass, "getStyle", "setStyle");
_style.setDisplayName("style");
_style.setShortDescription("style");
// enumeration mechanism added to the Beans spec. Format is a simple array
// of objects in triplet sets. First item is the string to display in the
// IDE (each mfr has to decide how they want to do it). The second item is
// the value of the object (typically an Integer) and the third is the
// code-gen string. This mechanism really makes code more readable when
// created by a bean-aware RAD tool. Instead of seeing
// x.setStyle(2);
// you would see
// x.setStyle(DateBean.YEAR_MONTH_DAY);
// in your code. The latter matching what many developers already do to
// make their code more readible
_style.setValue("enumerationValues", new Object[] {
"Mon Day Year", new Integer(DateBean.MONTH_DAY_YEAR), "DateBean.MONTH_DAY_YEAR",
"Mon Day Year Era", new Integer(DateBean.MONTH_DAY_YEAR_ERA), "DateBean.MONTH_DAY_YEAR_ERA",
"Year Mon Day", new Integer(DateBean.YEAR_MONTH_DAY), "DateBean.YEAR_MONTH_DAY",
"Mon Year", new Integer(DateBean.MONTH_YEAR), "DateBean.MONTH_YEAR",
"Day Mon Year", new Integer(DateBean.DAY_MONTH_YEAR), "DateBean.DAY_MONTH_YEAR"
});
PropertyDescriptor _useMonthString = new PropertyDescriptor("useMonthString", beanClass, "getUseMonthString", "setUseMonthString");
_useMonthString.setDisplayName("use month string");
_useMonthString.setShortDescription("month string");
PropertyDescriptor[] pds = new PropertyDescriptor[] {
_background,
_font,
_fontColor,
_style,
_useMonthString
};
return pds;
}
catch (IntrospectionException ex) {
ex.printStackTrace();
return null;
}
}
public java.awt.Image getIcon(int iconKind) {
switch (iconKind) {
case BeanInfo.ICON_COLOR_16x16:
return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null;
case BeanInfo.ICON_COLOR_32x32:
return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null;
case BeanInfo.ICON_MONO_16x16:
return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null;
case BeanInfo.ICON_MONO_32x32:
return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null;
}
return null;
}
}
|