Package org.geotools.swing.control
Class DnDListModel<T>
- Object
-
- AbstractListModel<T>
-
- DnDListModel<T>
-
- All Implemented Interfaces:
Serializable,ListModel<T>
public class DnDListModel<T> extends AbstractListModel<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:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class AbstractListModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description DnDListModel()Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItem(T newItem)Append a new item to the end of the list of current itemsvoidaddItems(Collection<T> newItems)Add new items to the end of the list of current itemsvoidaddItems(T[] newItems)Add new items to the end of the list of current itemsvoidclear()Remove all items from the listbooleancontains(T item)Query whether this list contains the specified itemTgetElementAt(int index)Get the list item at the specified index.List<T>getElementsAt(int[] indices)Returns a list of the items at the specified indices.List<T>getElementsAt(Collection<Integer> indices)Returns a list of the items at the indices specified in the Collection.booleangetNotifyListeners()intgetSize()intindexOf(T item)Get the (first) index of the given item in the list of items held by this model.voidinsertItem(int destIndex, T newItem)Insert an item into the list at the specified position.voidinsertItems(int destIndex, Collection<T> newItems)Insert new items into the list at the specified position.voidinsertItems(int destIndex, T[] newItems)Insert new items into the list at the specified position.voidmoveItems(int destIndex, int[] srcIndices)Move the items currently positioned at the indices in thesrcIndicesarray as block such that they are inserted into the list atdestIndex.voidremoveAt(int index)Remove the item at the specified indexvoidremoveItem(T item)Removes the first instance of the specified item if it is contained in the listvoidsetNofifyListeners(boolean notify)StringtoString()-
Methods inherited from class AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
-
-
-
Method Detail
-
setNofifyListeners
public void setNofifyListeners(boolean notify)
-
getNotifyListeners
public boolean getNotifyListeners()
-
getSize
public int getSize()
-
getElementAt
public T getElementAt(int index)
Get the list item at the specified index.Note: this method returns a live reference.
- Throws:
IndexOutOfBoundsException- if index is invalid
-
getElementsAt
public List<T> getElementsAt(int[] indices)
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
public List<T> getElementsAt(Collection<Integer> indices)
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
public void addItem(T newItem)
Append a new item to the end of the list of current items
-
addItems
public void addItems(T[] newItems)
Add new items to the end of the list of current items
-
addItems
public void addItems(Collection<T> newItems)
Add new items to the end of the list of current items
-
insertItem
public void insertItem(int destIndex, T newItem)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
public void insertItems(int destIndex, T[] newItems)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
public void insertItems(int destIndex, Collection<T> newItems)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 thesrcIndicesarray 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
public void removeItem(T item)
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
public boolean contains(T item)
Query whether this list contains the specified item
-
indexOf
public int indexOf(T item)
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
-
-