com.lightdev.app.filemanager.ui
Class FileTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.lightdev.app.filemanager.ui.FileTableModel
All Implemented Interfaces:
Serializable, TableModel

public class FileTableModel
extends AbstractTableModel

a FileTableModel is used to display and manipulate an array of FileRef objects in a JTable or FileTable.

Version:
1, 12.01.2008
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the BSD License, for details see file license.txt in the distribution package of this software
See Also:
Serialized Form

Field Summary
static int COLUMN_FILE
          column index constant
static int COLUMN_ICON
          column index constant
static int COLUMN_LAST_MODIFIED
          column index constant
static int COLUMN_NAME
          column index constant
static int COLUMN_SIZE
          column index constant
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
FileTableModel(FileSystem fileSystem, FileRef[] files)
          create a new instance of class FileTableModel
 
Method Summary
 void addFile(FileRef file)
          add a file to this model
 void createFolder(FileRef inFolder)
          create a folder using the underlying file system
 void deleteFiles(FileRef[] files)
          delete a list of files using the underlying file system
 void extractArchive(FileRef archive, FileRef toFolder)
          extract a given ZIP archive using the underlying file system
 Class<?> getColumnClass(int columnIndex)
          get the class of the column with the given index
 int getColumnCount()
          get the number of columns in this model, hard wired to four columns: 1.
 int getRowCount()
          get the number of rows in this model
 Object getValueAt(int rowIndex, int columnIndex)
          get the value of a cell in this model (columnIndex = columnCount returns files[rowIndex])
 void packFolder(FileRef folder)
          build a zip archive with the contents of a given folder using the underlying file system
 void removeFile(FileRef file)
          remove a file from this model
 void removeFiles(FileRef[] filesToRemove)
          remove files from this model
 void renameFile(FileRef file, String newName)
          rename a file or folder
 void setFiles(FileRef[] files)
          et the files this model shall represent
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLUMN_ICON

public static final int COLUMN_ICON
column index constant

See Also:
Constant Field Values

COLUMN_NAME

public static final int COLUMN_NAME
column index constant

See Also:
Constant Field Values

COLUMN_SIZE

public static final int COLUMN_SIZE
column index constant

See Also:
Constant Field Values

COLUMN_LAST_MODIFIED

public static final int COLUMN_LAST_MODIFIED
column index constant

See Also:
Constant Field Values

COLUMN_FILE

public static final int COLUMN_FILE
column index constant

See Also:
Constant Field Values
Constructor Detail

FileTableModel

public FileTableModel(FileSystem fileSystem,
                      FileRef[] files)
create a new instance of class FileTableModel

Parameters:
fileSystem - the file system to use
files - the files to display
Method Detail

getColumnCount

public int getColumnCount()
get the number of columns in this model, hard wired to four columns: 1. Symbol 2. file name 3. file last modified (long; milliseconds since 1.1.1970) 4. file length in bytes (long)

Returns:
column count

getRowCount

public int getRowCount()
get the number of rows in this model

Returns:
row count

getColumnClass

public Class<?> getColumnClass(int columnIndex)
get the class of the column with the given index

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
columnIndex - index of column to get the class for

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
get the value of a cell in this model (columnIndex = columnCount returns files[rowIndex])

Parameters:
rowIndex - the row that has the cell in question
columnIndex - the column that has the cell in question
Returns:
the cell value

setFiles

public void setFiles(FileRef[] files)
et the files this model shall represent

Parameters:
files - the file

addFile

public void addFile(FileRef file)
add a file to this model

Parameters:
file - the file to add

removeFile

public void removeFile(FileRef file)
remove a file from this model

Parameters:
file -

removeFiles

public void removeFiles(FileRef[] filesToRemove)
remove files from this model

Parameters:
filesToRemove - the files to remove

packFolder

public void packFolder(FileRef folder)
build a zip archive with the contents of a given folder using the underlying file system

Parameters:
folder - the folder whose contents are to be packed

deleteFiles

public void deleteFiles(FileRef[] files)
                 throws Throwable
delete a list of files using the underlying file system

Parameters:
files - the files to delete
Throws:
Throwable

extractArchive

public void extractArchive(FileRef archive,
                           FileRef toFolder)
                    throws Throwable
extract a given ZIP archive using the underlying file system

Parameters:
archive - the ZIP archive to extract
toFolder - the folder to extract to
Throws:
Throwable

createFolder

public void createFolder(FileRef inFolder)
                  throws Throwable
create a folder using the underlying file system

Parameters:
inFolder - the folder to create a new folder in
Throws:
Throwable

renameFile

public void renameFile(FileRef file,
                       String newName)
                throws Throwable
rename a file or folder

Parameters:
file - the flile or folder to rename
newName - the new name to set
Throws:
Throwable