Class PersistentList

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class PersistentList extends JPanel
Utility for managing a list of persistent objects. Uses a ListModel to manage a list of Objects. The id for an object is the String from "toString" method. Storing and fetching objects enforces id uniqueness.

An action event is sent when an object is selected. The event source is the selected object, or the listener can call getSelected().

(TBD) The first token of toString() must be a unique id (like a name). (TBD) Drag 'n Drop.
Version:
$Id: PersistentList.java,v 1.10 2007/07/06 20:45:32 jeffmc Exp $
Author:
John Caron
See Also:
  • Constructor Details

    • PersistentList

      public PersistentList(String objectName, PersistentStore store, String header)
      Constructor
      Parameters:
      objectName - name of list object in the PersistentStore
      store - where objects are stored
      header - field names placed at the top of the list
  • Method Details

    • addActionListener

      public void addActionListener(ActionListener l)
      add a "New Selection" listener
      Parameters:
      l -
    • removeActionListener

      public void removeActionListener(ActionListener l)
      remove a "New Selection" listener
      Parameters:
      l -
    • appendElement

      public void appendElement(Object o)
      _more_
      Parameters:
      o -
    • contains

      public boolean contains(String id)
      check if this id already exists
      Parameters:
      id -
      Returns:
      true if an Object with this id already exists in the list
    • replace

      public void replace(Object editedObject)
      find the object in the list with the same id as editedObject if it exists, replace it with editedObject. if it doesnt exist, add it to the end of the list.
      Parameters:
      editedObject - the edited object
    • deleteSelected

      public void deleteSelected()
      delete the currently selected object
    • getNumElements

      public int getNumElements()
      return the currently selected object
      Returns:
      _more_
    • getSelected

      public Object getSelected()
      return the currently selected object
      Returns:
      _more_
    • storePersistentData

      public void storePersistentData()
      save the list to the PersistentStore