cdx.scorebot.util.swing.binding.delegate
Class GenericJComponentDelegate<FROM,TO>

java.lang.Object
  extended by cdx.scorebot.util.swing.binding.delegate.GenericDelegate<FROM,TO>
      extended by cdx.scorebot.util.swing.binding.delegate.GenericJComponentDelegate<FROM,TO>
All Implemented Interfaces:
BoundDelegateComponent
Direct Known Subclasses:
CalHourBoxComponentDelegate, JLabelComponentDelegate, JTextComponentDelegate, JToggleButtonComponentDelegate, ListBasedComponentDelegate

public abstract class GenericJComponentDelegate<FROM,TO>
extends GenericDelegate<FROM,TO>

Binds some Object of type FROM to a component which requires type TO

Author:
David Underhill

Constructor Summary
GenericJComponentDelegate(boolean isContainer, BoundComponent owner, BoundComponent compon, TypeTranslator<FROM,TO> translator, java.lang.Object boundItem, java.lang.String varName)
          Instantiates a bound JComponent Delegate
GenericJComponentDelegate(boolean isContainer, BoundComponent owner, BoundComponent compon, TypeTranslator<FROM,TO> translator, java.lang.Object boundItem, java.lang.String getterName, java.lang.String setterName)
          Instantiates a bound JComponent Delegate
GenericJComponentDelegate(boolean isContainer, BoundComponent owner, BoundComponent compon, TypeTranslator<FROM,TO> translator, java.lang.Object boundItem, java.lang.String getterName, java.lang.String setterName, int indexAt)
          Instantiates a bound JComponent Delegate
GenericJComponentDelegate(boolean isContainer, BoundComponent owner, BoundComponent compon, TypeTranslator<FROM,TO> translator, java.lang.String varName)
          Instantiates a bound JComponent Delegate
GenericJComponentDelegate(BoundComponent owner, BoundComponent compon)
          Instantiates an unbound JComponent Delegate
 
Method Summary
protected abstract  void completeInit()
          suggested that this is used to load the component with its initial values after the constructor is done
protected  void handleValidationState()
          draw the border to reflect the specified validation state if me() returns a JComponent, and does nothing otherwise
 
Methods inherited from class cdx.scorebot.util.swing.binding.delegate.GenericDelegate
addBindingListener, changeBinding, changeBinding, changeBinding, changeBinding, changeBinding, changeBinding, changeBinding, getBinding, getBoundParent, getFormattedValidationErrorMsg, getMe, getOwner, getValidationErrorMsg, highlightOnError, isContainer, isValidated, load, notifyListenersOfBindingChanged, notifyListenersOfBindingChanging, notifyListenersOfBindingLoaded, removeBindingListener, save, setBoundParent, setHighlightOnError, setValidationError, setValidationError, validationError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericJComponentDelegate

public GenericJComponentDelegate(BoundComponent owner,
                                 BoundComponent compon)
Instantiates an unbound JComponent Delegate

Parameters:
owner - the BoundComponent which this belongs to
compon - the component that this works for

GenericJComponentDelegate

public GenericJComponentDelegate(boolean isContainer,
                                 BoundComponent owner,
                                 BoundComponent compon,
                                 TypeTranslator<FROM,TO> translator,
                                 java.lang.String varName)
Instantiates a bound JComponent Delegate

Parameters:
owner - the BoundComponent which this belongs to
isContainer - whether or not this component can contain others
compon - the component that this works for
translator - how to translate between the value in the boundItem (type FROM) a another value of type TO
varName - the name of the variable; assumes the getter and setter name will be get and set followed by varName with its first letter capitalized (ex: if varName is "value" then the getter will be getValue).

GenericJComponentDelegate

public GenericJComponentDelegate(boolean isContainer,
                                 BoundComponent owner,
                                 BoundComponent compon,
                                 TypeTranslator<FROM,TO> translator,
                                 java.lang.Object boundItem,
                                 java.lang.String varName)
Instantiates a bound JComponent Delegate

Parameters:
owner - the BoundComponent which this belongs to
isContainer - whether or not this component can contain others
compon - the component that this works for
translator - how to translate between the value in the boundItem (type FROM) a another value of type TO
boundItem - the object this is bound to (contains the value to be modified as specified by varName)
varName - the name of the variable; assumes the getter and setter name will be get and set followed by varName with its first letter capitalized (ex: if varName is "value" then the getter will be getValue).

GenericJComponentDelegate

public GenericJComponentDelegate(boolean isContainer,
                                 BoundComponent owner,
                                 BoundComponent compon,
                                 TypeTranslator<FROM,TO> translator,
                                 java.lang.Object boundItem,
                                 java.lang.String getterName,
                                 java.lang.String setterName)
Instantiates a bound JComponent Delegate

Parameters:
owner - the BoundComponent which this belongs to
isContainer - whether or not this component can contain others
compon - the component that this works for
translator - how to translate between the value in the boundItem (type FROM) a another value of type TO
boundItem - the object this is bound to (contains the value to be modified as specified by the getter and setter name)
getterName - how to get the bound value from the bound object
setterName - how to set the bound value from the bound object

GenericJComponentDelegate

public GenericJComponentDelegate(boolean isContainer,
                                 BoundComponent owner,
                                 BoundComponent compon,
                                 TypeTranslator<FROM,TO> translator,
                                 java.lang.Object boundItem,
                                 java.lang.String getterName,
                                 java.lang.String setterName,
                                 int indexAt)
Instantiates a bound JComponent Delegate

Parameters:
owner - the BoundComponent which this belongs to
isContainer - whether or not this component can contain others
compon - the component that this works for
translator - how to translate between the value in the boundItem (type FROM) a another value of type TO
boundItem - the object this is bound to (contains the value to be modified as specified by the getter and setter name)
getterName - how to get the bound value from the bound object
setterName - how to set the bound value from the bound object
indexAt - if bound value is stored within a container with get(index) and set(index, Object) methods, then indexAt should be the index to use; otherwise, indexAt should be -1
Method Detail

completeInit

protected abstract void completeInit()
suggested that this is used to load the component with its initial values after the constructor is done

Specified by:
completeInit in class GenericDelegate<FROM,TO>

handleValidationState

protected void handleValidationState()
draw the border to reflect the specified validation state if me() returns a JComponent, and does nothing otherwise

Specified by:
handleValidationState in class GenericDelegate<FROM,TO>