to.etc.domui.component.tbl
Class SimpleCollectionModel<T>

java.lang.Object
  extended by to.etc.domui.component.tbl.TableModelBase<T>
      extended by to.etc.domui.component.tbl.SimpleCollectionModel<T>
Type Parameters:
T -
All Implemented Interfaces:
ITableModel<T>, IShelvedListener

Deprecated.

@Deprecated
public class SimpleCollectionModel<T>
extends TableModelBase<T>
implements IShelvedListener

DEPRECATED Use SimpleListModel instead. The SimpleCollectionModel is a very basic model that directly represents a collection.

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.

Author:
Willem

Field Summary
 
Fields inherited from interface to.etc.domui.component.tbl.ITableModel
DEFAULT_MAX_SIZE
 
Constructor Summary
SimpleCollectionModel(java.util.Collection<T> collection)
          Deprecated.  
 
Method Summary
 boolean add(T item)
          Deprecated. Tries to add an item to the model's collection.
 T getItem(int index)
          Deprecated.  
 java.util.List<T> getItems(int start, int end)
          Deprecated.  
protected  java.util.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.
 
Methods inherited from class to.etc.domui.component.tbl.TableModelBase
addChangeListener, fireAdded, fireDeleted, fireModelChanged, fireModified, getListeners, refresh, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleCollectionModel

public SimpleCollectionModel(java.util.Collection<T> collection)
Deprecated. 
Method Detail

getList

protected java.util.List<T> getList()
                             throws java.lang.Exception
Deprecated. 
Throws:
java.lang.Exception

onShelve

public void onShelve()
              throws java.lang.Exception
Deprecated. 
Specified by:
onShelve in interface IShelvedListener
Throws:
java.lang.Exception

onUnshelve

public void onUnshelve()
                throws java.lang.Exception
Deprecated. 
Specified by:
onUnshelve in interface IShelvedListener
Throws:
java.lang.Exception

getItems

public java.util.List<T> getItems(int start,
                                  int end)
                           throws java.lang.Exception
Deprecated. 
Specified by:
getItems in interface ITableModel<T>
Throws:
java.lang.Exception

getItem

public T getItem(int index)
          throws java.lang.Exception
Deprecated. 
Specified by:
getItem in class TableModelBase<T>
Throws:
java.lang.Exception

getRows

public int getRows()
            throws java.lang.Exception
Deprecated. 
Description copied from interface: ITableModel
This must return the total #of rows in this table.

Specified by:
getRows in interface ITableModel<T>
Returns:
Throws:
java.lang.Exception

add

public boolean add(T item)
            throws java.lang.Exception
Deprecated. 
Tries to add an item to the model's collection. When the collection changed during the operation, the according listeners will be notified.

Parameters:
item, - the item to be added.
Returns:
true if the collection changed, false otherwise.
Throws:
java.lang.Exception

remove

public boolean remove(T item)
               throws java.lang.Exception
Deprecated. 
Tries to remove an item from the model's collection. When the collection changed during the operation, the according listeners will be notified.

Parameters:
item, - the item to be removed.
Returns:
true if the collection changed, false otherwise.
Throws:
java.lang.Exception