lejos.pc.tools
Class ExtendedFileModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by lejos.pc.tools.ExtendedFileModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class ExtendedFileModel
extends javax.swing.table.AbstractTableModel

Swing Table Model for manipulating NXT files.

Author:
Lawrie Griffiths
See Also:
Serialized Form

Field Summary
static int COL_DELETE
           
static int COL_NAME
           
static int COL_SIZE
           
static int MAX_FILES
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ExtendedFileModel()
          Fetch files from the NXT and create the model
 
Method Summary
 void delete(java.lang.String fileName, int row)
          Delete a file on the NXT and update the model
 java.lang.String fetchFiles(NXTCommand nxtCommand)
          Fetch the files from the NXT
 java.lang.Class<?> getColumnClass(int column)
          Get the class of a specific column
 int getColumnCount()
          Get the number of columns in the mode
 java.lang.String getColumnName(int column)
          Get the name of a column
 FileInfo getFile(int i)
          Get the FileInfo object for a specific file
 int getRow(java.lang.String fileName)
          Return the row for a given file
 int getRowCount()
          Get the number of rows in the model
 java.lang.Object getValueAt(int row, int column)
          Get the object at the specified location
 boolean isCellEditable(int row, int column)
          Check if a cell is editable
 int numFiles()
          Return the number of files
 void setValueAt(java.lang.Object value, int row, int column)
          Set the value of a cell
 
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
 

Field Detail

MAX_FILES

public static final int MAX_FILES
See Also:
Constant Field Values

COL_NAME

public static final int COL_NAME
See Also:
Constant Field Values

COL_SIZE

public static final int COL_SIZE
See Also:
Constant Field Values

COL_DELETE

public static final int COL_DELETE
See Also:
Constant Field Values
Constructor Detail

ExtendedFileModel

public ExtendedFileModel()
Fetch files from the NXT and create the model

Parameters:
nxtCommand - used to send LCP commands to the NXT
Method Detail

delete

public void delete(java.lang.String fileName,
                   int row)
            throws java.io.IOException
Delete a file on the NXT and update the model

Parameters:
fileName - the file to delete
row - the row in the file model
Throws:
java.io.IOException

getRowCount

public int getRowCount()
Get the number of rows in the model

Returns:
the number of files in the model

getColumnCount

public int getColumnCount()
Get the number of columns in the mode

Returns:
the column count

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Get the object at the specified location

Returns:
the object at the specified location

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int column)
Set the value of a cell

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

getColumnName

public java.lang.String getColumnName(int column)
Get the name of a column

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Returns:
the column name

getColumnClass

public java.lang.Class<?> getColumnClass(int column)
Get the class of a specific column

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Returns:
the class of the column

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Check if a cell is editable

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Returns:
true iff the cell is editable

fetchFiles

public java.lang.String fetchFiles(NXTCommand nxtCommand)
Fetch the files from the NXT

Returns:
null for success or the error message

getFile

public FileInfo getFile(int i)
Get the FileInfo object for a specific file

Parameters:
i - the row number of the file
Returns:
the FileInfo object

numFiles

public int numFiles()
Return the number of files

Returns:
the number of files

getRow

public int getRow(java.lang.String fileName)
Return the row for a given file

Parameters:
fileName - the filename
Returns:
the row of -1 if not found