Line 65
Link Here
|
|
|
65 |
this (bean, findInfo (bean, propertyName)); |
66 |
} |
67 |
|
68 |
/** Creates new DefaultPropertyModel with provided specific |
69 |
* <code>PropertyDescriptor</code>. This can be useful if one needs to |
70 |
* set to provide specific attributes to the property editor. |
71 |
* <PRE> |
72 |
* PropertyDescriptor pd = new PropertyDescriptor ("myProperty", bean.getClass ()); |
73 |
* pd.setPropertyEditorClass (PropertyEditorManager.findEditor (Object.class)); |
74 |
* |
75 |
* // special attributes to the property editor |
76 |
* pb.setValue ("superClass", MyProperty.class); |
77 |
* |
78 |
* |
79 |
* model = new DefaultPropertyModel (bean, pd); |
80 |
* panel = new PropertyPanel (model); |
81 |
* </PRE> |
82 |
* This constructor replaces the default use of BeanInfo and that is why |
83 |
* simplifies the use of <link>ExPropertyEditor</link>s. |
84 |
* |
85 |
* @param bean the java bean to be introspected |
86 |
* @param descr the property descriptor of the property to use |
87 |
* |
88 |
* @since 2.4 |
89 |
*/ |
90 |
public DefaultPropertyModel(Object bean, PropertyDescriptor descr) { |
Line 68
Link Here
|
|
|
94 |
|
95 |
this.prop = descr; |
96 |
this.readMethod = descr.getReadMethod (); |
97 |
this.writeMethod = descr.getWriteMethod (); |
98 |
|
Line 75
Link Here
|
|
|
106 |
} |
107 |
catch (Exception e) { |
108 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); |
109 |
} |
110 |
} |
Line 76
Link Here
|
|
|
112 |
/** Finds property descriptor for a bean. |
113 |
* @param bean the bean |
114 |
* @param name name of the property to find |
115 |
* @return the descriptor |
116 |
* @exception IllegalArgumentException if the method is not found |
117 |
*/ |
118 |
private static PropertyDescriptor findInfo (Object bean, String name) |
119 |
throws IllegalArgumentException { |
120 |
try { |
Lines 79-84
Link Here
|
79 |
if (descr[i].getName().equals(propertyName)) { |
124 |
if (descr[i].getName().equals(name)) { |
80 |
prop = descr[i]; |
125 |
return descr[i]; |
81 |
propertyTypeClass = prop.getPropertyType(); |
|
|
82 |
readMethod = prop.getReadMethod(); |
83 |
writeMethod = prop.getWriteMethod(); |
84 |
break; |
85 |
-- |
Line 87
Link Here
|
|
|
128 |
throw new IllegalArgumentException ( |
129 |
"No property named " + name + " in class " + bean.getClass () // NOI18N |
130 |
); |
131 |
} catch (IntrospectionException e) { |
132 |
IllegalArgumentException newEx = new IllegalArgumentException(); |
133 |
ErrorManager.getDefault().annotate (newEx, e); |
134 |
throw newEx; |
Lines 88-93
Link Here
|
88 |
catch (Exception e) { |
|
|
89 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); |
90 |
} |
91 |
|
92 |
if (prop == null) |
93 |
throw new IllegalArgumentException(); |
Line 95
Link Here
|
95 |
|
137 |
|
96 |
-- |
|
|