org.geotools.swing.control
Class DnDListModel<T>

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by org.geotools.swing.control.DnDListModel<T>
All Implemented Interfaces:
java.io.Serializable, javax.swing.ListModel

public class DnDListModel<T>
extends javax.swing.AbstractListModel

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
Version:
$Id: DnDListModel.java 34290 2009-10-30 12:36:40Z mbedward $
Author:
Michael Bedward
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
DnDListModel()
          Default constructor
 
Method Summary
 void addItem(T newItem)
          Append a new item to the end of the list of current items
 void addItems(java.util.Collection<T> newItems)
          Add new items to the end of the list of current items
 void addItems(T[] newItems)
          Add new items to the end of the list of current items
 void clear()
          Remove all items from the list
 boolean contains(T item)
          Query whether this list contains the specified item
 T getElementAt(int index)
          Get the list item at the specified index.
 java.util.List<T> getElementsAt(java.util.Collection<java.lang.Integer> indices)
          Returns a list of the items at the indices specified in the Collection.
 java.util.List<T> getElementsAt(int[] indices)
          Returns a list of the items at the specified indices.
 boolean getNotifyListeners()
           
 int getSize()
           
 int indexOf(T item)
          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, java.util.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 the srcIndices array as block such that they are inserted into the list at destIndex.
 void removeAt(int index)
          Remove the item at the specified index
 void removeItem(T item)
          Removes the first instance of the specified item if it is contained in the list
 void setNofifyListeners(boolean notify)
           
 java.lang.String toString()
           
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DnDListModel

public DnDListModel()
Default constructor

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:
java.lang.IndexOutOfBoundsException - if index is invalid

getElementsAt

public java.util.List<T> getElementsAt(int[] indices)
Returns a list of the items at the specified indices.

Note: The returned List contains live references.

Throws:
java.lang.IndexOutOfBoundsException - if any of the indices are invalid

getElementsAt

public java.util.List<T> getElementsAt(java.util.Collection<java.lang.Integer> indices)
Returns a list of the items at the indices specified in the Collection.

Note: The returned List contains live references.

Throws:
java.lang.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(java.util.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,
                        java.util.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 the srcIndices array as block such that they are inserted into the list at destIndex. 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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 1996-2010 Geotools. All Rights Reserved.