|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jminor.common.model.valuemap.AbstractValueChangeMapEditModel<K,V>
K
- the type of the keys in the value mapV
- the type of the values in the value mappublic abstract class AbstractValueChangeMapEditModel<K,V>
A class which facilitates the editing of the contents of a ValueChangeMap instance by providing a validation mechanism as well as value change events.
Constructor Summary | |
---|---|
AbstractValueChangeMapEditModel(ValueChangeMap<K,V> initialMap,
ValueMapValidator<K,V> validator)
Instantiates a new edit model instance for the given value map. |
Method Summary | |
---|---|
void |
addValueListener(K key,
ActionListener listener)
|
void |
addValueMapSetListener(ActionListener listener)
|
void |
addValueSetListener(K key,
ActionListener listener)
|
void |
clear()
Clears all data from this refreshable instance |
StateObserver |
getModifiedState()
|
ValueMapValidator<K,V> |
getValidator()
|
StateObserver |
getValidState()
|
V |
getValue(K key)
Returns the value associated with the given key in the underlying value map |
EventObserver |
getValueChangeObserver(K key)
|
protected ValueChangeMap<K,V> |
getValueMap()
|
boolean |
isModified()
|
boolean |
isNullable(K key)
|
boolean |
isValid()
|
boolean |
isValid(K key,
int action)
Returns true if the given value is valid for the given key, using the validate method |
boolean |
isValueNull(K key)
|
protected V |
prepareNewValue(K key,
V value)
Provides a hook into the value setting mechanism, override to translate or otherwise manipulate the value being set |
void |
refresh()
Performs a refresh |
void |
removeValueListener(K key,
ActionListener listener)
|
void |
removeValueMapSetListener(ActionListener listener)
|
void |
removeValueSetListener(K key,
ActionListener listener)
|
void |
setValue(K key,
V value)
Sets the given value in the underlying value map |
void |
setValueMap(ValueChangeMap<K,V> valueMap)
Sets the active value map, that is, deep copies the value from the source map into the underlying map |
void |
validate(K key,
int action)
Checks if the value associated with the give key is valid, throws a ValidationException if not |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.jminor.common.model.valuemap.ValueChangeMapEditModel |
---|
getDefaultValueMap |
Constructor Detail |
---|
public AbstractValueChangeMapEditModel(ValueChangeMap<K,V> initialMap, ValueMapValidator<K,V> validator)
initialMap
- the value map to editvalidator
- the validatorMethod Detail |
---|
public void clear()
clear
in interface Refreshable
public void refresh()
refresh
in interface Refreshable
public final ValueMapValidator<K,V> getValidator()
getValidator
in interface ValueChangeMapEditModel<K,V>
public final boolean isNullable(K key)
isNullable
in interface ValueChangeMapEditModel<K,V>
key
- the key
public final void validate(K key, int action) throws ValidationException
validate
in interface ValueChangeMapEditModel<K,V>
key
- the keyaction
- describes the action requiring validation,
ValueChangeMapEditModel.INSERT, ValueChangeMapEditModel.UPDATE or ValueChangeMapEditModel.UNKNOWN
ValidationException
- if the given value is not valid for the given keypublic final V getValue(K key)
getValue
in interface ValueChangeMapEditModel<K,V>
key
- the key of the value to retrieve
public final void setValue(K key, V value)
setValue
in interface ValueChangeMapEditModel<K,V>
key
- the key to associate the given value withvalue
- the value to associate with the given keypublic final boolean isValueNull(K key)
isValueNull
in interface ValueChangeMapEditModel<K,V>
key
- the key
public final void setValueMap(ValueChangeMap<K,V> valueMap)
setValueMap
in interface ValueChangeMapEditModel<K,V>
valueMap
- the map to set as active, if null then the default map value is set as activeValueChangeMapEditModel.getDefaultValueMap()
,
ValueChangeMapEditModel.addValueMapSetListener(java.awt.event.ActionListener)
public final boolean isValid(K key, int action)
validate
method
isValid
in interface ValueChangeMapEditModel<K,V>
key
- the keyaction
- describes the action requiring validation,
ValueChangeMapEditModel.INSERT, ValueChangeMapEditModel.UPDATE or ValueChangeMapEditModel.UNKNOWN
ValueChangeMapEditModel.validate(Object, int)
,
ValueMapValidator.validate(ValueMap, Object, int)
public final boolean isModified()
isModified
in interface ValueChangeMapEditModel<K,V>
ValueChangeMapEditModel.getModifiedState()
public final boolean isValid()
isValid
in interface ValueChangeMapEditModel<K,V>
()
public final void addValueSetListener(K key, ActionListener listener)
addValueSetListener
in interface ValueChangeMapEditModel<K,V>
key
- the key for which to monitor value changeslistener
- a listener notified each time the value of key
is setpublic final void removeValueSetListener(K key, ActionListener listener)
removeValueSetListener
in interface ValueChangeMapEditModel<K,V>
key
- the keylistener
- the listener to removepublic final EventObserver getValueChangeObserver(K key)
getValueChangeObserver
in interface ValueChangeMapEditModel<K,V>
key
- the key for which to retrieve the event
key
changespublic final void addValueListener(K key, ActionListener listener)
addValueListener
in interface ValueChangeMapEditModel<K,V>
key
- the key for which to monitor value changeslistener
- a listener notified each time the value of key
changespublic final void removeValueListener(K key, ActionListener listener)
removeValueListener
in interface ValueChangeMapEditModel<K,V>
key
- the keylistener
- the listener to removepublic final void addValueMapSetListener(ActionListener listener)
addValueMapSetListener
in interface ValueChangeMapEditModel<K,V>
listener
- a listener notified each time the value map is setpublic final void removeValueMapSetListener(ActionListener listener)
removeValueMapSetListener
in interface ValueChangeMapEditModel<K,V>
listener
- the listener to removepublic final StateObserver getModifiedState()
getModifiedState
in interface ValueChangeMapEditModel<K,V>
ValueChangeMapEditModel.isModified()
public final StateObserver getValidState()
getValidState
in interface ValueChangeMapEditModel<K,V>
ValueChangeMapEditModel.getValidator()
,
ValueChangeMapEditModel.isValid()
protected V prepareNewValue(K key, V value)
key
- the keyvalue
- the value
protected final ValueChangeMap<K,V> getValueMap()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |