|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractListModel
dsto.dfc.swing.list.SortedListModelAdapter
public class SortedListModelAdapter
Presents any collection as a sorted DfcListModel. If the collection implements MonitoredCollection, changes are automatically reflected in the list model.
Field Summary | |
---|---|
protected Collection |
collection
|
protected Comparator |
comparator
|
protected boolean |
mutable
|
protected ArrayList |
sortedCollection
|
Fields inherited from class javax.swing.AbstractListModel |
---|
listenerList |
Constructor Summary | |
---|---|
SortedListModelAdapter(Collection collection)
Create a list model that sorts Comparable items. |
|
SortedListModelAdapter(Collection collection,
Comparator comparator)
Create a list model that sorts the collection using a specified comparator. |
Method Summary | |
---|---|
void |
addEntry(Object entry)
Add a new entry at its correct sorted index in the list. |
void |
addEntry(Object entry,
int row)
Add an entry can at a given row. |
boolean |
canAddEntry(Object entry,
int row)
Test if an entry can be added at a given row. |
boolean |
canRemoveEntry(int row)
Test if an entry can be removed. |
boolean |
canReplaceEntry(Object entry,
int row)
Test if an entry can be replaced. |
protected void |
checkAddReplace(Object entry,
int row)
|
protected void |
checkRemove(int row)
|
void |
dispose()
Dispose of the object (unregister listeners, close open resources etc). |
void |
elementsAdded(Collection c)
For use when not using a MonitoredCollection in the list: indicate that elements have been added to the underlying collection. |
void |
elementsAdded(CollectionEvent e)
|
void |
elementsRemoved(Collection c)
For use when not using a MonitoredCollection in the list: indicate that elements have been removed from the underlying collection. |
void |
elementsRemoved(CollectionEvent e)
|
Object |
getElementAt(int index)
|
int |
getSize()
|
protected int |
getSortedIndex(Object listItem)
|
int |
indexOf(Object entry)
Find the first occurrence of an entry and return its index. |
boolean |
isMutable()
Test if this model is mutable (can be changed). |
Object |
removeEntry(int row)
Remove an entry at a given row. |
Object |
replaceEntry(Object entry,
int row)
Replace an entry can at a given row. |
void |
setMutable(boolean newValue)
|
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, toString, wait, wait, wait |
Methods inherited from interface javax.swing.ListModel |
---|
addListDataListener, removeListDataListener |
Field Detail |
---|
protected Collection collection
protected ArrayList sortedCollection
protected Comparator comparator
protected boolean mutable
Constructor Detail |
---|
public SortedListModelAdapter(Collection collection)
public SortedListModelAdapter(Collection collection, Comparator comparator)
Method Detail |
---|
public void dispose()
Disposable
dispose
in interface Disposable
public void addEntry(Object entry) throws UnsupportedOperationException
entry
- The new entry.
UnsupportedOperationException
- if list is not mutable.protected int getSortedIndex(Object listItem)
public void elementsAdded(Collection c)
c
- The collection of new elements.public void elementsRemoved(Collection c)
c
- The deleted elements.public boolean isMutable()
DfcListModel
isMutable
in interface DfcListModel
public void setMutable(boolean newValue)
public int indexOf(Object entry)
DfcListModel
indexOf
in interface DfcListModel
public boolean canReplaceEntry(Object entry, int row)
DfcListModel
canReplaceEntry
in interface DfcListModel
entry
- The entry to add.row
- The row to overwrite.
DfcListModel.replaceEntry(java.lang.Object, int)
public Object replaceEntry(Object entry, int row) throws IndexOutOfBoundsException, UnsupportedOperationException
DfcListModel
replaceEntry
in interface DfcListModel
entry
- The entry to add.row
- The row to overwrite.
IndexOutOfBoundsException
- if row is out of bounds.
UnsupportedOperationException
- if entry is not allowed to be
replaced.DfcListModel.canReplaceEntry(java.lang.Object, int)
public boolean canAddEntry(Object entry, int row)
DfcListModel
canAddEntry
in interface DfcListModel
entry
- The entry to add.row
- The row to add the new entry.
DfcListModel.addEntry(java.lang.Object, int)
public void addEntry(Object entry, int row) throws IndexOutOfBoundsException, UnsupportedOperationException
DfcListModel
addEntry
in interface DfcListModel
entry
- The entry to add.row
- The row to add the new entry.
IndexOutOfBoundsException
- if row is out of bounds.
UnsupportedOperationException
- if entry is not allowed to be
added.DfcListModel.canAddEntry(java.lang.Object, int)
public boolean canRemoveEntry(int row)
DfcListModel
canRemoveEntry
in interface DfcListModel
row
- The row to be removed.
DfcListModel.removeEntry(int)
public Object removeEntry(int row) throws IndexOutOfBoundsException, UnsupportedOperationException
DfcListModel
removeEntry
in interface DfcListModel
row
- The row to remove.
IndexOutOfBoundsException
- if row is out of bounds.
UnsupportedOperationException
- if entry is not allowed to be
removed.DfcListModel.canRemoveEntry(int)
protected void checkAddReplace(Object entry, int row) throws UnsupportedOperationException
UnsupportedOperationException
protected void checkRemove(int row) throws UnsupportedOperationException
UnsupportedOperationException
public int getSize()
getSize
in interface ListModel
public Object getElementAt(int index)
getElementAt
in interface ListModel
public void elementsAdded(CollectionEvent e)
elementsAdded
in interface CollectionListener
public void elementsRemoved(CollectionEvent e)
elementsRemoved
in interface CollectionListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |