wjhk.jupload2.gui
Class FilePanelDataModel2

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by wjhk.jupload2.gui.FilePanelDataModel2
All Implemented Interfaces:
Serializable, TableModel

 class FilePanelDataModel2
extends AbstractTableModel

This class replaces FilePanelDataModel. The data for each row is now contained in an instance of FileData (or one of its subclasses, like PictureFileData). This allow easy add of new functionalites, during upload, by adding attributes or methods to these classes, or create new ones.
Some ides of improvements :


Field Summary
static int COLINDEX_DIRECTORY
          The default colum indices of the columns, as displayed by the applet.
static int COLINDEX_MODIFIED
          The default colum indices of the columns, as displayed by the applet.
static int COLINDEX_NAME
          The default colum indices of the columns, as displayed by the applet.
static int COLINDEX_READABLE
          The default colum indices of the columns, as displayed by the applet.
static int COLINDEX_SIZE
          The default colum indices of the columns, as displayed by the applet.
protected  Class<?>[] columnClasses
           
protected  String[] columnNames
           
protected  int[] columnSize
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
FilePanelDataModel2(UploadPolicy uploadPolicy)
           
 
Method Summary
 void addFile(File file, File root)
          Add a file to the panel (at the end of the list)
 boolean contains(File file)
          Does this table contain this file ?
 Class getColumnClass(int arg0)
           
 int getColumnCount()
           
 String getColumnName(int arg0)
           
 int getColumnSize(int col)
          Retrieves the default colum size of a column.
 File getFileAt(int row)
          Ask for the file contained at specified row number.
 FileData getFileDataAt(int row)
          Ask for the file contained at specified row number.
 int getRowCount()
           
 Object getValueAt(int row, int col)
           
 boolean isCellEditable(int arg0, int arg1)
          Always return false here : no editable cell.
 boolean isSortable(int col)
          Return true if this column can be sorted.
 void removeRow(FileData fileData)
          Removes fileData from the current list.
 void removeRow(int row)
          Remove a specified row.
 void setValueAt(Object arg0, int arg1, int arg2)
          This method doesn't do anything : no changeable values.
 void sortColumn(int col, boolean ascending)
          Sort the rows, according to one column.
 
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

COLINDEX_NAME

public static final int COLINDEX_NAME
The default colum indices of the columns, as displayed by the applet. Index of the column "Filename"

See Also:
Constant Field Values

COLINDEX_SIZE

public static final int COLINDEX_SIZE
The default colum indices of the columns, as displayed by the applet. Index of the column "Filename"

See Also:
Constant Field Values

COLINDEX_DIRECTORY

public static final int COLINDEX_DIRECTORY
The default colum indices of the columns, as displayed by the applet. Index of the column "Filesize"

See Also:
Constant Field Values

COLINDEX_MODIFIED

public static final int COLINDEX_MODIFIED
The default colum indices of the columns, as displayed by the applet. Index of the column "Last modified"

See Also:
Constant Field Values

COLINDEX_READABLE

public static final int COLINDEX_READABLE
The default colum indices of the columns, as displayed by the applet. Index of the column "Readable"

See Also:
Constant Field Values

columnNames

protected String[] columnNames

columnSize

protected int[] columnSize

columnClasses

protected Class<?>[] columnClasses
Constructor Detail

FilePanelDataModel2

public FilePanelDataModel2(UploadPolicy uploadPolicy)
Parameters:
uploadPolicy -
Method Detail

contains

public boolean contains(File file)
Does this table contain this file ?

Parameters:
file - : the file that could be contained...
Returns:
true if the table contains this file.

addFile

public void addFile(File file,
                    File root)
             throws JUploadExceptionStopAddingFiles
Add a file to the panel (at the end of the list)

Parameters:
file -
root -
Throws:
JUploadExceptionStopAddingFiles

getFileAt

public File getFileAt(int row)
Ask for the file contained at specified row number.

Parameters:
row - The row number
Returns:
The return instance of File.

getFileDataAt

public FileData getFileDataAt(int row)
Ask for the file contained at specified row number.

Parameters:
row - The row number
Returns:
The return instance of File.

removeRow

public void removeRow(int row)
Remove a specified row.

Parameters:
row - The row to remove.

removeRow

public void removeRow(FileData fileData)
Removes fileData from the current list. There should be only one.

Parameters:
fileData -

getColumnCount

public int getColumnCount()
See Also:
TableModel.getColumnCount()

getRowCount

public int getRowCount()
See Also:
TableModel.getRowCount()

isCellEditable

public boolean isCellEditable(int arg0,
                              int arg1)
Always return false here : no editable cell.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
See Also:
TableModel.isCellEditable(int, int)

sortColumn

public void sortColumn(int col,
                       boolean ascending)
Sort the rows, according to one column.

Parameters:
col - The index of the column to sort
ascending - true if ascending, false if descending.

isSortable

public boolean isSortable(int col)
Return true if this column can be sorted.

Parameters:
col - The index of the column which can sortable or not.
Returns:
true if the column can be sorted. false otherwise.

getColumnClass

public Class getColumnClass(int arg0)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
See Also:
TableModel.getColumnClass(int)

getValueAt

public Object getValueAt(int row,
                         int col)
See Also:
TableModel.getValueAt(int, int)

setValueAt

public void setValueAt(Object arg0,
                       int arg1,
                       int arg2)
This method doesn't do anything : no changeable values.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel
See Also:
TableModel.setValueAt(java.lang.Object, int, int)

getColumnName

public String getColumnName(int arg0)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
See Also:
TableModel.getColumnName(int)

getColumnSize

public int getColumnSize(int col)
Retrieves the default colum size of a column.

Parameters:
col - The index of the column to query.
Returns:
the default size of the requested column.