KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > binding > Binding


1 /*
2  * $Id: Binding.java,v 1.1.1.1 2004/06/16 01:43:39 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.swing.binding;
9
10 import org.jdesktop.swing.data.DataModel;
11
12 import java.beans.PropertyChangeListener JavaDoc;
13
14 import javax.swing.JComponent JavaDoc;
15
16 /**
17  * Class which binds a user-interface component to a specific element
18  * in a data model. A Binding instance implements the following tasks:
19  * <ul>
20  * <li>pulls values from the data model into the UI component</li>
21  * <li>performs element-level validation on the value contained
22  * in the UI component to determine whether it can/should be
23  * pushed to the model.</li>
24  * <li>pushes validated values from the UI component to the data model.</li>
25  * </ul>
26  *
27  * @author Amy Fowler
28  * @version 1.0
29  */

30
31 public interface Binding {
32
33     public static final int AUTO_VALIDATE = 0;
34     public static final int AUTO_VALIDATE_STRICT = 1;
35     public static final int AUTO_VALIDATE_NONE = 2;
36
37     public static final int UNVALIDATED = 0;
38     public static final int VALID = 1;
39     public static final int INVALID = 2;
40
41     JComponent JavaDoc getComponent();
42
43     DataModel getDataModel();
44
45     String JavaDoc getFieldName();
46
47     /**
48      * Pulls the value of this binding's data model element
49      * into its UI component.
50      *
51      * @return boolean indicating whether or not the value was pulled from the
52      * data model
53      */

54     boolean pull();
55
56     /**
57      *
58      * @return boolean indicating whether or not the value contained in
59      * this binding's UI component has been modified since the
60      * value was last pushed or pulled
61      */

62     boolean isModified();
63
64     /**
65      * @return boolean indicating whether or not the value contained in
66      * this binding's UI component is valid
67      */

68     boolean isValid();
69
70     int getValidState();
71
72     /**
73      * Returns validation error messages generated from the most
74      * recent element-level validation pass.
75      *
76      * @return array containing any error messages which occurred during
77      * element-level validation
78      */

79     String JavaDoc[] getValidationErrors();
80
81     /**
82      * Pushes the current value contained in this binding's UI component
83      * to this binding's data model element. Only valid values
84      * should be pushed to the model.
85      * @return boolean indicating whether or not the value was pushed to the
86      * data model
87      */

88     boolean push();
89
90     void addPropertyChangeListener(PropertyChangeListener JavaDoc pcl);
91
92     void removePropertyChangeListener(PropertyChangeListener JavaDoc pcl);
93
94     PropertyChangeListener JavaDoc[] getPropertyChangeListeners();
95
96 }
97
Popular Tags