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 processes a data binding when it receives a
10: * <code>PropertyChangeEvent</code>.
11: */
12: public class DataBindingListener implements PropertyChangeListener {
13: private JAXXObject object;
14: private String dest;
15:
16: /** Creates a new <code>DataBindingListener</code> which will run the given data binding
17: * when it receives a <code>PropertyChangeEvent</code>.
18: *
19: *@param object the object in which the data binding exists
20: *@param dest the name of the data binding to run
21: */
22: public DataBindingListener(JAXXObject object, String dest) {
23: this .object = object;
24: this .dest = dest;
25: }
26:
27: /** Processes the data binding in response to a <code>PropertyChangeEvent</code>.
28: *
29: *@param e the event which triggered the binding
30: */
31: public void propertyChange(PropertyChangeEvent e) {
32: object.processDataBinding(dest);
33:
34: // for now, handle dependency changes by always removing & reapplying
35: // the binding. We should be more efficient and only do this when it's
36: // actually necessary
37: object.removeDataBinding(dest);
38: object.applyDataBinding(dest);
39: }
40: }
|