public class DirectoryTableModel extends DefaultPageableTableModel<File> implements SortableTableModel
The following keys must be configured in the localisation files for the column names:
com.sptci.echo.tree.filesystem.DirectoryTableModel.column.name
- The column in which the file name is displayed.com.sptci.echo.tree.filesystem.DirectoryTableModel.column.size
- The column in which the file size is displayed.com.sptci.echo.tree.filesystem.DirectoryTableModel.column.modified
- The column in which the file last modification time is displayed.com.sptci.echo.tree.filesystem.DirectoryTableModel.column.type
- The column in which the file type is displayed.© Copyright 2009 Sans Pareil Technologies, Inc.
SortableTableModel.Direction| Modifier and Type | Field and Description |
|---|---|
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.
|
page, pageSize, totalRowscolumns, datasortDirection, sortIndex| Constructor and Description |
|---|
DirectoryTableModel(File directory)
Create a new model for the specified directory.
|
| Modifier and Type | Method and Description |
|---|---|
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() |
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 files by the values in the specified column index.
|
void |
sort(int column,
SortableTableModel.Direction direction)
Sort the files by the values in the specified column index.
|
getPage, getPageSize, getTotalPages, setPageSizeaddRow, deleteRow, deleteRow, getColumnAnnotations, getObjectAt, getRowCount, insertRow, processColumnAnnotations, processColumns, processColumnsAnnotation, processFields, updateRowgetSortDirectionaddTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getEventListenerList, removeTableModelListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSortDirectionprotected static final String[] columnNames
protected File directory
protected SimpleDateFormat dateFormat
public DirectoryTableModel(File directory)
directory - The directory whose contents are to be displayed.public void sort(int column)
TreeMap to sort the value in
the specified column index.sort in interface SortableTableModelcolumn - The index of the column by which the data is to
be sorted.AbstractTableModel.getSortDirection(int),
SortableTableModel.sort( int, Direction )public void sort(int column,
SortableTableModel.Direction direction)
TreeMap to sort the value in
the specified column index.sort in interface SortableTableModelcolumn - The index of the column by which the data is to
be sorted.direction - The direction of sorting to be applied.AbstractTableModel.fireTableDataChanged()public void setPage(int page)
setPage in interface PageableTableModelpage - The page to be displayed.public void setPageSize(int pageSize)
setPageSize in interface PageableTableModelpageSize - The number of rows to display in a page.public File getDirectory()
public int getColumnCount()
getColumnCount in interface TableModelgetColumnCount in class TableModel<File>TableModel.getColumnCount()public String getColumnName(int column)
<D.class.getName()>.<fieldName>.heading
and if found returns the localised value.getColumnName in interface TableModelgetColumnName in class TableModel<File>column - The index of the column whose name is to be returned.TableModel.getColumnName(int)public Object getValueAt(int column, int row) throws IllegalArgumentException
TableModelLevel.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.getValueAt in interface TableModelgetValueAt in class TableModel<File>column - The column index.row - The row index.IllegalArgumentException - If column or
row indices are invalid for this model.TableModel.getValueAt(int, int)public Class getColumnClass(int column)
String.class.
Returns the class of the objects displayed in the specified column.getColumnClass in interface TableModelgetColumnClass in class TableModel<File>column - The column whose class is to be returned.TableModel.getColumnClass(int)public void init()
init in class DefaultPageableTableModel<File>TableModel.processColumns()public void setDirectory(File directory)
directory - The directory to use as the backing model.