public class LOVAdapter extends Object implements ListSelectionModel, ComboBoxModel, ActionListener
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION
Constructor and Description |
---|
LOVAdapter(ButtonGroup pButtonGroup,
List<?> pDisplayedItems,
List<?> pKeys,
ValueModel<?> pSelectedKeyVM,
Object pUnselectedKey)
Create a new adapter between the buttong group, the keys and the selected key.
|
LOVAdapter(ButtonGroup pButtonGroup,
ValueModel<List<?>> pDisplayedItemsVM,
ValueModel<List<?>> pKeysVM,
ValueModel<?> pSelectedKeyVM,
Object pUnselectedKey)
Create a new adapter between the buttong group, the keys and the selected key.
|
LOVAdapter(JComboBox pComboBox,
List<?> pDisplayedItems,
List<?> pKeys,
ValueModel<?> pSelectedKeyVM)
Create a new adapter between the displayed itams and the keys.
|
LOVAdapter(JComboBox pComboBox,
List<?> pDisplayedItems,
List<?> pKeys,
ValueModel<?> pSelectedKeyVM,
Object pUnselectedKey)
Create a new adapter between the displayed itams, the keys and a magic "null"
key value.
|
LOVAdapter(JComboBox pComboBox,
ValueModel<List<?>> pDisplayedItemsVM,
ValueModel<List<?>> pKeysVM,
ValueModel<?> pSelectedKeyVM)
Create a new adapter between the displayed itams and the keys.
|
LOVAdapter(JComboBox pComboBox,
ValueModel<List<?>> pDisplayedItemsVM,
ValueModel<List<?>> pKeysVM,
ValueModel<?> pSelectedKeyVM,
Object pUnselectedKey)
Create a new adapter between the displayed itams, the keys and a magic "null"
key value.
|
LOVAdapter(JList pList,
List<?> pDisplayedItems,
List<?> pKeys,
ValueModel<?> pSelectedKeyVM)
Create a new adapter between the displayed itams and the keys.
|
LOVAdapter(JList pList,
List<?> pDisplayedItems,
List<?> pKeys,
ValueModel<?> pSelectedKeyVM,
Object pUnselectedKey)
Create a new adapter between the displayed itams, the keys and a magic "null"
key value.
|
LOVAdapter(JList pList,
ValueModel<List<?>> pDisplayedItemsVM,
ValueModel<List<?>> pKeysVM,
ValueModel<?> pSelectedKeyVM)
Create a new adapter between the displayed itams and the keys.
|
LOVAdapter(JList pList,
ValueModel<List<?>> pDisplayedItemsVM,
ValueModel<List<?>> pKeysVM,
ValueModel<?> pSelectedKeyVM,
Object pUnselectedKey)
Create a new adapter between the displayed itams, the keys and a magic "null"
key value.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent pEvent) |
void |
addListDataListener(ListDataListener pListDataListener) |
void |
addListSelectionListener(ListSelectionListener pListener) |
void |
addSelectionInterval(int pIndex0,
int pIndex1) |
void |
clearSelection() |
protected void |
fireListChanged(ListDataEvent pListDataEvent)
Helper method to notify all listeners that something changed in our list model.
|
int |
getAnchorSelectionIndex() |
Object |
getElementAt(int pIndex) |
int |
getIndexByKey(Object pKey)
Small helper to find the index for a key in the key list.
|
int |
getLeadSelectionIndex() |
int |
getMaxSelectionIndex() |
int |
getMinSelectionIndex() |
int |
getSelectedIndex()
Return the selected index or -1 if there is no valid selection.
|
Object |
getSelectedItem() |
int |
getSelectionMode() |
int |
getSize() |
boolean |
getValueIsAdjusting() |
void |
insertIndexInterval(int pIndex,
int pLength,
boolean pBefore) |
boolean |
isSelectedIndex(int pIndex) |
boolean |
isSelectionEmpty() |
void |
removeIndexInterval(int pIndex0,
int pIndex1) |
void |
removeListDataListener(ListDataListener pListDataListener) |
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 |
vmItemsChanged(ChangeEvent pEvent)
Callback from our ValueModel holding the displayed items.
|
void |
vmKeysChanged(ChangeEvent pEvent)
Callback from our ValueModel holding the possible keys.
|
void |
vmSelectedKeyChanged(ChangeEvent pEvent)
Callback from our ValueModel holding the selected key.
|
public LOVAdapter(JComboBox pComboBox, ValueModel<List<?>> pDisplayedItemsVM, ValueModel<List<?>> pKeysVM, ValueModel<?> pSelectedKeyVM)
pComboBox
- the combobox widget, must not be nullpDisplayedItemsVM
- the value model holding the displayed items, must not be nullpKeysVM
- the value model holding the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpublic LOVAdapter(JComboBox pComboBox, ValueModel<List<?>> pDisplayedItemsVM, ValueModel<List<?>> pKeysVM, ValueModel<?> pSelectedKeyVM, Object pUnselectedKey)
pComboBox
- the combobox widget, must not be nullpDisplayedItemsVM
- the value model holding the displayed items, must not be nullpKeysVM
- the value model holding the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpUnselectedKey
- the magic key, may be nulllpublic LOVAdapter(JComboBox pComboBox, List<?> pDisplayedItems, List<?> pKeys, ValueModel<?> pSelectedKeyVM)
pComboBox
- the combobox widget, must not be nullpDisplayedItems
- the list containing the displayed items, must not be nullpKeys
- the list containing the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpublic LOVAdapter(JComboBox pComboBox, List<?> pDisplayedItems, List<?> pKeys, ValueModel<?> pSelectedKeyVM, Object pUnselectedKey)
pComboBox
- the combobox widget, must not be nullpDisplayedItems
- the list containing the displayed items, must not be nullpKeys
- the list containing the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpUnselectedKey
- the magic key, may be nulllpublic LOVAdapter(JList pList, ValueModel<List<?>> pDisplayedItemsVM, ValueModel<List<?>> pKeysVM, ValueModel<?> pSelectedKeyVM)
pList
- the list widget, must not be nullpDisplayedItemsVM
- the value model holding the displayed items, must not be nullpKeysVM
- the value model holding the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpublic LOVAdapter(JList pList, ValueModel<List<?>> pDisplayedItemsVM, ValueModel<List<?>> pKeysVM, ValueModel<?> pSelectedKeyVM, Object pUnselectedKey)
pList
- the list widget, must not be nullpDisplayedItemsVM
- the value model holding the displayed items, must not be nullpKeysVM
- the value model holding the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpUnselectedKey
- the magic key, may be nulllpublic LOVAdapter(JList pList, List<?> pDisplayedItems, List<?> pKeys, ValueModel<?> pSelectedKeyVM)
pList
- the list widget, must not be nullpDisplayedItems
- the list containing the displayed items, must not be nullpKeys
- the list containing the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpublic LOVAdapter(JList pList, List<?> pDisplayedItems, List<?> pKeys, ValueModel<?> pSelectedKeyVM, Object pUnselectedKey)
pList
- the list widget, must not be nullpDisplayedItems
- the list containing the displayed items, must not be nullpKeys
- the list containing the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpUnselectedKey
- the magic key, may be nulllpublic LOVAdapter(ButtonGroup pButtonGroup, ValueModel<List<?>> pDisplayedItemsVM, ValueModel<List<?>> pKeysVM, ValueModel<?> pSelectedKeyVM, Object pUnselectedKey)
pButtonGroup
- the list widget, must not be nullpDisplayedItemsVM
- the value model holding the displayed items, must not be nullpKeysVM
- the value model holding the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpUnselectedKey
- the magic key, may be nulllpublic LOVAdapter(ButtonGroup pButtonGroup, List<?> pDisplayedItems, List<?> pKeys, ValueModel<?> pSelectedKeyVM, Object pUnselectedKey)
pButtonGroup
- the button group, must not be nullpDisplayedItems
- the list containing the displayed items, must not be null, but not really usedpKeys
- the list containing the matching keys, must not be nullpSelectedKeyVM
- the value model holding the key matching the selection keys, must not be nullpUnselectedKey
- the magic key, may be nulllprotected void fireListChanged(ListDataEvent pListDataEvent)
pListDataEvent
- the list data event to dispatchpublic int getSelectedIndex()
public int getIndexByKey(Object pKey)
pKey
- the key we are searching the index forpublic void vmItemsChanged(ChangeEvent pEvent)
pEvent
- not usedpublic void vmSelectedKeyChanged(ChangeEvent pEvent)
pEvent
- not usedpublic void vmKeysChanged(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 pListDataListener)
addListDataListener
in interface ListModel
public void removeListDataListener(ListDataListener pListDataListener)
removeListDataListener
in interface ListModel
public void actionPerformed(ActionEvent pEvent)
actionPerformed
in interface ActionListener
Copyright © 2017 Jürgen Zeller (privat). All rights reserved.