public class ListModelAdapter extends Object implements ComboBoxModel, ListSelectionModel
Modifier and Type | Field and Description |
---|---|
protected SelectionInList<?> |
mSelectionInList
value model holding the list, never null
|
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION
Constructor and Description |
---|
ListModelAdapter(JComboBox pComboBox,
SelectionInList<?> pListValueModel,
DelegateAccess pAccessValueModel)
Creates a new adapter between a SelectionInList ValueModel
and a JComboBox.
|
ListModelAdapter(JList pList,
SelectionInList<?> pListValueModel,
DelegateAccess pAccessValueModel)
Creates a new adapter between a SelectionInList ValueModel
and a JList.
|
Modifier and Type | Method and Description |
---|---|
void |
addElement(Object pObj)
Add the item to the list.
|
void |
addListDataListener(ListDataListener pListener) |
void |
addListSelectionListener(ListSelectionListener pListener) |
void |
addSelectionInterval(int pIndex0,
int pIndex1) |
void |
clearSelection() |
protected void |
fireListChanged(ListDataEvent pEvent)
Notifies all listeners that something changed in our list model.
|
int |
getAnchorSelectionIndex() |
Object |
getElementAt(int pIndex) |
int |
getIndexByObject(Object pItem)
Small helper to find a item in our list.
|
int |
getLeadSelectionIndex() |
int |
getMaxSelectionIndex() |
int |
getMinSelectionIndex() |
Object |
getSelectedItem() |
int |
getSelectionMode() |
int |
getSize() |
boolean |
getValueIsAdjusting() |
void |
insertIndexInterval(int pIndex,
int pLength,
boolean pBefore) |
boolean |
isSelectedIndex(int pIndex) |
boolean |
isSelectionEmpty() |
void |
removeElement(Object pObj)
Removes the item from the list.
|
void |
removeIndexInterval(int pIndex0,
int pIndex1) |
void |
removeListDataListener(ListDataListener pListener) |
void |
removeListSelectionListener(ListSelectionListener pListener) |
void |
removeSelectionInterval(int pIndex0,
int pIndex1) |
void |
setAnchorSelectionIndex(int pIndex) |
void |
setLeadSelectionIndex(int pIndex) |
void |
setSelectedItem(Object pItem) |
void |
setSelectionInterval(int pIndex0,
int pIndex1) |
void |
setSelectionMode(int pSelectionMode) |
void |
setValueIsAdjusting(boolean pValueIsAdjusting) |
void |
vmDataChanged(ChangeEvent pEvent)
Callback from our VM
|
void |
vmSelectionChanged(ChangeEvent pEvent)
Callback from our VM
|
protected SelectionInList<?> mSelectionInList
public ListModelAdapter(JList pList, SelectionInList<?> pListValueModel, DelegateAccess pAccessValueModel)
pList
- the list for which we adapt topListValueModel
- the value model (SelectionInList) that drives the list
(data, selection) and gets updated by the list (selection only)pAccessValueModel
- null or the converter we use to map between the
SelectionInList list objects and the display objectsIllegalArgumentException
- if pList or pValueModel is nullpublic ListModelAdapter(JComboBox pComboBox, SelectionInList<?> pListValueModel, DelegateAccess pAccessValueModel)
pComboBox
- the combobox for which we adapt topListValueModel
- the value model (SelectionInList) that drives the combobox
(data, selection) and gets updated by the combobox (selection only)pAccessValueModel
- null or the converter we use to map between the
SelectionInList list objects and the display objectsIllegalArgumentException
- if pComboBox or pValueModel is nullprotected void fireListChanged(ListDataEvent pEvent)
pEvent
- the ListDataEvent to firepublic void vmDataChanged(ChangeEvent pEvent)
pEvent
- not usedpublic void vmSelectionChanged(ChangeEvent pEvent)
pEvent
- not usedpublic void setSelectionInterval(int pIndex0, int pIndex1)
setSelectionInterval
in interface ListSelectionModel
public void addSelectionInterval(int pIndex0, int pIndex1)
addSelectionInterval
in interface ListSelectionModel
public void removeSelectionInterval(int pIndex0, int pIndex1)
removeSelectionInterval
in interface ListSelectionModel
public void insertIndexInterval(int pIndex, int pLength, boolean pBefore)
insertIndexInterval
in interface ListSelectionModel
public void removeIndexInterval(int pIndex0, int pIndex1)
removeIndexInterval
in interface ListSelectionModel
public void clearSelection()
clearSelection
in interface ListSelectionModel
public int getMinSelectionIndex()
getMinSelectionIndex
in interface ListSelectionModel
public int getMaxSelectionIndex()
getMaxSelectionIndex
in interface ListSelectionModel
public boolean isSelectedIndex(int pIndex)
isSelectedIndex
in interface ListSelectionModel
public int getAnchorSelectionIndex()
getAnchorSelectionIndex
in interface ListSelectionModel
public void setAnchorSelectionIndex(int pIndex)
setAnchorSelectionIndex
in interface ListSelectionModel
public int getLeadSelectionIndex()
getLeadSelectionIndex
in interface ListSelectionModel
public void setLeadSelectionIndex(int pIndex)
setLeadSelectionIndex
in interface ListSelectionModel
public boolean isSelectionEmpty()
isSelectionEmpty
in interface ListSelectionModel
public void setValueIsAdjusting(boolean pValueIsAdjusting)
setValueIsAdjusting
in interface ListSelectionModel
public boolean getValueIsAdjusting()
getValueIsAdjusting
in interface ListSelectionModel
public void setSelectionMode(int pSelectionMode)
setSelectionMode
in interface ListSelectionModel
public int getSelectionMode()
getSelectionMode
in interface ListSelectionModel
public void addListSelectionListener(ListSelectionListener pListener)
addListSelectionListener
in interface ListSelectionModel
public void removeListSelectionListener(ListSelectionListener pListener)
removeListSelectionListener
in interface ListSelectionModel
public Object getSelectedItem()
getSelectedItem
in interface ComboBoxModel
public void setSelectedItem(Object pItem)
setSelectedItem
in interface ComboBoxModel
public Object getElementAt(int pIndex)
getElementAt
in interface ListModel
public void addListDataListener(ListDataListener pListener)
addListDataListener
in interface ListModel
public void removeListDataListener(ListDataListener pListener)
removeListDataListener
in interface ListModel
public void addElement(Object pObj)
pObj
- the component to be addedSelectionInList.addItem(Object)
public void removeElement(Object pObj)
pObj
- the component to be removedSelectionInList.removeItem(int)
public int getIndexByObject(Object pItem)
pItem
- the (display) object we are searchingCopyright © 2017 Jürgen Zeller (privat). All rights reserved.