Package org.geotools.swing.control
Class DnDListModel<T>
Object
AbstractListModel<T>
DnDListModel<T>
- All Implemented Interfaces:
Serializable
,ListModel<T>
A generic ListModel class to support DnDList.
The DnDListModel acts as a wrapper around an internal list of items; providing notification as the items are changed.
- Since:
- 2.6
- Author:
- Michael Bedward
- See Also:
-
Field Summary
Fields inherited from class AbstractListModel
listenerList
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Append a new item to the end of the list of current itemsvoid
addItems
(Collection<T> newItems) Add new items to the end of the list of current itemsvoid
Add new items to the end of the list of current itemsvoid
clear()
Remove all items from the listboolean
Query whether this list contains the specified itemgetElementAt
(int index) Get the list item at the specified index.getElementsAt
(int[] indices) Returns a list of the items at the specified indices.getElementsAt
(Collection<Integer> indices) Returns a list of the items at the indices specified in the Collection.boolean
int
getSize()
int
Get the (first) index of the given item in the list of items held by this model.void
insertItem
(int destIndex, T newItem) Insert an item into the list at the specified position.void
insertItems
(int destIndex, Collection<T> newItems) Insert new items into the list at the specified position.void
insertItems
(int destIndex, T[] newItems) Insert new items into the list at the specified position.void
moveItems
(int destIndex, int[] srcIndices) Move the items currently positioned at the indices in thesrcIndices
array as block such that they are inserted into the list atdestIndex
.void
removeAt
(int index) Remove the item at the specified indexvoid
removeItem
(T item) Removes the first instance of the specified item if it is contained in the listvoid
setNofifyListeners
(boolean notify) toString()
Methods inherited from class AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
Constructor Details
-
DnDListModel
public DnDListModel()Default constructor
-
-
Method Details
-
setNofifyListeners
public void setNofifyListeners(boolean notify) -
getNotifyListeners
public boolean getNotifyListeners() -
getSize
public int getSize() -
getElementAt
Get the list item at the specified index.Note: this method returns a live reference.
- Throws:
IndexOutOfBoundsException
- if index is invalid
-
getElementsAt
Returns a list of the items at the specified indices.Note: The returned List contains live references.
- Throws:
IndexOutOfBoundsException
- if any of the indices are invalid
-
getElementsAt
Returns a list of the items at the indices specified in the Collection.Note: The returned List contains live references.
- Throws:
IndexOutOfBoundsException
- if any of the indices are invalid
-
addItem
Append a new item to the end of the list of current items -
addItems
Add new items to the end of the list of current items -
addItems
Add new items to the end of the list of current items -
insertItem
Insert an item into the list at the specified position.- Parameters:
destIndex
- the position of the new item: if < 0 the item will be inserted at the start of the list; if >= the current list size the item will be appended to the end of the list
-
insertItems
Insert new items into the list at the specified position.- Parameters:
destIndex
- the position of the new item: if < 0 the items will be inserted at the start of the list; if >= the current list size the items will be appended to the end of the list
-
insertItems
Insert new items into the list at the specified position.- Parameters:
destIndex
- the position of the new item: if < 0 the items will be inserted at the start of the list; if >= the current list size the items will be appended to the end of the list
-
moveItems
public void moveItems(int destIndex, int[] srcIndices) Move the items currently positioned at the indices in thesrcIndices
array as block such that they are inserted into the list atdestIndex
. It is assumed that srcIndices is sorted in ascending order. -
removeAt
public void removeAt(int index) Remove the item at the specified index -
removeItem
Removes the first instance of the specified item if it is contained in the list -
clear
public void clear()Remove all items from the list -
contains
Query whether this list contains the specified item -
indexOf
Get the (first) index of the given item in the list of items held by this model.- Parameters:
item
- the item to search for- Returns:
- the index or -1 if the item is not present
-
toString
-