net.shredzone.ifish.gui
Class NaviDbTableModel

java.lang.Object
  extended by net.shredzone.ifish.db.NaviDb
      extended by net.shredzone.ifish.gui.NaviDbTableModel
All Implemented Interfaces:
TableModel

public class NaviDbTableModel
extends NaviDb
implements TableModel

This is an extension of the NaviDb class to make it usable in JTables.

Version:
$Id: NaviDbTableModel.java 291 2009-04-28 21:29:27Z shred $

Field Summary
protected  List<Entry> lSequence
           
 
Fields inherited from class net.shredzone.ifish.db.NaviDb
sEntries
 
Constructor Summary
NaviDbTableModel()
          Create a new, empty NaviDbTableModel.
NaviDbTableModel(File file, String charset)
          Create a database and fill it with a database file.
 
Method Summary
 void addEntry(Entry entry)
          Add an entry to the database.
 void addTableModelListener(TableModelListener l)
          Add a TableModelListener.
protected  void fireTableModelEvent(int row)
          Fire a model event.
 Class<?> getColumnClass(int columnIndex)
          Get the class that represents the column.
 int getColumnCount()
          Get the number of columns
 String getColumnName(int columnIndex)
          Get the column title.
 Entry getEntryAt(int rowIndex)
          Get the entry of a certain row.
 int getRowCount()
          Get the number of rows.
 Object getValueAt(int rowIndex, int columnIndex)
          Get the value of a certain cell.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Check if a cell is editable.
 void removeEntry(Entry entry)
          Remove an entry from the database.
 void removeTableModelListener(TableModelListener l)
          Remove a TableModelListener.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
          Change the value of a cell.
 
Methods inherited from class net.shredzone.ifish.db.NaviDb
exportFile, exportFile, getAddCounter, getCreationDate, getEntry, getEntry, getRemoveCounter, getUpdateCounter, importFile, importFile, iterator, knowsFile, modifiedFile, resetCounters, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lSequence

protected final List<Entry> lSequence
Constructor Detail

NaviDbTableModel

public NaviDbTableModel()
Create a new, empty NaviDbTableModel.


NaviDbTableModel

public NaviDbTableModel(File file,
                        String charset)
                 throws IOException,
                        DatabaseException,
                        UnsupportedEncodingException
Create a database and fill it with a database file.

Parameters:
file - Database file to be read
charset - Desired Charset
Throws:
IOException - File was erraneous or could not be read
DatabaseException - An error occured during database creation
UnsupportedEncodingException - Charset not known
Method Detail

getRowCount

public int getRowCount()
Get the number of rows.

Specified by:
getRowCount in interface TableModel
Returns:
Number of Rows (entries)

getColumnCount

public int getColumnCount()
Get the number of columns

Specified by:
getColumnCount in interface TableModel
Returns:
Number of Columns

getColumnName

public String getColumnName(int columnIndex)
Get the column title.

Specified by:
getColumnName in interface TableModel
Parameters:
columnIndex - Addressed column
Returns:
It's title

getColumnClass

public Class<?> getColumnClass(int columnIndex)
Get the class that represents the column.

Specified by:
getColumnClass in interface TableModel
Parameters:
columnIndex - Addressed column
Returns:
The representing class

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Check if a cell is editable. Will always return false.

Specified by:
isCellEditable in interface TableModel
Parameters:
rowIndex - Addressed Row
columnIndex - Addressed Column
Returns:
true: editable, false: immutable

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Get the value of a certain cell.

Specified by:
getValueAt in interface TableModel
Parameters:
rowIndex - Addressed Row
columnIndex - Addressed Column
Returns:
Value of this cell

getEntryAt

public Entry getEntryAt(int rowIndex)
Get the entry of a certain row.

Parameters:
rowIndex - Addressed Row
Returns:
Entry

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Change the value of a cell. This is unsupported.

Specified by:
setValueAt in interface TableModel
Parameters:
aValue - New value
rowIndex - Addressed Row
columnIndex - Addressed Column

addTableModelListener

public void addTableModelListener(TableModelListener l)
Add a TableModelListener.

Specified by:
addTableModelListener in interface TableModel
Parameters:
l - TableModelListener to add.

removeTableModelListener

public void removeTableModelListener(TableModelListener l)
Remove a TableModelListener. If it was not added, nothing will happen.

Specified by:
removeTableModelListener in interface TableModel
Parameters:
l - TableModelListener to be removed.

fireTableModelEvent

protected void fireTableModelEvent(int row)
Fire a model event.

Parameters:
row - Affected row

addEntry

public void addEntry(Entry entry)
              throws DatabaseException
Add an entry to the database.

Overrides:
addEntry in class NaviDb
Parameters:
entry - Entry to be added
Throws:
DatabaseException

removeEntry

public void removeEntry(Entry entry)
Remove an entry from the database. If the entry does not exist, nothing will happen.

Overrides:
removeEntry in class NaviDb
Parameters:
entry - Entry to be removed


Copyright © 2007-2011 shredzone.org. All Rights Reserved.