Mp3dings 
20100427

net.sourceforge.mp3dings
Class DataTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by net.sourceforge.mp3dings.AbstractTableModel
          extended by net.sourceforge.mp3dings.DataTableModel
All Implemented Interfaces:
HeaderPopupTableModel, SortableTableModel, Serializable, TableModel, FieldAssociatedTableModel, Mp3dingsTableModel

public final class DataTableModel
extends AbstractTableModel

This class serves as the table model for the spreadsheet of the mp3dings "Data" tab. It provides functionality to

Version:
$Revision: 125 $ ($Date: 2007-12-22 15:31:36 +0100 (Sa, 22 Dez 2007) $)
Author:
Moritz Ringler
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sourceforge.mp3dings.AbstractTableModel
AbstractTableModel.UpdateRunnable
 
Field Summary
 
Fields inherited from class net.sourceforge.mp3dings.AbstractTableModel
aggregator, filters
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface de.mospace.swing.table.SortableTableModel
ASCENDING, DESCENDING
 
Constructor Summary
DataTableModel()
          Creates a new instance of this class.
 
Method Summary
 void addFilenameInfo(Frame owner)
          Guesses artist, track and title from each filename.
 void addFiles(File[] nf)
          Adds several files to the workspace.
 void addID3v(int ntag, Frame owner)
          Reads information from the ID3v1 or ID3v2 tags.
 void addRecursively(File[] files, Frame owner)
          Recursively grabs files from directories and adds them to the model.
 void clearFiles(Frame owner)
          Removes all files from the workspace.
 Field[] getAllowedFields()
          Gets the allowedFields attribute of the DataTableModel object
 Field[] getDefaultFields()
          Gets the defaultFields attribute of the DataTableModel object
 boolean getEditable(Field field)
          Returns whether values of the specified field can be edited in this table.
 Object getFieldValue(int entry, Field field)
          Gets a field value from the table.
 File getFile(int row)
          Gets the file associated with the specified row.
 Field[] getPersistentFields()
          Gets the persistentFields attribute of the DataTableModel object
 String getPrefKey()
          Gets the prefKey attribute of the DataTableModel object
 void queryDatabase(MainFrame owner)
           
 void removeRows(int[] rows)
          Removes the files in rows rows[] from the workspace.
protected  List reorganizeData(int[] old2new, int newlength)
          Description of the Method
protected  void setData(List v)
          Sets the data attribute of the DataTableModel object
 void setFile(File f, int row)
          Associates the specified row with file f.
 void silentlySetFile(File f, int row)
          Associates the specified row with file f.
 
Methods inherited from class net.sourceforge.mp3dings.AbstractTableModel
addDataChangeListener, addMessageListener, addRowsToSorter, buildFilters, discardChanges, fireAllColumnsUpdated, fireDataChanged, fireDataChanged, fireMessageSent, fireMessageSent, get, getColumn, getColumnClass, getColumnCount, getColumnName, getEntries, getEntries, getField, getFields, getFilterEditPopup, getFilterEditPopup, getFilters, getHeaderPopup, getNextDuplicates, getPrefs, getRowCount, getRows, getRows, getSortingColumn, getSortOrder, getValueAt, init, isCellEditable, isFiltered, isSorted, randomize, remAllRowsFromSorter, removeDataChangeListener, removeMessageListener, remRowFromSorter, remRowFromSorter, resetChangeCounter, set, set, setSortBy, setSortBy, setSortBy, setSorted, setValueAt, setValueAt, sort
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.mp3dings.Mp3dingsTableModel
fireTableDataChanged
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
 

Constructor Detail

DataTableModel

public DataTableModel()
Creates a new instance of this class.

Method Detail

getAllowedFields

public Field[] getAllowedFields()
Gets the allowedFields attribute of the DataTableModel object

Returns:
The allowedFields value

getPersistentFields

public Field[] getPersistentFields()
Gets the persistentFields attribute of the DataTableModel object

Returns:
The persistentFields value

getEditable

public boolean getEditable(Field field)
Returns whether values of the specified field can be edited in this table.

Specified by:
getEditable in interface FieldAssociatedTableModel
Specified by:
getEditable in class AbstractTableModel
Parameters:
field - the field to (not) edit
Returns:
whether values of field can be edited
See Also:
AbstractTableModel.isCellEditable(int, int)

getDefaultFields

public Field[] getDefaultFields()
Gets the defaultFields attribute of the DataTableModel object

Returns:
The defaultFields value

getFieldValue

public Object getFieldValue(int entry,
                            Field field)
Gets a field value from the table.

Parameters:
entry - Mp3 file identifier.
field - Field identifier.
Returns:
The fieldValue value

addFilenameInfo

public void addFilenameInfo(Frame owner)
Guesses artist, track and title from each filename. Adds the information gathered in this way to the spreadsheet.

Parameters:
owner - The feature to be added to the FilenameInfo attribute

addFiles

public void addFiles(File[] nf)
Adds several files to the workspace.

Parameters:
nf - array of mp3-files that will be added

clearFiles

public void clearFiles(Frame owner)
Removes all files from the workspace.

Parameters:
owner - Description of the Parameter

removeRows

public void removeRows(int[] rows)
Removes the files in rows rows[] from the workspace.

Parameters:
rows - Array contaning the rows to be removed

reorganizeData

protected List reorganizeData(int[] old2new,
                              int newlength)
Description of the Method

Specified by:
reorganizeData in class AbstractTableModel
Parameters:
old2new - Description of the Parameter
newlength - Description of the Parameter
Returns:
Description of the Return Value

setData

protected void setData(List v)
Sets the data attribute of the DataTableModel object

Specified by:
setData in class AbstractTableModel
Parameters:
v - The new data value

addRecursively

public void addRecursively(File[] files,
                           Frame owner)
Recursively grabs files from directories and adds them to the model.

Parameters:
files - Input list of mp3-files (f) and directories (d)
owner - The feature to be added to the Recursively attribute

addID3v

public void addID3v(int ntag,
                    Frame owner)
Reads information from the ID3v1 or ID3v2 tags. Updates the spreadsheet

Parameters:
ntag - 1 for ID3v1, 2 for ID3v2. If tag is neither the method returns without doing anything.
owner - The feature to be added to the ID3v attribute

queryDatabase

public void queryDatabase(MainFrame owner)

getFile

public File getFile(int row)
Gets the file associated with the specified row.

Specified by:
getFile in interface Mp3dingsTableModel
Specified by:
getFile in class AbstractTableModel
Parameters:
row - A spreadsheet row
Returns:
The file associated with that row

setFile

public void setFile(File f,
                    int row)
Associates the specified row with file f.

Parameters:
f - The new file value
row - The new file value

silentlySetFile

public void silentlySetFile(File f,
                            int row)
Associates the specified row with file f.

Parameters:
f - Description of the Parameter
row - Description of the Parameter

getPrefKey

public String getPrefKey()
Gets the prefKey attribute of the DataTableModel object

Returns:
The prefKey value

Mp3dings 
20100427