org.tanager.ui
Class CPlaylistViewerTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.tanager.ui.CPlaylistViewerTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class CPlaylistViewerTableModel
extends javax.swing.table.AbstractTableModel

This class represents the tabular representation of the playlist, and it's used for displaying the playlist to the user. An AbstractTableModel is extended to provide the column heading names and song data for the current playlist. Each row describes a single song in the playlist, and the row's columns show the song's title, artist, album, and date downloaded.

Version:
$Revision: 1.2.2.1 $
Author:
Bob Lavey
See Also:
Serialized Form

Field Summary
private static java.lang.String[] columnNames
           Represents the column heading names.
private  java.util.Vector playlist_
           Represents the playlist vector.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CPlaylistViewerTableModel(java.util.Vector playlist)
           This is the only constructor allowed for a CPlaylistViewerTableModel object.
 
Method Summary
 int getColumnCount()
           This method returns the number of columns in this table.
 java.lang.String getColumnName(int col)
           This method returns the heading name for the given column.
 int getRowCount()
           This method returns the number of columns in this table.
 java.lang.Object getValueAt(int row, int col)
           This method returns the value for the given cell.
 boolean isCellEditable(int row, int col)
           This method returns true if the given cell is editable.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columnNames

private static final java.lang.String[] columnNames

Represents the column heading names.


playlist_

private java.util.Vector playlist_

Represents the playlist vector.

Constructor Detail

CPlaylistViewerTableModel

public CPlaylistViewerTableModel(java.util.Vector playlist)

This is the only constructor allowed for a CPlaylistViewerTableModel object. The caller must supply the playlist vector.

Parameters:
playlist - the playlist vector
Method Detail

getColumnName

public java.lang.String getColumnName(int col)

This method returns the heading name for the given column.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
col - the column whose heading name is being requested
Returns:

getRowCount

public int getRowCount()

This method returns the number of columns in this table.

Returns:
return the number of elements in the playlist vector

getColumnCount

public int getColumnCount()

This method returns the number of columns in this table.

Returns:
return the number of elements in the columns names array

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)

This method returns the value for the given cell.

Semantics:
  1. get the song that is to be displayed in the given row from the playlist vector
  2. if the cell is in column 0
    1. return the song's title
  3. if the cell is in column 1
    1. return the song's artist
  4. if the cell is in column 2
    1. return the song's album
  5. if the cell is in column 3
    1. return the song's date downloaded
  6. if the cell is not in column 0, 1, 2, or 3
    1. return an empty string

Parameters:
row - the cell's row
col - the cell's column
Returns:
the string value that is to be displayed in the given cell

isCellEditable

public boolean isCellEditable(int row,
                              int col)

This method returns true if the given cell is editable. Since this is a read=only table, we will always return false.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
row - the cell's row
col - the cell's column
Returns:
false always, since this is a read-only table