org.jminor.common.ui.control
Class AbstractValueLink<T,V>

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.jminor.common.ui.control.Control
          extended by org.jminor.common.ui.control.AbstractValueLink<T,V>
Type Parameters:
T - the type of the value owner
V - the type of the value
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
Direct Known Subclasses:
AbstractBeanValueLink, AbstractValueMapLink

public abstract class AbstractValueLink<T,V>
extends Control

An abstract base class for linking a UI component to a model value.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
AbstractValueLink(T valueOwner, EventObserver modelValueChangeEvent, LinkType linkType)
          Instantiates a new AbstractValueLink
 
Method Summary
 void actionPerformed(ActionEvent e)
          
 LinkType getLinkType()
           
abstract  V getModelValue()
           
protected abstract  V getUIValue()
           
 T getValueOwner()
           
abstract  void setModelValue(V value)
          Sets the value in the model
protected abstract  void setUIValue(V value)
          Sets the value in the UI
 void updateModel()
          Updates the model according to the UI.
 void updateUI()
          Updates the UI according to the model.
 
Methods inherited from class org.jminor.common.ui.control.Control
getDescription, getEnabledState, getIcon, getMnemonic, getName, isEnabled, setDescription, setEnabled, setIcon, setKeyStroke, setMnemonic, setName
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, putValue, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractValueLink

public AbstractValueLink(T valueOwner,
                         EventObserver modelValueChangeEvent,
                         LinkType linkType)
Instantiates a new AbstractValueLink

Parameters:
valueOwner - the owner of the property value
modelValueChangeEvent - an Event on which the UI should be updated to reflect changes in the model
linkType - the link Type
Method Detail

actionPerformed

public final void actionPerformed(ActionEvent e)

Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class Control

getValueOwner

public final T getValueOwner()
Returns:
the owner of the linked property, the model

getLinkType

public final LinkType getLinkType()
Returns:
the type of this link

updateModel

public final void updateModel()
Updates the model according to the UI.


updateUI

public final void updateUI()
Updates the UI according to the model.


getModelValue

public abstract V getModelValue()
Returns:
the model value of the linked property

setModelValue

public abstract void setModelValue(V value)
Sets the value in the model

Parameters:
value - the value to set for property

getUIValue

protected abstract V getUIValue()
Returns:
the value according to the UI

setUIValue

protected abstract void setUIValue(V value)
Sets the value in the UI

Parameters:
value - the value to represent in the UI