T - @Deprecated public class SimpleCollectionModel<T> extends TableModelBase<T> implements IShelvedListener
20091206 jal This model is deprecated because TableModel's REQUIRE the use of indexed addressing, and this addressing needs to remain stable while using this. This implementation uses Collection and re-creates a list for every time we need indexed addressing. This is VERY expensive, but also unstable when items are added: when they are added to a HashSet for instance the entire internal order can change (after a rehash) causing all items in the table to shift position. Although this model does fire modelChanged so at least the presentation remains correct, this is unacceptable behaviour. The implementation depends on the unshelve command, during unshelving all listeners are notified that the model changed, so changes in the collection this model represents constructor will be reflected in the component that is bound to the model. This means that changes made to the collection itself will be reflected only if that changed are made in a different page then where the component this model is tied to is located. For reflecting changes in the same page the add and remove methods should be called on the model itself, not on the collection it represents.
DEFAULT_MAX_SIZE, IN_MEMORY_FILTER_OR_SORT_MAX_SIZE| Constructor and Description |
|---|
SimpleCollectionModel(Collection<T> collection)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T item)
Deprecated.
Tries to add an item to the model's collection.
|
T |
getItem(int index)
Deprecated.
|
List<T> |
getItems(int start,
int end)
Deprecated.
|
protected List<T> |
getList()
Deprecated.
|
int |
getRows()
Deprecated.
This must return the total #of rows in this table.
|
void |
onShelve()
Deprecated.
|
void |
onUnshelve()
Deprecated.
|
boolean |
remove(T item)
Deprecated.
Tries to remove an item from the model's collection.
|
addChangeListener, fireAdded, fireDeleted, fireModelChanged, fireModified, getListeners, refresh, removeChangeListenerpublic SimpleCollectionModel(Collection<T> collection)
public void onShelve()
throws Exception
onShelve in interface IShelvedListenerExceptionpublic void onUnshelve()
throws Exception
onUnshelve in interface IShelvedListenerException@Nonnull public List<T> getItems(int start, int end) throws Exception
getItems in interface ITableModel<T>Exceptionpublic T getItem(int index) throws Exception
getItem in class TableModelBase<T>Exceptionpublic int getRows()
throws Exception
ITableModelgetRows in interface ITableModel<T>Exceptionpublic boolean add(T item) throws Exception
item, - the item to be added.Exceptionpublic boolean remove(T item) throws Exception
item, - the item to be removed.ExceptionCopyright © 2017 etc.to. All rights reserved.