|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
package org.ejtools.adwt;
|
|
8
|
|
|
|
9
|
|
import java.awt.Color;
|
|
10
|
|
import java.awt.Component;
|
|
11
|
|
import java.awt.Frame;
|
|
12
|
|
import java.awt.GridBagConstraints;
|
|
13
|
|
import java.awt.GridBagLayout;
|
|
14
|
|
import java.awt.Insets;
|
|
15
|
|
import java.awt.event.ActionEvent;
|
|
16
|
|
import java.awt.event.ActionListener;
|
|
17
|
|
import java.beans.BeanInfo;
|
|
18
|
|
import java.beans.Customizer;
|
|
19
|
|
import java.beans.Introspector;
|
|
20
|
|
import java.beans.MethodDescriptor;
|
|
21
|
|
import java.beans.PropertyChangeEvent;
|
|
22
|
|
import java.beans.PropertyChangeListener;
|
|
23
|
|
import java.beans.PropertyDescriptor;
|
|
24
|
|
import java.beans.PropertyEditor;
|
|
25
|
|
import java.beans.PropertyVetoException;
|
|
26
|
|
import java.lang.reflect.InvocationTargetException;
|
|
27
|
|
import java.lang.reflect.Method;
|
|
28
|
|
import java.util.StringTokenizer;
|
|
29
|
|
|
|
30
|
|
import javax.swing.JButton;
|
|
31
|
|
import javax.swing.JComponent;
|
|
32
|
|
import javax.swing.JLabel;
|
|
33
|
|
import javax.swing.JOptionPane;
|
|
34
|
|
import javax.swing.JPanel;
|
|
35
|
|
import javax.swing.SwingConstants;
|
|
36
|
|
import javax.swing.SwingUtilities;
|
|
37
|
|
|
|
38
|
|
import org.ejtools.adwt.editor.ArrayEditor;
|
|
39
|
|
import org.ejtools.beans.CustomPropertyEditorManager;
|
|
40
|
|
import org.ejtools.util.ClassTools;
|
|
41
|
|
|
|
42
|
|
import com.dreambean.awt.GenericMethodDialog;
|
|
43
|
|
import com.dreambean.awt.GenericPropertyCustomizer;
|
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
|
47
|
|
|
|
48
|
|
|
|
49
|
|
|
|
50
|
|
|
|
51
|
|
|
|
52
|
|
|
|
53
|
|
public class SimpleCustomizer extends JPanel implements Customizer
|
|
54
|
|
{
|
|
55
|
|
|
|
56
|
|
private MethodDescriptor md[];
|
|
57
|
|
|
|
58
|
|
private Object object;
|
|
59
|
|
|
|
60
|
|
private PropertyDescriptor pd[];
|
|
61
|
|
|
|
62
|
|
private JComponent previous;
|
|
63
|
|
|
|
64
|
|
|
|
65
|
|
|
|
66
|
0
|
public SimpleCustomizer()
|
|
67
|
|
{
|
|
68
|
0
|
super();
|
|
69
|
0
|
this.previous = null;
|
|
70
|
0
|
this.setLayout(new GridBagLayout());
|
|
71
|
|
}
|
|
72
|
|
|
|
73
|
|
|
|
74
|
|
|
|
75
|
|
|
|
76
|
|
|
|
77
|
|
|
|
78
|
|
|
|
79
|
0
|
public SimpleCustomizer(Object obj)
|
|
80
|
|
{
|
|
81
|
0
|
this();
|
|
82
|
0
|
this.setObject(obj);
|
|
83
|
|
}
|
|
84
|
|
|
|
85
|
|
|
|
86
|
|
|
|
87
|
|
|
|
88
|
|
|
|
89
|
|
|
|
90
|
|
|
|
91
|
0
|
public void setObject(Object obj)
|
|
92
|
|
{
|
|
93
|
0
|
try
|
|
94
|
|
{
|
|
95
|
0
|
this.removeAll();
|
|
96
|
|
|
|
97
|
0
|
if (obj == null)
|
|
98
|
|
{
|
|
99
|
0
|
this.validate();
|
|
100
|
0
|
this.repaint();
|
|
101
|
0
|
return;
|
|
102
|
|
}
|
|
103
|
0
|
this.object = obj;
|
|
104
|
|
|
|
105
|
0
|
GridBagConstraints gridbagconstraints = new GridBagConstraints();
|
|
106
|
0
|
gridbagconstraints.insets = new Insets(0, 0, 0, 0);
|
|
107
|
0
|
gridbagconstraints.anchor = GridBagConstraints.NORTH;
|
|
108
|
0
|
gridbagconstraints.weighty = 1.0D;
|
|
109
|
|
|
|
110
|
0
|
BeanInfo beaninfo;
|
|
111
|
0
|
if (obj instanceof BeanInfo)
|
|
112
|
|
{
|
|
113
|
0
|
beaninfo = (BeanInfo) obj;
|
|
114
|
|
}
|
|
115
|
|
else
|
|
116
|
|
{
|
|
117
|
0
|
beaninfo = Introspector.getBeanInfo(obj.getClass());
|
|
118
|
|
}
|
|
119
|
|
|
|
120
|
0
|
pd = beaninfo.getPropertyDescriptors();
|
|
121
|
0
|
if (pd != null)
|
|
122
|
|
{
|
|
123
|
0
|
if (beaninfo.getBeanDescriptor().getValue("propertyorder") == null)
|
|
124
|
|
{
|
|
125
|
0
|
for (int i = 0; i < pd.length; i++)
|
|
126
|
|
{
|
|
127
|
0
|
if (!pd[i].getReadMethod().getDeclaringClass().equals(Object.class) && !pd[i].isHidden())
|
|
128
|
|
{
|
|
129
|
0
|
PropertyEditor propertyeditor = null;
|
|
130
|
|
|
|
131
|
|
|
|
132
|
0
|
Class c = ClassTools.getClass(pd[i].getPropertyType().getName());
|
|
133
|
0
|
if (c == null)
|
|
134
|
|
{
|
|
135
|
0
|
this.addUnsupportedProperty(pd[i]);
|
|
136
|
|
}
|
|
137
|
|
else
|
|
138
|
|
{
|
|
139
|
|
|
|
140
|
0
|
Class clazz = pd[i].getPropertyEditorClass();
|
|
141
|
0
|
if (clazz != null)
|
|
142
|
|
{
|
|
143
|
0
|
propertyeditor = (PropertyEditor) clazz.newInstance();
|
|
144
|
|
}
|
|
145
|
|
|
|
146
|
|
|
|
147
|
0
|
if (pd[i].getPropertyType().isArray())
|
|
148
|
|
{
|
|
149
|
0
|
Class componentType = pd[i].getPropertyType().getComponentType();
|
|
150
|
0
|
propertyeditor = new ArrayEditor(componentType);
|
|
151
|
0
|
this.addProperty(pd[i], propertyeditor);
|
|
152
|
|
}
|
|
153
|
|
else
|
|
154
|
|
{
|
|
155
|
0
|
if (propertyeditor == null)
|
|
156
|
|
{
|
|
157
|
0
|
propertyeditor = CustomPropertyEditorManager.findEditor(pd[i].getPropertyType());
|
|
158
|
|
}
|
|
159
|
0
|
if (propertyeditor == null)
|
|
160
|
|
{
|
|
161
|
0
|
propertyeditor = CustomPropertyEditorManager.findEditor(String.class);
|
|
162
|
|
}
|
|
163
|
0
|
this.addProperty(pd[i], propertyeditor);
|
|
164
|
|
}
|
|
165
|
0
|
gridbagconstraints.weighty = 1.0D;
|
|
166
|
|
}
|
|
167
|
|
}
|
|
168
|
|
}
|
|
169
|
|
}
|
|
170
|
|
else
|
|
171
|
|
{
|
|
172
|
0
|
for (StringTokenizer stringtokenizer = new StringTokenizer((String) beaninfo.getBeanDescriptor().getValue("propertyorder"), ":"); stringtokenizer.hasMoreTokens(); )
|
|
173
|
|
{
|
|
174
|
0
|
String s = stringtokenizer.nextToken();
|
|
175
|
0
|
for (int k = 0; k < pd.length; k++)
|
|
176
|
|
{
|
|
177
|
0
|
if (pd[k].getName().equals(s) && !pd[k].isHidden())
|
|
178
|
|
{
|
|
179
|
0
|
PropertyEditor propertyeditor1 = null;
|
|
180
|
|
|
|
181
|
|
|
|
182
|
0
|
Class c = ClassTools.getClass(pd[k].getPropertyType().getName());
|
|
183
|
0
|
if (c == null)
|
|
184
|
|
{
|
|
185
|
0
|
this.addUnsupportedProperty(pd[k]);
|
|
186
|
|
}
|
|
187
|
|
else
|
|
188
|
|
{
|
|
189
|
|
|
|
190
|
0
|
Class clazz = pd[k].getPropertyEditorClass();
|
|
191
|
0
|
if (clazz != null)
|
|
192
|
|
{
|
|
193
|
0
|
propertyeditor1 = (PropertyEditor) clazz.newInstance();
|
|
194
|
|
}
|
|
195
|
|
|
|
196
|
|
|
|
197
|
0
|
if (pd[k].getPropertyType().isArray())
|
|
198
|
|
{
|
|
199
|
0
|
Class componentType = pd[k].getPropertyType().getComponentType();
|
|
200
|
0
|
propertyeditor1 = new ArrayEditor(componentType);
|
|
201
|
0
|
this.addProperty(pd[k], propertyeditor1);
|
|
202
|
|
}
|
|
203
|
|
else
|
|
204
|
|
{
|
|
205
|
0
|
if (propertyeditor1 == null)
|
|
206
|
|
{
|
|
207
|
0
|
propertyeditor1 = CustomPropertyEditorManager.findEditor(pd[k].getPropertyType());
|
|
208
|
|
}
|
|
209
|
0
|
if (propertyeditor1 == null)
|
|
210
|
|
{
|
|
211
|
0
|
propertyeditor1 = CustomPropertyEditorManager.findEditor(String.class);
|
|
212
|
|
}
|
|
213
|
0
|
this.addProperty(pd[k], propertyeditor1);
|
|
214
|
|
}
|
|
215
|
0
|
gridbagconstraints.weighty = 1.0D;
|
|
216
|
|
}
|
|
217
|
|
}
|
|
218
|
|
}
|
|
219
|
|
}
|
|
220
|
|
}
|
|
221
|
|
}
|
|
222
|
|
|
|
223
|
0
|
md = beaninfo.getMethodDescriptors();
|
|
224
|
|
|
|
225
|
0
|
gridbagconstraints.weighty = 1.0D;
|
|
226
|
0
|
gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
|
|
227
|
0
|
gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
228
|
|
|
|
229
|
0
|
if (md != null)
|
|
230
|
|
{
|
|
231
|
0
|
for (int j = 0; j < md.length; j++)
|
|
232
|
|
{
|
|
233
|
0
|
if (!md[j].getName().startsWith("get")
|
|
234
|
|
&& !md[j].getName().startsWith("set")
|
|
235
|
|
&& !md[j].getName().startsWith("is"))
|
|
236
|
|
{
|
|
237
|
0
|
JButton jbutton = new JButton(md[j].getDisplayName());
|
|
238
|
0
|
jbutton.setToolTipText(md[j].getShortDescription());
|
|
239
|
0
|
this.add(jbutton, gridbagconstraints);
|
|
240
|
0
|
jbutton.addActionListener(new MethodInvoker(md[j]));
|
|
241
|
|
}
|
|
242
|
|
}
|
|
243
|
|
}
|
|
244
|
|
|
|
245
|
0
|
this.validate();
|
|
246
|
0
|
this.repaint();
|
|
247
|
|
}
|
|
248
|
|
catch (Exception exception)
|
|
249
|
|
{
|
|
250
|
0
|
exception.printStackTrace();
|
|
251
|
|
}
|
|
252
|
|
}
|
|
253
|
|
|
|
254
|
|
|
|
255
|
|
|
|
256
|
|
|
|
257
|
|
|
|
258
|
|
|
|
259
|
|
|
|
260
|
|
|
|
261
|
0
|
protected void addProperty(PropertyDescriptor propertydescriptor, PropertyEditor propertyeditor)
|
|
262
|
|
{
|
|
263
|
0
|
GridBagConstraints gridbagconstraints = new GridBagConstraints();
|
|
264
|
0
|
gridbagconstraints.insets = new Insets(3, 3, 3, 3);
|
|
265
|
|
|
|
266
|
0
|
try
|
|
267
|
|
{
|
|
268
|
0
|
Object obj = propertydescriptor.getReadMethod().invoke(object, new Object[0]);
|
|
269
|
0
|
if (obj != null)
|
|
270
|
|
{
|
|
271
|
0
|
propertyeditor.setValue(obj);
|
|
272
|
|
}
|
|
273
|
0
|
if (!obj.equals(propertyeditor.getValue()))
|
|
274
|
|
{
|
|
275
|
0
|
propertydescriptor.getWriteMethod().invoke(object, new Object[]{
|
|
276
|
|
propertyeditor.getValue()
|
|
277
|
|
});
|
|
278
|
|
}
|
|
279
|
|
}
|
|
280
|
|
catch (Throwable throwable)
|
|
281
|
|
{
|
|
282
|
0
|
throwable.printStackTrace();
|
|
283
|
|
}
|
|
284
|
|
|
|
285
|
0
|
JLabel jlabel = new JLabel(propertydescriptor.getDisplayName() + " : ", SwingConstants.RIGHT);
|
|
286
|
0
|
jlabel.setToolTipText(propertydescriptor.getShortDescription());
|
|
287
|
|
|
|
288
|
0
|
gridbagconstraints.anchor = GridBagConstraints.NORTH;
|
|
289
|
0
|
gridbagconstraints.weightx = 0.0D;
|
|
290
|
0
|
gridbagconstraints.weighty = 1.0D;
|
|
291
|
0
|
gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
|
|
292
|
0
|
gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
293
|
|
|
|
294
|
0
|
this.add(jlabel, gridbagconstraints);
|
|
295
|
0
|
Object obj1;
|
|
296
|
0
|
if (propertyeditor.supportsCustomEditor())
|
|
297
|
|
{
|
|
298
|
0
|
obj1 = propertyeditor.getCustomEditor();
|
|
299
|
0
|
if (obj1 instanceof JComponent)
|
|
300
|
|
{
|
|
301
|
0
|
if (previous != null)
|
|
302
|
|
{
|
|
303
|
0
|
previous.setNextFocusableComponent(((Component) (obj1)));
|
|
304
|
|
}
|
|
305
|
0
|
previous = (JComponent) obj1;
|
|
306
|
|
}
|
|
307
|
|
}
|
|
308
|
|
else
|
|
309
|
|
{
|
|
310
|
0
|
String as[] = propertyeditor.getTags();
|
|
311
|
0
|
if (as != null)
|
|
312
|
|
{
|
|
313
|
0
|
obj1 = new GenericPropertyCustomizer(propertyeditor, as);
|
|
314
|
0
|
if (previous != null)
|
|
315
|
|
{
|
|
316
|
0
|
previous.setNextFocusableComponent(((Component) (obj1)));
|
|
317
|
|
}
|
|
318
|
0
|
previous = (JComponent) obj1;
|
|
319
|
|
}
|
|
320
|
0
|
else if (propertydescriptor.getWriteMethod() != null)
|
|
321
|
|
{
|
|
322
|
0
|
obj1 = new GenericPropertyCustomizer(propertyeditor);
|
|
323
|
0
|
if (previous != null)
|
|
324
|
|
{
|
|
325
|
0
|
previous.setNextFocusableComponent(((Component) (obj1)));
|
|
326
|
|
}
|
|
327
|
0
|
previous = (JComponent) obj1;
|
|
328
|
|
}
|
|
329
|
|
else
|
|
330
|
|
{
|
|
331
|
0
|
final JLabel lbl = new JLabel(propertyeditor.getAsText());
|
|
332
|
0
|
final PropertyEditor pcEditor = propertyeditor;
|
|
333
|
0
|
obj1 = lbl;
|
|
334
|
0
|
pcEditor.addPropertyChangeListener(
|
|
335
|
|
new PropertyChangeListener()
|
|
336
|
|
{
|
|
337
|
0
|
public void propertyChange(PropertyChangeEvent propertychangeevent)
|
|
338
|
|
{
|
|
339
|
0
|
lbl.setText(pcEditor.getAsText());
|
|
340
|
|
}
|
|
341
|
|
});
|
|
342
|
|
}
|
|
343
|
|
}
|
|
344
|
|
|
|
345
|
0
|
gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
|
|
346
|
0
|
gridbagconstraints.weightx = 1.0D;
|
|
347
|
|
|
|
348
|
0
|
this.add(((Component) (obj1)), gridbagconstraints);
|
|
349
|
|
|
|
350
|
0
|
if (propertydescriptor.getWriteMethod() != null)
|
|
351
|
|
{
|
|
352
|
0
|
propertyeditor.addPropertyChangeListener(new BeanUpdater(propertydescriptor));
|
|
353
|
|
}
|
|
354
|
0
|
try
|
|
355
|
|
{
|
|
356
|
0
|
Method method = object.getClass().getMethod("addPropertyChangeListener", new Class[]{java.lang.String.class, java.beans.PropertyChangeListener.class});
|
|
357
|
0
|
method.invoke(object, new Object[]{propertydescriptor.getName(), new EditorUpdater(propertyeditor, propertydescriptor.getName())});
|
|
358
|
|
}
|
|
359
|
|
catch (Exception _ex)
|
|
360
|
|
{
|
|
361
|
0
|
try
|
|
362
|
|
{
|
|
363
|
0
|
Method method1 = object.getClass().getMethod("addPropertyChangeListener", new Class[]{java.beans.PropertyChangeListener.class});
|
|
364
|
0
|
method1.invoke(object, new Object[]{new EditorUpdater(propertyeditor, propertydescriptor)});
|
|
365
|
|
}
|
|
366
|
|
catch (Exception _ex2)
|
|
367
|
|
{
|
|
368
|
0
|
System.out.println("Exception occurred");
|
|
369
|
0
|
_ex2.printStackTrace();
|
|
370
|
|
}
|
|
371
|
|
}
|
|
372
|
|
}
|
|
373
|
|
|
|
374
|
|
|
|
375
|
|
|
|
376
|
|
|
|
377
|
|
|
|
378
|
|
|
|
379
|
|
|
|
380
|
0
|
protected void addUnsupportedProperty(PropertyDescriptor propertydescriptor)
|
|
381
|
|
{
|
|
382
|
0
|
GridBagConstraints gridbagconstraints = new GridBagConstraints();
|
|
383
|
0
|
gridbagconstraints.insets = new Insets(3, 3, 3, 3);
|
|
384
|
|
|
|
385
|
0
|
JLabel jlabel = new JLabel(propertydescriptor.getName() + " : ", SwingConstants.RIGHT);
|
|
386
|
0
|
jlabel.setToolTipText(propertydescriptor.getShortDescription());
|
|
387
|
0
|
jlabel.setForeground(Color.black);
|
|
388
|
|
|
|
389
|
0
|
gridbagconstraints.anchor = GridBagConstraints.NORTH;
|
|
390
|
0
|
gridbagconstraints.weightx = 0.0D;
|
|
391
|
0
|
gridbagconstraints.weighty = 1.0D;
|
|
392
|
0
|
gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
|
|
393
|
0
|
gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
394
|
|
|
|
395
|
0
|
this.add(jlabel, gridbagconstraints);
|
|
396
|
|
|
|
397
|
|
|
|
398
|
0
|
JLabel lbl = new JLabel("customizer.text.unloadable.class" + " " + ClassTools.classDisplay(propertydescriptor.getPropertyType().getName()));
|
|
399
|
0
|
lbl.setForeground(AwtToolkit.DARK_RED);
|
|
400
|
|
|
|
401
|
0
|
gridbagconstraints.weightx = 1.0D;
|
|
402
|
0
|
gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
|
|
403
|
|
|
|
404
|
0
|
this.add(lbl, gridbagconstraints);
|
|
405
|
|
}
|
|
406
|
|
|
|
407
|
|
|
|
408
|
|
|
|
409
|
|
|
|
410
|
|
|
|
411
|
|
|
|
412
|
|
|
|
413
|
|
|
|
414
|
|
|
|
415
|
0
|
protected void updated(String name, Object oldValue, Object newValue)
|
|
416
|
|
{
|
|
417
|
0
|
this.firePropertyChange(name, oldValue, newValue);
|
|
418
|
|
}
|
|
419
|
|
|
|
420
|
|
|
|
421
|
|
|
|
422
|
|
|
|
423
|
|
|
|
424
|
|
|
|
425
|
|
|
|
426
|
|
|
|
427
|
|
|
|
428
|
|
protected class BeanUpdater implements PropertyChangeListener
|
|
429
|
|
{
|
|
430
|
|
|
|
431
|
|
protected PropertyDescriptor propertyDescriptor;
|
|
432
|
|
|
|
433
|
|
|
|
434
|
|
|
|
435
|
|
|
|
436
|
|
|
|
437
|
|
|
|
438
|
|
|
|
439
|
0
|
public BeanUpdater(PropertyDescriptor propertyDescriptor)
|
|
440
|
|
{
|
|
441
|
0
|
this.propertyDescriptor = propertyDescriptor;
|
|
442
|
|
}
|
|
443
|
|
|
|
444
|
|
|
|
445
|
|
|
|
446
|
|
|
|
447
|
|
|
|
448
|
|
|
|
449
|
|
|
|
450
|
0
|
public void propertyChange(PropertyChangeEvent event)
|
|
451
|
|
{
|
|
452
|
0
|
try
|
|
453
|
|
{
|
|
454
|
0
|
Object oldValue = this.propertyDescriptor.getReadMethod().invoke(object, new Object[0]);
|
|
455
|
0
|
Object newValue = ((PropertyEditor) event.getSource()).getValue();
|
|
456
|
0
|
this.propertyDescriptor.getWriteMethod().invoke(object, new Object[]{newValue});
|
|
457
|
0
|
SimpleCustomizer.this.updated(this.propertyDescriptor.getName(), oldValue, newValue);
|
|
458
|
|
}
|
|
459
|
|
catch (InvocationTargetException invocationtargetexception)
|
|
460
|
|
{
|
|
461
|
0
|
if (invocationtargetexception.getTargetException() instanceof PropertyVetoException)
|
|
462
|
|
{
|
|
463
|
0
|
JOptionPane.showMessageDialog((Frame) SwingUtilities.windowForComponent(SimpleCustomizer.this), "Could not change value:" + invocationtargetexception.getTargetException().getMessage(), "Error", 0);
|
|
464
|
|
}
|
|
465
|
|
}
|
|
466
|
|
catch (Exception exception)
|
|
467
|
|
{
|
|
468
|
0
|
System.err.println(exception);
|
|
469
|
|
}
|
|
470
|
|
}
|
|
471
|
|
}
|
|
472
|
|
|
|
473
|
|
|
|
474
|
|
|
|
475
|
|
|
|
476
|
|
|
|
477
|
|
|
|
478
|
|
|
|
479
|
|
|
|
480
|
|
protected class EditorUpdater implements PropertyChangeListener
|
|
481
|
|
{
|
|
482
|
|
|
|
483
|
|
protected PropertyDescriptor pd;
|
|
484
|
|
|
|
485
|
|
protected String propName;
|
|
486
|
|
|
|
487
|
|
protected PropertyEditor propertyEditor;
|
|
488
|
|
|
|
489
|
|
|
|
490
|
|
|
|
491
|
|
|
|
492
|
|
|
|
493
|
|
|
|
494
|
|
|
|
495
|
|
|
|
496
|
0
|
public EditorUpdater(PropertyEditor propertyeditor, PropertyDescriptor propertydescriptor)
|
|
497
|
|
{
|
|
498
|
0
|
this.propName = null;
|
|
499
|
0
|
this.propertyEditor = propertyeditor;
|
|
500
|
0
|
pd = propertydescriptor;
|
|
501
|
|
}
|
|
502
|
|
|
|
503
|
|
|
|
504
|
|
|
|
505
|
|
|
|
506
|
|
|
|
507
|
|
|
|
508
|
|
|
|
509
|
|
|
|
510
|
0
|
public EditorUpdater(PropertyEditor propertyeditor, String s)
|
|
511
|
|
{
|
|
512
|
0
|
this.propName = null;
|
|
513
|
0
|
this.propertyEditor = propertyeditor;
|
|
514
|
0
|
propName = s;
|
|
515
|
|
}
|
|
516
|
|
|
|
517
|
|
|
|
518
|
|
|
|
519
|
|
|
|
520
|
|
|
|
521
|
|
|
|
522
|
|
|
|
523
|
0
|
public void propertyChange(PropertyChangeEvent propertychangeevent)
|
|
524
|
|
{
|
|
525
|
0
|
if (this.propName != null && propertychangeevent.getPropertyName() != null && !propertychangeevent.getPropertyName().equals(this.propName))
|
|
526
|
|
{
|
|
527
|
0
|
return;
|
|
528
|
|
}
|
|
529
|
0
|
if (propertychangeevent.getPropertyName() != null)
|
|
530
|
|
{
|
|
531
|
0
|
if (!this.propertyEditor.getValue().equals(propertychangeevent.getNewValue()))
|
|
532
|
|
{
|
|
533
|
0
|
this.propertyEditor.setValue(propertychangeevent.getNewValue());
|
|
534
|
|
}
|
|
535
|
|
}
|
|
536
|
|
else
|
|
537
|
|
{
|
|
538
|
0
|
try
|
|
539
|
|
{
|
|
540
|
0
|
Object obj = pd.getReadMethod().invoke(propertychangeevent.getSource(), new Object[0]);
|
|
541
|
0
|
if (obj != null && !obj.equals(this.propertyEditor.getValue()))
|
|
542
|
|
{
|
|
543
|
0
|
this.propertyEditor.setValue(obj);
|
|
544
|
|
}
|
|
545
|
|
}
|
|
546
|
|
catch (Exception exception)
|
|
547
|
|
{
|
|
548
|
|
|
|
549
|
|
}
|
|
550
|
|
}
|
|
551
|
|
}
|
|
552
|
|
}
|
|
553
|
|
|
|
554
|
|
|
|
555
|
|
|
|
556
|
|
|
|
557
|
|
|
|
558
|
|
|
|
559
|
|
|
|
560
|
|
|
|
561
|
|
protected class MethodInvoker implements ActionListener
|
|
562
|
|
{
|
|
563
|
|
|
|
564
|
|
protected MethodDescriptor methodDescriptor;
|
|
565
|
|
|
|
566
|
|
|
|
567
|
|
|
|
568
|
|
|
|
569
|
|
|
|
570
|
|
|
|
571
|
|
|
|
572
|
0
|
public MethodInvoker(MethodDescriptor methodDescriptor)
|
|
573
|
|
{
|
|
574
|
0
|
this.methodDescriptor = methodDescriptor;
|
|
575
|
|
}
|
|
576
|
|
|
|
577
|
|
|
|
578
|
|
|
|
579
|
|
|
|
580
|
|
|
|
581
|
|
|
|
582
|
|
|
|
583
|
0
|
public void actionPerformed(ActionEvent actionevent)
|
|
584
|
|
{
|
|
585
|
0
|
Object obj;
|
|
586
|
0
|
for (obj = this; !(obj instanceof Frame); obj = ((Component) (obj)).getParent())
|
|
587
|
|
{
|
|
588
|
|
;
|
|
589
|
|
}
|
|
590
|
0
|
if (this.methodDescriptor.getParameterDescriptors() == null
|
|
591
|
|
&& this.methodDescriptor.getMethod().getParameterTypes().length == 0
|
|
592
|
|
|| this.methodDescriptor.getParameterDescriptors() != null
|
|
593
|
|
&& this.methodDescriptor.getParameterDescriptors().length == 0)
|
|
594
|
|
{
|
|
595
|
0
|
try
|
|
596
|
|
{
|
|
597
|
0
|
this.methodDescriptor.getMethod().invoke(object, new Object[0]);
|
|
598
|
|
}
|
|
599
|
|
catch (InvocationTargetException invocationtargetexception)
|
|
600
|
|
{
|
|
601
|
0
|
invocationtargetexception.getTargetException().printStackTrace();
|
|
602
|
0
|
JOptionPane.showMessageDialog(((Component) (obj)), invocationtargetexception.getTargetException().getMessage(), "Error", 0);
|
|
603
|
|
}
|
|
604
|
|
catch (Exception exception)
|
|
605
|
|
{
|
|
606
|
0
|
System.err.println(exception);
|
|
607
|
0
|
JOptionPane.showMessageDialog(((Component) (obj)), "An exception occured. Check log for details", "Error", 0);
|
|
608
|
|
}
|
|
609
|
|
}
|
|
610
|
|
else
|
|
611
|
|
{
|
|
612
|
0
|
new GenericMethodDialog(object, this.methodDescriptor, (Frame) obj);
|
|
613
|
|
}
|
|
614
|
|
}
|
|
615
|
|
}
|
|
616
|
|
}
|
|
617
|
|
|
|
618
|
|
|