Lines 28-33
Link Here
|
28 |
*/ |
28 |
*/ |
29 |
public class JFaceProperty extends SimpleValueProperty { |
29 |
public class JFaceProperty extends SimpleValueProperty { |
30 |
|
30 |
|
|
|
31 |
private final Class sourceType; |
31 |
private Class returnType; |
32 |
private Class returnType; |
32 |
private Method setterMethod; |
33 |
private Method setterMethod; |
33 |
private Method getterMethod; |
34 |
private Method getterMethod; |
Lines 92-120
Link Here
|
92 |
} |
93 |
} |
93 |
|
94 |
|
94 |
/** |
95 |
/** |
|
|
96 |
* @param sourceType |
95 |
* @param fieldName |
97 |
* @param fieldName |
96 |
* @param property |
98 |
* @param property |
97 |
* @param clazz |
|
|
98 |
*/ |
99 |
*/ |
99 |
public JFaceProperty(String fieldName, String property, Class clazz) { |
100 |
public JFaceProperty(Class sourceType, String fieldName, String property) { |
|
|
101 |
this.sourceType = sourceType; |
100 |
this.property = property; |
102 |
this.property = property; |
101 |
// Create all the necessary method ahead of time to ensure they are |
103 |
// Create all the necessary method ahead of time to ensure they are |
102 |
// available |
104 |
// available |
103 |
try { |
105 |
try { |
104 |
try { |
106 |
try { |
105 |
String getterName = getGetterName(fieldName); |
107 |
String getterName = getGetterName(fieldName); |
106 |
getterMethod = clazz.getMethod(getterName, new Class[] {}); |
108 |
getterMethod = sourceType.getMethod(getterName, new Class[] {}); |
107 |
} catch (NoSuchMethodException e) { |
109 |
} catch (NoSuchMethodException e) { |
108 |
String getterName = getBooleanGetterName(fieldName); |
110 |
String getterName = getBooleanGetterName(fieldName); |
109 |
getterMethod = clazz.getMethod(getterName, new Class[] {}); |
111 |
getterMethod = sourceType.getMethod(getterName, new Class[] {}); |
110 |
} |
112 |
} |
111 |
returnType = getterMethod.getReturnType(); |
113 |
returnType = getterMethod.getReturnType(); |
112 |
setterMethod = clazz.getMethod(getSetterName(fieldName), |
114 |
setterMethod = sourceType.getMethod(getSetterName(fieldName), |
113 |
new Class[] { returnType }); |
115 |
new Class[] { returnType }); |
114 |
addPropertyListenerMethod = clazz |
116 |
addPropertyListenerMethod = sourceType |
115 |
.getMethod( |
117 |
.getMethod( |
116 |
"addPropertyChangeListener", new Class[] { IPropertyChangeListener.class }); //$NON-NLS-1$ |
118 |
"addPropertyChangeListener", new Class[] { IPropertyChangeListener.class }); //$NON-NLS-1$ |
117 |
removePropertyListenerMethod = clazz |
119 |
removePropertyListenerMethod = sourceType |
118 |
.getMethod( |
120 |
.getMethod( |
119 |
"removePropertyChangeListener", new Class[] { IPropertyChangeListener.class }); //$NON-NLS-1$ |
121 |
"removePropertyChangeListener", new Class[] { IPropertyChangeListener.class }); //$NON-NLS-1$ |
120 |
} catch (SecurityException e) { |
122 |
} catch (SecurityException e) { |
Lines 124-129
Link Here
|
124 |
} |
126 |
} |
125 |
} |
127 |
} |
126 |
|
128 |
|
|
|
129 |
public Object getSourceType() { |
130 |
return sourceType; |
131 |
} |
132 |
|
127 |
public INativePropertyListener adaptListener( |
133 |
public INativePropertyListener adaptListener( |
128 |
ISimplePropertyListener listener) { |
134 |
ISimplePropertyListener listener) { |
129 |
return new Listener(listener); |
135 |
return new Listener(listener); |