org.jdesktop.binding.swingx
Class AbstractBinding

java.lang.Object
  extended by org.jdesktop.binding.swingx.AbstractBinding
All Implemented Interfaces:
Binding
Direct Known Subclasses:
BooleanBinding, ComboBoxBinding, DatePickerBinding, DirectListBinding, DirectTableBinding, FormBinding, HyperlinkBinding, ImagePanelBinding, LabelBinding, LabelMetaBinding, ListBinding, RadioBinding, SpinnerBinding, TableBinding, TextBinding

public abstract class AbstractBinding
extends java.lang.Object
implements Binding

Abstract base class which implements a default mechanism for binding user-interface components to elements in a data model. Note:

Version:
1.0
Author:
Amy Fowler

Field Summary
protected  java.lang.Object cachedValue
           
protected  DataModel dataModel
           
protected  java.util.ArrayList errorList
           
protected  java.lang.String fieldName
           
protected  MetaData metaData
           
protected  boolean modified
           
protected  boolean pulling
           
protected  boolean pushing
           
protected  int validState
           
 
Fields inherited from interface org.jdesktop.binding.swingx.Binding
AUTO_VALIDATE, AUTO_VALIDATE_NONE, AUTO_VALIDATE_STRICT, INVALID, UNVALIDATED, VALID
 
Constructor Summary
protected AbstractBinding(javax.swing.JComponent component, DataModel dataModel, java.lang.String fieldName, int validationPolicy)
           
 
Method Summary
protected  void addError(java.lang.String error)
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Adds the specified property change listener to this binding object.
protected  void checkNull(java.lang.Object component, java.lang.String message)
           
protected  boolean checkRequired(java.lang.Object componentValue)
           
 void clearValidationErrors()
           
protected  java.lang.String convertFromModelType(java.lang.Object modelValue)
           
protected  java.lang.Object convertToModelType(java.lang.Object componentValue)
           
protected  boolean executeValidators(java.lang.Object value)
           
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
           
protected abstract  java.lang.Object getComponentValue()
           
 DataModel getDataModel()
           
 java.lang.String getFieldName()
           
 java.beans.PropertyChangeListener[] getPropertyChangeListeners()
           
 java.lang.String[] getValidationErrors()
          Returns validation error messages generated from the most recent element-level validation pass.
 int getValidationPolicy()
           
 int getValidState()
           
protected  void installDataModel(DataModel dataModel, java.lang.String fieldName)
           
protected  void installDataModelListener()
           
protected  void installInputVerifier()
          installs an InputVerifier depending on validationPolicy.
protected  void installMetaDataListener()
          here: does nothing
protected  boolean isEmpty(java.lang.Object componentValue)
           
 boolean isModified()
           
 boolean isValid()
           
 boolean pull()
          Pulls the value of this binding's data model element into its UI component.
 boolean push()
          Pushes the current value contained in this binding's UI component to this binding's data model element.
 void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Removes the specified property change listener from this binding object.
protected abstract  void setComponent(javax.swing.JComponent component)
          set component and configures metaData dependent logic/constraint state.
protected abstract  void setComponentValue(java.lang.Object value)
           
protected  void setModified(boolean modified)
           
 void setValidationPolicy(int policy)
           
protected  void setValidState(int validState)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jdesktop.binding.swingx.Binding
getComponent
 

Field Detail

dataModel

protected DataModel dataModel

metaData

protected MetaData metaData

fieldName

protected java.lang.String fieldName

cachedValue

protected java.lang.Object cachedValue

errorList

protected java.util.ArrayList errorList

modified

protected boolean modified

validState

protected int validState

pulling

protected boolean pulling

pushing

protected boolean pushing
Constructor Detail

AbstractBinding

protected AbstractBinding(javax.swing.JComponent component,
                          DataModel dataModel,
                          java.lang.String fieldName,
                          int validationPolicy)
Parameters:
component -
dataModel -
fieldName -
validationPolicy -
Throws:
java.lang.NullPointerException - if component, dataModel or fieldName is null
Method Detail

getDataModel

public DataModel getDataModel()
Specified by:
getDataModel in interface Binding

getFieldName

public java.lang.String getFieldName()
Specified by:
getFieldName in interface Binding

setValidationPolicy

public void setValidationPolicy(int policy)
Parameters:
policy -

getValidationPolicy

public int getValidationPolicy()

pull

public boolean pull()
Description copied from interface: Binding
Pulls the value of this binding's data model element into its UI component.

Specified by:
pull in interface Binding
Returns:
boolean indicating whether or not the value was pulled from the data model

push

public boolean push()
Description copied from interface: Binding
Pushes the current value contained in this binding's UI component to this binding's data model element. Only valid values should be pushed to the model.

Specified by:
push in interface Binding
Returns:
boolean indicating whether or not the value was pushed to the data model

isModified

public boolean isModified()
Specified by:
isModified in interface Binding
Returns:
boolean indicating whether or not the value contained in this binding's UI component has been modified since the value was last pushed or pulled

isValid

public boolean isValid()
Specified by:
isValid in interface Binding
Returns:
boolean indicating whether or not the value contained in this binding's UI component is valid

getValidState

public int getValidState()
Specified by:
getValidState in interface Binding

getValidationErrors

public java.lang.String[] getValidationErrors()
Description copied from interface: Binding
Returns validation error messages generated from the most recent element-level validation pass.

Specified by:
getValidationErrors in interface Binding
Returns:
array containing any error messages which occurred during element-level validation

clearValidationErrors

public void clearValidationErrors()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Adds the specified property change listener to this binding object.

Specified by:
addPropertyChangeListener in interface Binding
Parameters:
pcl - PropertyChangeListener object to receive events when binding properties change

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Removes the specified property change listener from this binding object.

Specified by:
removePropertyChangeListener in interface Binding
Parameters:
pcl - PropertyChangeListener object to receive events when binding properties change

getPropertyChangeListeners

public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
Specified by:
getPropertyChangeListeners in interface Binding
Returns:
array containing the PropertyChangeListener objects registered on this binding object

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)

setComponent

protected abstract void setComponent(javax.swing.JComponent component)
set component and configures metaData dependent logic/constraint state.

Parameters:
component -

getComponentValue

protected abstract java.lang.Object getComponentValue()

setComponentValue

protected abstract void setComponentValue(java.lang.Object value)

checkRequired

protected boolean checkRequired(java.lang.Object componentValue)

isEmpty

protected boolean isEmpty(java.lang.Object componentValue)

convertToModelType

protected java.lang.Object convertToModelType(java.lang.Object componentValue)
                                       throws ConversionException
Throws:
ConversionException

convertFromModelType

protected java.lang.String convertFromModelType(java.lang.Object modelValue)

executeValidators

protected boolean executeValidators(java.lang.Object value)

addError

protected void addError(java.lang.String error)

setModified

protected void setModified(boolean modified)

setValidState

protected void setValidState(int validState)

installInputVerifier

protected void installInputVerifier()
installs an InputVerifier depending on validationPolicy.


checkNull

protected void checkNull(java.lang.Object component,
                         java.lang.String message)

installDataModel

protected void installDataModel(DataModel dataModel,
                                java.lang.String fieldName)

installDataModelListener

protected void installDataModelListener()

installMetaDataListener

protected void installMetaDataListener()
here: does nothing



Copyright © 2005 Sun Microsystems All Rights Reserved.