de.matthiasmann.twl.model
Class SimpleMRUListModel<T>

java.lang.Object
  extended by de.matthiasmann.twl.model.SimpleMRUListModel<T>
Type Parameters:
T - the data type stored in this MRU model
All Implemented Interfaces:
ListModel<T>, MRUListModel<T>
Direct Known Subclasses:
PersistentMRUListModel

public class SimpleMRUListModel<T>
extends java.lang.Object
implements MRUListModel<T>

A non persistent MRU list implementation


Nested Class Summary
 
Nested classes/interfaces inherited from interface de.matthiasmann.twl.model.ListModel
ListModel.ChangeListener
 
Field Summary
protected  java.util.ArrayList<T> entries
           
protected  ListModel.ChangeListener[] listeners
           
protected  int maxEntries
           
 
Constructor Summary
SimpleMRUListModel(int maxEntries)
           
 
Method Summary
 void addChangeListener(ListModel.ChangeListener listener)
           
 void addEntry(T entry)
          Adds an entry to this MRU model.
protected  void doDeleteEntry(int idx)
           
 T getEntry(int index)
           
 java.lang.Object getEntryTooltip(int index)
           
 int getMaxEntries()
          Returns the maximum number of entries stored in this MRU list
 int getNumEntries()
           
 boolean matchPrefix(int index, java.lang.String prefix)
           
 void removeChangeListener(ListModel.ChangeListener listener)
           
 void removeEntry(int index)
          Removes the entry at the given index
protected  void saveEntries()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entries

protected final java.util.ArrayList<T> entries

maxEntries

protected final int maxEntries

listeners

protected ListModel.ChangeListener[] listeners
Constructor Detail

SimpleMRUListModel

public SimpleMRUListModel(int maxEntries)
Method Detail

getMaxEntries

public int getMaxEntries()
Description copied from interface: MRUListModel
Returns the maximum number of entries stored in this MRU list

Specified by:
getMaxEntries in interface MRUListModel<T>
Returns:
the maximum number of entries stored in this MRU list

getNumEntries

public int getNumEntries()
Specified by:
getNumEntries in interface ListModel<T>
Specified by:
getNumEntries in interface MRUListModel<T>

getEntry

public T getEntry(int index)
Specified by:
getEntry in interface ListModel<T>
Specified by:
getEntry in interface MRUListModel<T>

addEntry

public void addEntry(T entry)
Description copied from interface: MRUListModel
Adds an entry to this MRU model. If the entry is already in the MRU list, then it is moved to the from.

Specified by:
addEntry in interface MRUListModel<T>
Parameters:
entry - the entry
See Also:
Object.equals(java.lang.Object)

removeEntry

public void removeEntry(int index)
Description copied from interface: MRUListModel
Removes the entry at the given index

Specified by:
removeEntry in interface MRUListModel<T>

addChangeListener

public void addChangeListener(ListModel.ChangeListener listener)
Specified by:
addChangeListener in interface ListModel<T>
Specified by:
addChangeListener in interface MRUListModel<T>

removeChangeListener

public void removeChangeListener(ListModel.ChangeListener listener)
Specified by:
removeChangeListener in interface ListModel<T>
Specified by:
removeChangeListener in interface MRUListModel<T>

doDeleteEntry

protected void doDeleteEntry(int idx)

saveEntries

protected void saveEntries()

getEntryTooltip

public java.lang.Object getEntryTooltip(int index)
Specified by:
getEntryTooltip in interface ListModel<T>

matchPrefix

public boolean matchPrefix(int index,
                           java.lang.String prefix)
Specified by:
matchPrefix in interface ListModel<T>