dsto.dfc.swing.undo
Class EditListModel

java.lang.Object
  extended by dsto.dfc.swing.undo.EditListModel
All Implemented Interfaces:
Serializable, ListModel

public class EditListModel
extends Object
implements ListModel, Serializable

Implementation of a JList ListModel that stores UndoableEdits, for use by the MonitoredUndoManager. The EditListModel fire ListDataEvents.

Version:
$Revision$
Author:
Derek Weber, Peter J Smet
See Also:
MonitoredUndoManager, ListModel, Serialized Form

Field Summary
protected  List list
          The list of UndoableEdits.
protected  EventListenerList listenerList
          For managing ListDataListeners.
 
Constructor Summary
EditListModel()
          Empty constructor for bean serialisation.
EditListModel(List edits)
          Constructs an EditListModel from the list of edits provided.
 
Method Summary
 void add(int index, Object element)
           
 boolean add(Object o)
           
 void addListDataListener(ListDataListener l)
          Add a listener to the list that's notified each time a change to the data model occurs.
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(List edits)
           
 boolean doesNotContainAll(List edits)
           
protected  void fireContentsChanged(Object source, int index0, int index1)
          EditListModel subclasses must call this method after one or more elements of the list change.
protected  void fireIntervalAdded(Object source, int index0, int index1)
          EditListModel subclasses must call this method after one or more elements are added to the model.
protected  void fireIntervalRemoved(Object source, int index0, int index1)
          EditListModel subclasses must call this method after one or more elements are removed from the model.
 Object get(int index)
           
 UndoableEdit getEdit(int index)
           
 List getEdits()
          Returns a list containing the EditListModel's edits.
 Object getElementAt(int index)
           
 EventListener[] getListeners(Class listenerType)
          Return an array of all the listeners of the given type that were added to this model.
 int getSize()
           
 int indexOf(Object o)
           
 boolean isEmpty()
           
 Object remove(int index)
           
 void remove(Object editToBeRemoved)
           
 void removeAll(List editsToBeRemoved)
           
 void removeListDataListener(ListDataListener l)
          Remove a listener from the list that's notified each time a change to the data model occurs.
 Object set(int index, Object element)
           
 void setEdits(List edits)
          Only to be used by the Deserializer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

protected transient EventListenerList listenerList
For managing ListDataListeners.


list

protected List list
The list of UndoableEdits.

Constructor Detail

EditListModel

public EditListModel()
Empty constructor for bean serialisation.


EditListModel

public EditListModel(List edits)
Constructs an EditListModel from the list of edits provided. It pulls the edits out of the list, however, rather than simply using the List provided.

Method Detail

getEdits

public List getEdits()
Returns a list containing the EditListModel's edits. NB Please don't modify this list or these edits. Cannot return a Collections unmodifiable list because of serialisation issues.


setEdits

public void setEdits(List edits)
Only to be used by the Deserializer.


getElementAt

public Object getElementAt(int index)
Specified by:
getElementAt in interface ListModel

clear

public void clear()

isEmpty

public boolean isEmpty()

getSize

public int getSize()
Specified by:
getSize in interface ListModel

contains

public boolean contains(Object o)

add

public boolean add(Object o)

get

public Object get(int index)

getEdit

public UndoableEdit getEdit(int index)

set

public Object set(int index,
                  Object element)

add

public void add(int index,
                Object element)

remove

public Object remove(int index)

remove

public void remove(Object editToBeRemoved)

removeAll

public void removeAll(List editsToBeRemoved)

doesNotContainAll

public boolean doesNotContainAll(List edits)

containsAll

public boolean containsAll(List edits)

indexOf

public int indexOf(Object o)

addListDataListener

public void addListDataListener(ListDataListener l)
Add a listener to the list that's notified each time a change to the data model occurs.

Specified by:
addListDataListener in interface ListModel
Parameters:
l - the ListDataListener

removeListDataListener

public void removeListDataListener(ListDataListener l)
Remove a listener from the list that's notified each time a change to the data model occurs.

Specified by:
removeListDataListener in interface ListModel
Parameters:
l - the ListDataListener

fireContentsChanged

protected void fireContentsChanged(Object source,
                                   int index0,
                                   int index1)
EditListModel subclasses must call this method after one or more elements of the list change. The changed elements are specified by a closed interval index0, index1, i.e. the range that includes both index0 and index1. Note that index0 need not be less than or equal to index1.

Parameters:
source - The ListModel that changed, typically "this".
index0 - One end of the new interval.
index1 - The other end of the new interval.
See Also:
EventListenerList

fireIntervalAdded

protected void fireIntervalAdded(Object source,
                                 int index0,
                                 int index1)
EditListModel subclasses must call this method after one or more elements are added to the model. The new elements are specified by a closed interval index0, index1, i.e. the range that includes both index0 and index1. Note that index0 need not be less than or equal to index1.

Parameters:
source - The ListModel that changed, typically "this".
index0 - One end of the new interval.
index1 - The other end of the new interval.
See Also:
EventListenerList

fireIntervalRemoved

protected void fireIntervalRemoved(Object source,
                                   int index0,
                                   int index1)
EditListModel subclasses must call this method after one or more elements are removed from the model. The new elements are specified by a closed interval index0, index1, i.e. the range that includes both index0 and index1. Note that index0 need not be less than or equal to index1.

Parameters:
source - The ListModel that changed, typically "this".
index0 - One end of the new interval.
index1 - The other end of the new interval.
See Also:
EventListenerList

getListeners

public EventListener[] getListeners(Class listenerType)
Return an array of all the listeners of the given type that were added to this model.

Since:
1.3


Copyright © 2008 Commonwealth of Australia