T - the Type inside the list we monitor the selectionpublic class SelectionInList<T> extends AbstractValueModel<List<T>> implements ValueModel<List<T>>, ChangeListener, ExternalUpdate, IndexProvider
| Modifier and Type | Field and Description |
|---|---|
static Integer |
NO_SELECTION
no selection as an Integer object
|
| Constructor and Description |
|---|
SelectionInList(List<T> pList)
Creates a new SelectionInList that does not select an entry in the list.
|
SelectionInList(List<T> pList,
int pIndex)
Creates a new SelectionInList.
|
SelectionInList(ValueModel<List<T>> pListHolder)
Creates a new SelectionInList that does not select an entry in the list.
|
SelectionInList(ValueModel<List<T>> pListHolder,
int pIndex)
Creates a new SelectionInList that does not select an entry in the list.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addItem(int pIndex,
T pItem)
Add an item to the underlying list at the given position.
|
void |
addItem(T pItem)
Add an item to the underlying list at the current position or at the
end of the list if there is currently no selection.
|
void |
dispose()
Cleanup all resources: disconnect from any input sources (like
other ValueModel's ...), and remove all listeners.
|
int |
getIndex()
Return the index of the currently selected item in our list.
|
Comparator<?> |
getSelectionComparator() |
List<T> |
getValue()
Get the current list.
|
boolean |
isEditable()
Returns always true
|
ValueModel<Boolean> |
isIndexInList()
The provided ValueModel can be used to monitor if this IndexedAdapter
holds a "valid" value (index is not NO_SELECTION).
|
boolean |
isKeepSelection() |
ValueModel<List<T>> |
listHolder()
Provides the ValueModel of the ListHolder for our List.
|
Object |
removeItem()
Removes the currently selecte item, or does nothing if no item
is selected.
|
Object |
removeItem(int pIndex)
Remove the item at the handed position.
|
ValueModel<Integer> |
selectionHolder()
The provided ValueModel can be used to monitor and change
the selection in our list.
|
void |
setKeepSelection(boolean pKeepSelection)
defines the behavior of the selection when the
list changes.
|
void |
setSelectionComparator(Comparator<T> pSelectionComparator)
sets the comparator to use to find the object if
mKeepSelection is true |
void |
setValue(List<T> pValue,
boolean pIsSetForced)
Set a new value, this will fire a ChangeEvent if the new value
is different from the old value.
|
void |
stateChanged(ChangeEvent pEvent)
Invoked when the value model holding our list changed its state.
|
addChangeListener, booleanValue, checkDisposed, doubleValue, fireStateChanged, floatValue, getDependents, getName, intValue, isDisposed, isInSetValue, isSetForced, longValue, onChangeSend, removeChangeListener, retractInterestsFor, setInSetValue, setName, setObjectValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueForced, signalExternalUpdate, stringValueclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddChangeListener, booleanValue, doubleValue, floatValue, getDependents, getName, intValue, isDisposed, isSetForced, longValue, onChangeSend, removeChangeListener, retractInterestsFor, setName, setObjectValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueForced, stringValuesignalExternalUpdatepublic static final Integer NO_SELECTION
public SelectionInList(ValueModel<List<T>> pListHolder)
pListHolder - the list we monitor the selection is the value of pListHolderIllegalArgumentException - if pListHolder is null or pListHolder.getValue()
is not null and not a Listpublic SelectionInList(ValueModel<List<T>> pListHolder, int pIndex)
pListHolder - the list we monitor the selection is the value of pListHolderpIndex - NO_SELECTION or the initial index in the listIllegalArgumentException - if pListHolder is null or the value if
pListHolder is neither null nor a List or pIndex is out of rangepublic SelectionInList(List<T> pList)
pList - the list we are indexing into, may be nullpublic SelectionInList(List<T> pList, int pIndex)
pList - the list we are indexing into, may be nullpIndex - NO_SELECTION or the initial index in the listIllegalArgumentException - if pIndex is out of rangepublic boolean isEditable()
isEditable in interface ValueModel<List<T>>public void dispose()
dispose in interface ValueModel<List<T>>dispose in class AbstractValueModel<List<T>>public void setKeepSelection(boolean pKeepSelection)
pKeepSelection - if true, we try to keep the selected
object, if false, the selection is cleared.mKeepSelectionpublic boolean isKeepSelection()
mKeepSelectionpublic Comparator<?> getSelectionComparator()
mKeepSelection is truemKeepSelectionpublic void setSelectionComparator(Comparator<T> pSelectionComparator)
mKeepSelection is truepSelectionComparator - the new comparator, may be null.
If null, Object.equals(Object) will be used.mKeepSelectionpublic void setValue(List<T> pValue, boolean pIsSetForced)
setValue in interface ValueModel<List<T>>pValue - the new list (null is o.k.)pIsSetForced - true if a forced setValue should be doneIllegalArgumentException - if pValue is neither a List nor nullpublic List<T> getValue()
getValue in interface ValueModel<List<T>>public int getIndex()
getIndex in interface IndexProviderpublic void addItem(T pItem)
pItem - the item to addpublic void addItem(int pIndex,
T pItem)
pIndex - the index to add the itempItem - the item to addpublic Object removeItem(int pIndex)
pIndex - NO_SELECTION or 0..list size-1public Object removeItem()
public void stateChanged(ChangeEvent pEvent)
stateChanged in interface ChangeListenerpEvent - a ChangeEvent object, not usedpublic ValueModel<Boolean> isIndexInList()
public ValueModel<Integer> selectionHolder()
public ValueModel<List<T>> listHolder()
Copyright © 2017 Jürgen Zeller (privat). All rights reserved.