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

Quick Search    Search Deep

com.jgoodies.binding.tutorial.manager
Class AlbumManager  view AlbumManager download AlbumManager.java

java.lang.Object
  extended bycom.jgoodies.binding.tutorial.manager.AlbumManager

public final class AlbumManager
extends java.lang.Object

Holds a List of Albums and provides operations to add, delete and change a Album. Such a manager is often part of the domain layer.

This manager holds the Albums in an ArrayListModel, so we can operate on a List and can expose it as a ListModel. As an alternative, a higher-level presentation model, such as the AlbumManagerModel could turn the List into a ListModel. In the latter case, you would then need to fire the required ListDataEvents.

The AlbumManagerModel turns the List of Albums and the operations into a form that can be used in a user interface to display, select, and edit Albums.

TODO: Demonstrate how to sort the albums.

Version:
$Revision: 1.2 $

Field Summary
private  ArrayListModel managedAlbums
          Holds the List of Albums.
 
Constructor Summary
AlbumManager(java.util.List albums)
          Constructs a AlbumManager for the given list of Albums.
 
Method Summary
 void addItem(com.jgoodies.binding.tutorial.Album albumToAdd)
          Adds the given Album to the List of managed Albums and notifies observers of the managed Albums ListModel about the change.
 com.jgoodies.binding.tutorial.Album createItem()
          Creates and return a new Album.
 javax.swing.ListModel getManagedAlbums()
           
 void markItemChanged(int index)
          Notifies observers of the managed Albums ListModel about a changed Album at the given index
 void removeItem(com.jgoodies.binding.tutorial.Album albumToRemove)
          Removes the given Album from the List of managed Albums and notifies observers of the managed Albums ListModel about the change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

managedAlbums

private final ArrayListModel managedAlbums
Holds the List of Albums. Albums are added and removed from this List. The ObservableList implements ListModel, and so, we can directly use this List for the UI and can observe changes.

In a real world application this List may be held by a AlbumManager, or may be kept in synch with a DataBase.

Constructor Detail

AlbumManager

public AlbumManager(java.util.List albums)
Constructs a AlbumManager for the given list of Albums.

Method Detail

getManagedAlbums

public javax.swing.ListModel getManagedAlbums()

createItem

public com.jgoodies.binding.tutorial.Album createItem()
Creates and return a new Album.


addItem

public void addItem(com.jgoodies.binding.tutorial.Album albumToAdd)
Adds the given Album to the List of managed Albums and notifies observers of the managed Albums ListModel about the change.


markItemChanged

public void markItemChanged(int index)
Notifies observers of the managed Albums ListModel about a changed Album at the given index


removeItem

public void removeItem(com.jgoodies.binding.tutorial.Album albumToRemove)
Removes the given Album from the List of managed Albums and notifies observers of the managed Albums ListModel about the change.