01: /*
02: * Copyright 2006 Ethan Nicholas. All rights reserved.
03: * Use is subject to license terms.
04: */
05: package jaxx.runtime;
06:
07: import java.beans.*;
08:
09: /** A <code>PropertyChangeListener</code> which removes and re-applies a data binding
10: * when it receives a <code>PropertyChangeEvent</code>.
11: */
12: public class DataBindingUpdateListener implements
13: PropertyChangeListener {
14: private JAXXObject object;
15: private String dest;
16:
17: /** Creates a new <code>DataBindingUpdateListener</code> which will remove and re-apply a
18: * data binding when it receives a <code>PropertyChangeEvent</code>.
19: *
20: *@param object the object in which the data binding exists
21: *@param dest the name of the data binding to reapply
22: */
23: public DataBindingUpdateListener(JAXXObject object, String dest) {
24: this .object = object;
25: this .dest = dest;
26: }
27:
28: public String getBindingName() {
29: return dest;
30: }
31:
32: /** Updates the data binding in response to a <code>PropertyChangeEvent</code>.
33: *
34: *@param e the event which triggered the binding
35: */
36: public void propertyChange(PropertyChangeEvent e) {
37: object.removeDataBinding(dest);
38: object.applyDataBinding(dest);
39: }
40: }
|