Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.scopemvc.model.collection
Class ListModelAdaptor  view ListModelAdaptor download ListModelAdaptor.java

java.lang.Object
  extended byorg.scopemvc.model.basic.BasicModel
      extended byorg.scopemvc.model.collection.ListModelAdaptor
All Implemented Interfaces:
org.scopemvc.core.ModelChangeEventSource, org.scopemvc.core.ModelChangeListener, org.scopemvc.core.ModelChangeTypes

public class ListModelAdaptor
extends org.scopemvc.model.basic.BasicModel
implements org.scopemvc.core.ModelChangeListener

Used to present a list of ListModelSources as an active BasicModel. Useful when initialising org.scopemvc.view.swing.SComboBox or org.scopemvc.view.swing.SList with a static list of data.

This will propogate ModelChangeEvents from sublists that are ModelChangeEventSources. Note that this adaptor registers as a listener with such sublists: it may be necessary to manually unregister with removeModelChangeListeners() 55 if an adaptor is no longer needed.

The adaptor can present its ListModelSources as a sorted list if a Comparator is passed to setComparator(java.util.Comparator) 55 or all list elements implement Comparable and setSorted(boolean) 55 is called.

Version:
$Revision: 1.4 $ $Date: 2002/01/12 09:35:40 $

Field Summary
private  java.util.Comparator comparator
           
private  java.util.List list
           
static org.scopemvc.core.Selector LIST_SELECTOR
           
static org.scopemvc.core.Selector LIST_SIZE_SELECTOR
           
private  ListModelSource[] listSources
           
private  boolean sorted
           
 
Fields inherited from class org.scopemvc.model.basic.BasicModel
 
Fields inherited from interface org.scopemvc.core.ModelChangeTypes
ACCESS_CHANGED, VALUE_ADDED, VALUE_CHANGED, VALUE_REMOVED
 
Constructor Summary
ListModelAdaptor(ListModelSource listSource)
           
ListModelAdaptor(ListModelSource[] listSources)
           
 
Method Summary
 java.lang.Object getElementAt(int inIndex)
           
 java.util.List getList()
           
 int getSize()
           
private  boolean isListChangeEvent(org.scopemvc.core.ModelChangeEvent inEvent)
           
 boolean isSorted()
           
protected  void loadList()
           
 void modelChanged(org.scopemvc.core.ModelChangeEvent inEvent)
           Invoked to notify listeners of a change in the state of a ModelChangeEventSource.
 void removeModelChangeListeners()
           
 void setComparator(java.util.Comparator inComparator)
           
 void setSorted(boolean inSorted)
           
 
Methods inherited from class org.scopemvc.model.basic.BasicModel
addModelChangeListener, fireModelChange, listenNewSubmodel, makeActive, removeModelChangeListener, unlistenOldSubmodel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST_SELECTOR

public static final org.scopemvc.core.Selector LIST_SELECTOR

LIST_SIZE_SELECTOR

public static final org.scopemvc.core.Selector LIST_SIZE_SELECTOR

list

private java.util.List list

listSources

private ListModelSource[] listSources

sorted

private boolean sorted

comparator

private java.util.Comparator comparator
Constructor Detail

ListModelAdaptor

public ListModelAdaptor(ListModelSource[] listSources)

ListModelAdaptor

public ListModelAdaptor(ListModelSource listSource)
Method Detail

removeModelChangeListeners

public void removeModelChangeListeners()

modelChanged

public void modelChanged(org.scopemvc.core.ModelChangeEvent inEvent)
Description copied from interface: org.scopemvc.core.ModelChangeListener

Invoked to notify listeners of a change in the state of a org.scopemvc.core.ModelChangeEventSource.

Specified by:
modelChanged in interface org.scopemvc.core.ModelChangeListener

isListChangeEvent

private boolean isListChangeEvent(org.scopemvc.core.ModelChangeEvent inEvent)

getList

public java.util.List getList()

getSize

public int getSize()

getElementAt

public java.lang.Object getElementAt(int inIndex)

isSorted

public boolean isSorted()

setSorted

public void setSorted(boolean inSorted)

setComparator

public void setComparator(java.util.Comparator inComparator)

loadList

protected void loadList()