static { try { EventSetDescriptor propertyChange = new EventSetDescriptor( BEAN_CLASS, "propertyChange", PropertyChangeListener.class, "propertyChange"); propertyChange.setDisplayName(ResourceBundleLoader.getText("EVT_NAME_PROPERTY_CHANGE")); propertyChange.setShortDescription(ResourceBundleLoader.getText("EVT_DESC_PROPERTY_CHANGE")); eventSetDescriptors_ = new EventSetDescriptor[] {propertyChange}; PropertyDescriptor path = new PropertyDescriptor("path", BEAN_CLASS); path.setBound(true); path.setConstrained(false); path.setDisplayName(ResourceBundleLoader.getText("PROP_NAME_PATH")); path.setShortDescription(ResourceBundleLoader.getText("PROP_DESC_PATH")); PropertyDescriptor system = new PropertyDescriptor("system", BEAN_CLASS); system.setBound(true); system.setConstrained(false); system.setDisplayName(ResourceBundleLoader.getText("PROP_NAME_SYSTEM")); system.setShortDescription(ResourceBundleLoader.getText("PROP_DESC_SYSTEM")); propertyDescriptors_ = new PropertyDescriptor[] {path, system}; } catch (IntrospectionException e) { Trace.log(Trace.ERROR, "Unexpected IntrospectionException:", e); throw new InternalErrorException(InternalErrorException.UNEXPECTED_EXCEPTION); } }
/* * see java.beans.FeatureDescriptor#FeatureDescriptor(FeatureDescriptor) */ public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target) throws IntrospectionException { target.setExpert(source.isExpert()); target.setHidden(source.isHidden()); target.setPreferred(source.isPreferred()); target.setName(source.getName()); target.setShortDescription(source.getShortDescription()); target.setDisplayName(source.getDisplayName()); // copy all attributes (emulating behavior of private FeatureDescriptor#addTable) Enumeration<String> keys = source.attributeNames(); while (keys.hasMoreElements()) { String key = keys.nextElement(); target.setValue(key, source.getValue(key)); } // see java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor) target.setPropertyEditorClass(source.getPropertyEditorClass()); target.setBound(source.isBound()); target.setConstrained(source.isConstrained()); }
@Override public void introspect(IntrospectionContext context) throws IntrospectionException { for (Method method : context.getTargetClass().getMethods()) { try { Class<?>[] argTypes = method.getParameterTypes(); int argCount = argTypes.length; if (argCount == 1 && method.getName().startsWith("set")) { String propertyName = Introspector.decapitalize(method.getName().substring(3)); if (!propertyName.equals("class")) { PropertyDescriptor pd = context.getDescriptor(propertyName); boolean setWriteMethod = false; if (pd == null) { pd = new PropertyDescriptor(propertyName, null, method); context.addDescriptor(pd); setWriteMethod = true; } else if (pd.getWriteMethod() == null && pd.getReadMethod() != null && pd.getReadMethod().getReturnType() == argTypes[0]) { pd.setWriteMethod(method); setWriteMethod = true; } if (setWriteMethod) { for (Class<?> type : method.getExceptionTypes()) { if (type == PropertyVetoException.class) { pd.setConstrained(true); break; } } } } } } catch (IntrospectionException ignored) { } } }
/** * Creates {@code PropertyDescriptor} from the specified property info. * * @param entry the pair of values, where the {@code key} is the base name of the property (the * rest of the method name) and the {@code value} is the automatically generated property info * @param bound the flag indicating whether it is possible to treat this property as a bound * property * @since 9 */ PropertyDescriptor(Entry<String, PropertyInfo> entry, boolean bound) { String base = entry.getKey(); PropertyInfo info = entry.getValue(); setName(Introspector.decapitalize(base)); setReadMethod0(info.getReadMethod()); setWriteMethod0(info.getWriteMethod()); setPropertyType(info.getPropertyType()); setConstrained(info.isConstrained()); setBound(bound && info.is(PropertyInfo.Name.bound)); boolean isExpert = info.is(PropertyInfo.Name.expert); setValue(PropertyInfo.Name.expert.name(), isExpert); // compatibility setExpert(isExpert); boolean isHidden = info.is(PropertyInfo.Name.hidden); setValue(PropertyInfo.Name.hidden.name(), isHidden); // compatibility setHidden(isHidden); setPreferred(info.is(PropertyInfo.Name.preferred)); boolean isRequired = info.is(PropertyInfo.Name.required); setValue(PropertyInfo.Name.required.name(), isRequired); boolean visual = info.is(PropertyInfo.Name.visualUpdate); setValue(PropertyInfo.Name.visualUpdate.name(), visual); Object description = info.get(PropertyInfo.Name.description); if (description != null) { setShortDescription(description.toString()); } Object values = info.get(PropertyInfo.Name.enumerationValues); if (values != null) { setValue(PropertyInfo.Name.enumerationValues.name(), values); } this.baseName = base; }
// Static initializer. static { try { // Events. EventSetDescriptor event1 = new EventSetDescriptor( beanClass_, "propertyChange", PropertyChangeListener.class, "propertyChange"); event1.setDisplayName(rbl_.getText("EVT_NAME_PROPERTY_CHANGE")); event1.setShortDescription(rbl_.getText("EVT_DESC_PROPERTY_CHANGE")); EventSetDescriptor event2 = new EventSetDescriptor( beanClass_, "actionCompleted", ActionCompletedListener.class, "actionCompleted"); event2.setDisplayName(rbl_.getText("EVT_NAME_ACTION_COMPLETED")); event2.setShortDescription(rbl_.getText("EVT_DESC_ACTION_COMPLETED")); EventSetDescriptor event3 = new EventSetDescriptor( beanClass_, "propertyChange", VetoableChangeListener.class, "vetoableChange"); event3.setDisplayName(rbl_.getText("EVT_NAME_PROPERTY_VETO")); event3.setShortDescription(rbl_.getText("EVT_DESC_PROPERTY_VETO")); events_ = new EventSetDescriptor[] {event1, event2, event3}; // Properties. PropertyDescriptor classPath = new PropertyDescriptor("classPath", beanClass_, "getClassPath", "setClassPath"); classPath.setBound(true); classPath.setConstrained(true); classPath.setDisplayName(rbl_.getText("PROP_NAME_JAC_CLASSPATH")); classPath.setShortDescription(rbl_.getText("PROP_DESC_JAC_CLASSPATH")); PropertyDescriptor classPathSecurityChkLvl = new PropertyDescriptor( "securityCheckLevel", beanClass_, "getSecurityCheckLevel", "setSecurityCheckLevel"); classPathSecurityChkLvl.setBound(true); classPathSecurityChkLvl.setConstrained(true); classPathSecurityChkLvl.setDisplayName(rbl_.getText("PROP_NAME_JAC_SECCHKLVL")); classPathSecurityChkLvl.setShortDescription(rbl_.getText("PROP_DESC_JAC_SECCHKLVL")); PropertyDescriptor garbageCollectInitialSize = new PropertyDescriptor( "garbageCollectionInitialSize", beanClass_, "getGarbageCollectionInitialSize", "setGarbageCollectionInitialSize"); garbageCollectInitialSize.setBound(true); garbageCollectInitialSize.setConstrained(true); garbageCollectInitialSize.setDisplayName(rbl_.getText("PROP_NAME_JAC_GCINIT")); garbageCollectInitialSize.setShortDescription(rbl_.getText("PROP_DESC_JAC_GCINIT")); PropertyDescriptor garbageCollectMaximumSize = new PropertyDescriptor( "garbageCollectionMaximumSize", beanClass_, "getGarbageCollectionMaximumSize", "setGarbageCollectionMaximumSize"); garbageCollectMaximumSize.setBound(true); garbageCollectMaximumSize.setConstrained(true); garbageCollectMaximumSize.setDisplayName(rbl_.getText("PROP_NAME_JAC_GCMAX")); garbageCollectMaximumSize.setShortDescription(rbl_.getText("PROP_DESC_JAC_GCMAX")); PropertyDescriptor garbageCollectionFrequency = new PropertyDescriptor( "garbageCollectionFrequency", beanClass_, "getGarbageCollectionFrequency", "setGarbageCollectionFrequency"); garbageCollectionFrequency.setBound(true); garbageCollectionFrequency.setConstrained(true); garbageCollectionFrequency.setDisplayName(rbl_.getText("PROP_NAME_JAC_GCFREQ")); garbageCollectionFrequency.setShortDescription(rbl_.getText("PROP_DESC_JAC_GCFREQ")); PropertyDescriptor garbageCollectionPriority = new PropertyDescriptor( "garbageCollectionPriority", beanClass_, "getGarbageCollectionPriority", "setGarbageCollectionPriority"); garbageCollectionPriority.setBound(true); garbageCollectionPriority.setConstrained(true); garbageCollectionPriority.setDisplayName(rbl_.getText("PROP_NAME_JAC_GCPRIORITY")); garbageCollectionPriority.setShortDescription(rbl_.getText("PROP_DESC_JAC_GCPRIORITY")); PropertyDescriptor interpret = new PropertyDescriptor("interpret", beanClass_, "getInterpret", "setInterpret"); interpret.setBound(true); interpret.setConstrained(true); interpret.setDisplayName(rbl_.getText("PROP_NAME_JAC_INTERPRET")); interpret.setShortDescription(rbl_.getText("PROP_DESC_JAC_INTERPRET")); PropertyDescriptor javaApplication = new PropertyDescriptor( "javaApplication", beanClass_, "getJavaApplication", "setJavaApplication"); javaApplication.setBound(true); javaApplication.setConstrained(true); javaApplication.setDisplayName(rbl_.getText("PROP_NAME_JAC_JAVAAPP")); javaApplication.setShortDescription(rbl_.getText("PROP_DESC_JAC_JAVAAPP")); PropertyDescriptor optimization = new PropertyDescriptor("optimization", beanClass_, "getOptimization", "setOptimization"); optimization.setBound(true); optimization.setConstrained(true); optimization.setDisplayName(rbl_.getText("PROP_NAME_JAC_OPTIMIZE")); optimization.setShortDescription(rbl_.getText("PROP_DESC_JAC_OPTIMIZE")); PropertyDescriptor option = new PropertyDescriptor("option", beanClass_, "getOptions", "setOptions"); option.setBound(true); option.setConstrained(true); option.setDisplayName(rbl_.getText("PROP_NAME_JAC_OPTION")); option.setShortDescription(rbl_.getText("PROP_DESC_JAC_OPTION")); PropertyDescriptor parameters = new PropertyDescriptor("parameters", beanClass_, "getParameters", "setParameters"); parameters.setBound(true); parameters.setConstrained(true); parameters.setDisplayName(rbl_.getText("PROP_NAME_JAC_PARAMETERS")); parameters.setShortDescription(rbl_.getText("PROP_DESC_JAC_PARAMETERS")); PropertyDescriptor portSearch = new PropertyDescriptor("findPort", beanClass_, "isFindPort", "setFindPort"); portSearch.setBound(true); portSearch.setConstrained(true); portSearch.setDisplayName(rbl_.getText("PROP_NAME_JAC_PORTSEARCH")); portSearch.setShortDescription(rbl_.getText("PROP_DESC_JAC_PORTSEARCH")); properties_ = new PropertyDescriptor[] { classPath, classPathSecurityChkLvl, garbageCollectInitialSize, garbageCollectMaximumSize, garbageCollectionFrequency, garbageCollectionPriority, interpret, javaApplication, parameters, optimization, option, portSearch, }; } catch (IntrospectionException e) { throw new Error(e.toString()); } }
static { try { EventSetDescriptor changed = new EventSetDescriptor( beanClass, "propertyChange", java.beans.PropertyChangeListener.class, "propertyChange"); changed.setDisplayName(loader_.getText("EVT_NAME_PROPERTY_CHANGE")); changed.setShortDescription(loader_.getText("EVT_DESC_PROPERTY_CHANGE")); EventSetDescriptor veto = new EventSetDescriptor( beanClass, "propertyChange", java.beans.VetoableChangeListener.class, "vetoableChange"); veto.setDisplayName(loader_.getText("EVT_NAME_PROPERTY_VETO")); veto.setShortDescription(loader_.getText("EVT_DESC_PROPERTY_VETO")); EventSetDescriptor[] events = {changed, veto}; events_ = events; // ***** PROPERTIES PropertyDescriptor alignment = new PropertyDescriptor("alignment", beanClass, "getAlignment", "setAlignment"); alignment.setBound(true); alignment.setConstrained(true); alignment.setDisplayName(loader_.getText("PROP_NAME_ALIGNMENT")); alignment.setShortDescription(loader_.getText("PROP_HTBL_DESC_ALIGNMENT")); PropertyDescriptor borderWidth = new PropertyDescriptor("borderWidth", beanClass, "getBorderWidth", "setBorderWidth"); borderWidth.setBound(true); borderWidth.setConstrained(true); borderWidth.setDisplayName(loader_.getText("PROP_NAME_BORDERWIDTH")); borderWidth.setShortDescription(loader_.getText("PROP_DESC_BORDERWIDTH")); // PropertyDescriptor caption = new PropertyDescriptor("caption", beanClass, // "getCaption", "setCaption"); Class[] parameterList = {HTMLTableCaption.class}; PropertyDescriptor caption = new PropertyDescriptor( "caption", beanClass.getMethod("getCaption", (java.lang.Class[]) null), beanClass.getMethod("setCaption", parameterList)); // @pdc cast for jdk1.5 caption.setBound(true); caption.setConstrained(true); caption.setDisplayName(loader_.getText("PROP_NAME_CAPTION")); caption.setShortDescription(loader_.getText("PROP_DESC_CAPTION")); PropertyDescriptor cellPadding = new PropertyDescriptor("cellPadding", beanClass, "getCellPadding", "setCellPadding"); cellPadding.setBound(true); cellPadding.setConstrained(true); cellPadding.setDisplayName(loader_.getText("PROP_NAME_CELLPADDING")); cellPadding.setShortDescription(loader_.getText("PROP_DESC_CELLPADDING")); PropertyDescriptor cellSpacing = new PropertyDescriptor("cellSpacing", beanClass, "getCellSpacing", "setCellSpacing"); cellSpacing.setBound(true); cellSpacing.setConstrained(true); cellSpacing.setDisplayName(loader_.getText("PROP_NAME_CELLSPACING")); cellSpacing.setShortDescription(loader_.getText("PROP_DESC_CELLSPACING")); PropertyDescriptor header = new PropertyDescriptor("header", beanClass, "getHeader", "setHeader"); header.setBound(true); header.setConstrained(true); header.setDisplayName(loader_.getText("PROP_NAME_HEADER")); header.setShortDescription(loader_.getText("PROP_DESC_HEADER")); PropertyDescriptor useHeader = new PropertyDescriptor("headerInUse", beanClass, "isHeaderInUse", "setHeaderInUse"); useHeader.setBound(true); useHeader.setConstrained(true); useHeader.setDisplayName(loader_.getText("PROP_NAME_HEADERINUSE")); useHeader.setShortDescription(loader_.getText("PROP_DESC_HEADERINUSE")); PropertyDescriptor width = new PropertyDescriptor("width", beanClass, "getWidth", "setWidth"); width.setBound(true); width.setConstrained(true); width.setDisplayName(loader_.getText("PROP_NAME_WIDTH")); width.setShortDescription(loader_.getText("PROP_HTBL_DESC_WIDTH")); PropertyDescriptor widthInPercent = new PropertyDescriptor( "widthInPercent", beanClass, "isWidthInPercent", "setWidthInPercent"); widthInPercent.setBound(true); widthInPercent.setConstrained(true); widthInPercent.setDisplayName(loader_.getText("PROP_NAME_WPERCENT")); widthInPercent.setShortDescription(loader_.getText("PROP_HTBL_DESC_WPERCENT")); PropertyDescriptor lang = new PropertyDescriptor("lang", beanClass, "getLanguage", "setLanguage"); // $B1A lang.setBound(true); // $B1A lang.setConstrained(true); // $B1A lang.setDisplayName(loader_.getText("PROP_NAME_LANGUAGE")); // $B1A lang.setShortDescription(loader_.getText("PROP_DESC_LANGUAGE")); // $B1A PropertyDescriptor dir = new PropertyDescriptor("dir", beanClass, "getDirection", "setDirection"); // $B1A dir.setBound(true); // $B1A dir.setConstrained(true); // $B1A dir.setDisplayName(loader_.getText("PROP_NAME_DIRECTION")); // $B1A dir.setShortDescription(loader_.getText("PROP_DESC_DIRECTION")); // $B1A PropertyDescriptor useFO = new PropertyDescriptor("useFO", beanClass, "isUseFO", "setUseFO"); // @C1A useFO.setBound(true); // @C1A useFO.setConstrained(false); // @C1A useFO.setDisplayName(loader_.getText("PROP_NAME_FORMATTING_OBJECT")); // @C1A useFO.setShortDescription(loader_.getText("PROP_DESC_FORMATTING_OBJECT")); // @C1A properties_ = new PropertyDescriptor[] { alignment, borderWidth, caption, cellPadding, cellSpacing, header, useHeader, width, widthInPercent, lang, dir, useFO }; // $B1C //@C1A } catch (Exception e) { throw new Error(e.toString()); } }