SPT Core API

com.sptci.echo.tree.filesystem
Class DirectoryTableModel

java.lang.Object
  extended by nextapp.echo.app.table.AbstractTableModel
      extended by com.sptci.echo.table.AbstractTableModel<D>
          extended by com.sptci.echo.table.TableModel<D>
              extended by com.sptci.echo.table.DefaultPageableTableModel<File>
                  extended by com.sptci.echo.tree.filesystem.DirectoryTableModel
All Implemented Interfaces:
PageableTableModel, SortableTableModel, Serializable, TableModel

public class DirectoryTableModel
extends DefaultPageableTableModel<File>
implements SortableTableModel

A table model that represents all the files under a directory.

The following keys must be configured in the localisation files for the column names:

© Copyright 2009 Sans Pareil Technologies, Inc.

Version:
$Id: DirectoryTableModel.java 4858 2009-08-11 15:52:14Z rakesh $
Author:
Rakesh 2009-06-15
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sptci.echo.table.SortableTableModel
SortableTableModel.Direction
 
Field Summary
protected static String[] columnNames
          The array of column name keys for the model.
protected  SimpleDateFormat dateFormat
          The date formatter used to format the file last modification time.
protected  File directory
          The directory whose contents are being displayed in the model.
 
Fields inherited from class com.sptci.echo.table.DefaultPageableTableModel
page, pageSize, totalRows
 
Fields inherited from class com.sptci.echo.table.TableModel
columns, data
 
Fields inherited from class com.sptci.echo.table.AbstractTableModel
sortDirection, sortIndex
 
Constructor Summary
DirectoryTableModel(File directory)
          Create a new model for the specified directory.
 
Method Summary
 Class getColumnClass(int column)
          Over-ridden to always return String.class.
 int getColumnCount()
          Returns the number of columns displayed in the table.
 String getColumnName(int column)
          Returns the name of the specified column.
 File getDirectory()
           
 SortableTableModel.Direction getSortDirection(int column)
          Return the sort direction for the specified column.
 Object getValueAt(int column, int row)
          Return the value at the specified coordinate in the table.
 void init()
          Over-ridden to do nothing as no processing is required.
 void setDirectory(File directory)
          Set the directory to display in this model.
 void setPage(int page)
          Set the page currently displayed in the model.
 void setPageSize(int pageSize)
          Set the number of rows to display in a page.
 void sort(int column)
          Sort the data by the values in the specified column index.
 void sort(int column, SortableTableModel.Direction direction)
          Sort the data by the values in the specified column index.
 
Methods inherited from class com.sptci.echo.table.DefaultPageableTableModel
getPage, getPageSize, getTotalPages, setPageSize
 
Methods inherited from class com.sptci.echo.table.TableModel
addRow, deleteRow, deleteRow, getColumnAnnotations, getObjectAt, getRowCount, insertRow, processColumnAnnotations, processColumns, processColumnsAnnotation, processFields, updateRow
 
Methods inherited from class nextapp.echo.app.table.AbstractTableModel
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getEventListenerList, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columnNames

protected static final String[] columnNames
The array of column name keys for the model.


directory

protected File directory
The directory whose contents are being displayed in the model.


dateFormat

protected SimpleDateFormat dateFormat
The date formatter used to format the file last modification time.

Constructor Detail

DirectoryTableModel

public DirectoryTableModel(File directory)
Create a new model for the specified directory.

Parameters:
directory - The directory whose contents are to be displayed.
Method Detail

getSortDirection

public SortableTableModel.Direction getSortDirection(int column)
Return the sort direction for the specified column.

Specified by:
getSortDirection in interface SortableTableModel
Overrides:
getSortDirection in class AbstractTableModel<File>
Parameters:
column - The column whose sort direction is to be returned.
Returns:
The sort direction for the column. Return null if no sort directive is available.

sort

public void sort(int column)
Sort the data by the values in the specified column index. The SortableTableModel.Direction of sorting is inferred from the current sort order.

Specified by:
sort in interface SortableTableModel
Parameters:
column - The index of the column by which the data is to be sorted.
See Also:
AbstractTableModel.fireTableDataChanged()

sort

public void sort(int column,
                 SortableTableModel.Direction direction)
Sort the data by the values in the specified column index.

Specified by:
sort in interface SortableTableModel
Parameters:
column - The index of the column by which the data is to be sorted.
direction - The direction in which the data is to be sorted.
See Also:
AbstractTableModel.fireTableDataChanged()

setPage

public void setPage(int page)
Set the page currently displayed in the model.

Specified by:
setPage in interface PageableTableModel
Parameters:
page - The page to be displayed.

setPageSize

public void setPageSize(int pageSize)
Set the number of rows to display in a page.

Specified by:
setPageSize in interface PageableTableModel
Parameters:
pageSize - The number of rows to display in a page.

getDirectory

public File getDirectory()

getColumnCount

public int getColumnCount()
Returns the number of columns displayed in the table.

Specified by:
getColumnCount in interface TableModel
Overrides:
getColumnCount in class TableModel<File>
Returns:
The number of columns displayed.
See Also:
TableModel.getColumnCount()

getColumnName

public String getColumnName(int column)
Returns the name of the specified column. Looks for a localised value with a key <D.class.getName()>.<fieldName>.heading and if found returns the localised value.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class TableModel<File>
Parameters:
column - The index of the column whose name is to be returned.
Returns:
The name of the specified column.
See Also:
TableModel.getColumnName(int)

getValueAt

public Object getValueAt(int column,
                         int row)
                  throws IllegalArgumentException
Description copied from class: TableModel
Return the value at the specified coordinate in the table. If an unexpected error is encountered, a Level.SEVERE message with stack trace is logged. Throwing a RuntimeException results in Echo framework handling it improperly and ultimately killing the user session with a unrelated message.

Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class TableModel<File>
Parameters:
column - The column index.
row - The row index.
Returns:
The object that is displayed at the coordinate specified.
Throws:
IllegalArgumentException - If column or row indices are invalid for this model.
See Also:
TableModel.getValueAt(int, int)

getColumnClass

public Class getColumnClass(int column)
Over-ridden to always return String.class. Returns the class of the objects displayed in the specified column.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class TableModel<File>
Parameters:
column - The column whose class is to be returned.
Returns:
The class of the objects displayed.
See Also:
TableModel.getColumnClass(int)

init

public void init()
Over-ridden to do nothing as no processing is required.

Overrides:
init in class DefaultPageableTableModel<File>
See Also:
TableModel.processColumns()

setDirectory

public void setDirectory(File directory)
Set the directory to display in this model. Notifies the update manager that the table data has changed.

Parameters:
directory - The directory to use as the backing model.

SPT Core API