class BackupTableModel extends javax.swing.table.AbstractTableModel implements javax.swing.event.TableModelListener, BackupViewer
AbstractTableModel, which
implements most of the methods required by TableModel
interface and serves as a base class to implement customized tables.
This class also implements the BackupViewer interface
to receive updates from the BackupManager
and the TableModelListener interface,
which defines the tableChanged(TableModelEvent e)
method that is executed every time the table model changes.
| Modifier and Type | Field and Description |
|---|---|
private BackupManager |
mBackupManager
Instance of
BackupManager that is
shared between the model and the MainWindow. |
(package private) java.util.Set<java.lang.String> |
mSelectedBackups
A
Set that holds items that are currently selected. |
private java.util.Vector<java.util.Vector> |
mTableData
The data saved in the table cells represented by
a two dimensional
Vector. |
private java.lang.String[] |
mTableHeader
The table header as an array of
String. |
| Constructor and Description |
|---|
BackupTableModel(BackupManager manager)
Class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRow(boolean selected,
java.lang.String name,
java.lang.String original,
java.lang.String backup,
boolean shallow,
java.util.Date date)
This method is used to add new items into the table.
|
void |
clear()
Clears this
BackupTableModel. |
BackupManager |
getBackupManager()
Returns the associated
BackupManager instance. |
java.lang.String |
getBackupName() |
java.lang.Class<?> |
getColumnClass(int columnIndex)
Returns
Object.class regardless of columnIndex. |
int |
getColumnCount()
Returns the number of columns in the model.
|
java.lang.String |
getColumnName(int column)
Returns a default name for the column using spreadsheet conventions:
A, B, C, ...
|
int |
getRowCount()
Returns the number of rows in the model.
|
java.util.Set<java.lang.String> |
getSelectedBackups()
Returns a
Set of names of the selected backups. |
java.lang.Object |
getValueAt(int rowIndex,
int columnIndex)
Returns the value for the cell at
columnIndex and
rowIndex. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Returns false.
|
void |
removeFromSelectedBackups(java.lang.String name)
Marks a backup with this name as not selected.
|
private void |
saveSelectedBackups()
This method saves the names of currently selected backups.
|
void |
setBackupManager(BackupManager mBackupManager)
Associates a
BackupManager instance with this BackupTableModel. |
void |
setBackupName(java.lang.String name) |
void |
setValueAt(java.lang.Object value,
int rowIndex,
int columnIndex)
This empty implementation is provided so users don't have to implement
this method if their data model is not editable.
|
void |
showBackupInfo(java.lang.String name,
java.lang.String original,
java.lang.String backup,
boolean shallow,
java.util.Date date)
This method is used by the
BackupManager
to show backup information in the view. |
void |
tableChanged(javax.swing.event.TableModelEvent e)
Update the model when the table is edited.
|
void |
update()
Rebuilds this
BackupTableModel. |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListenerprivate java.lang.String[] mTableHeader
String.private java.util.Vector<java.util.Vector> mTableData
Vector.java.util.Set<java.lang.String> mSelectedBackups
Set that holds items that are currently selected.private BackupManager mBackupManager
BackupManager that is
shared between the model and the MainWindow.BackupTableModel(BackupManager manager)
BackupManager
, updates itself and registers itself to listen for TableModelEvent events.manager - instance of BackupManager that is
shared between the model and the MainWindowpublic void addRow(boolean selected,
java.lang.String name,
java.lang.String original,
java.lang.String backup,
boolean shallow,
java.util.Date date)
selected - defines whether the item is selectedname - value of the Name columnoriginal - value of the Original Directory columnbackup - value of the backup Directory columnshallow - defines whether the backup is defined as shallowdate - value of the Last Synchronized columnpublic BackupManager getBackupManager()
BackupManager instance.BackupManager instance.public void setBackupManager(BackupManager mBackupManager)
BackupManager instance with this BackupTableModel.public java.util.Set<java.lang.String> getSelectedBackups()
Set of names of the selected backups.Set of names of the selected backupspublic void removeFromSelectedBackups(java.lang.String name)
name - name of the backuppublic void update()
BackupTableModel.public void clear()
BackupTableModel.public int getRowCount()
JTable uses this method to determine how many rows it
should display. This method should be quick, as it
is called frequently during rendering.getRowCount in interface javax.swing.table.TableModelgetColumnCount()public int getColumnCount()
JTable uses this method to determine how many columns it
should create and display by default.getColumnCount in interface javax.swing.table.TableModelgetRowCount()public java.lang.String getColumnName(int column)
column cannot be found,
returns an empty string.getColumnName in interface javax.swing.table.TableModelgetColumnName in class javax.swing.table.AbstractTableModelcolumn - the column being queriedcolumnpublic java.lang.Class<?> getColumnClass(int columnIndex)
Object.class regardless of columnIndex.getColumnClass in interface javax.swing.table.TableModelgetColumnClass in class javax.swing.table.AbstractTableModelcolumnIndex - the column being queriedpublic java.lang.Object getValueAt(int rowIndex,
int columnIndex)
columnIndex and
rowIndex.getValueAt in interface javax.swing.table.TableModelrowIndex - the row whose value is to be queriedcolumnIndex - the column whose value is to be queriedpublic void setValueAt(java.lang.Object value,
int rowIndex,
int columnIndex)
setValueAt in interface javax.swing.table.TableModelsetValueAt in class javax.swing.table.AbstractTableModelvalue - value to assign to cellrowIndex - row of cellcolumnIndex - column of cellpublic boolean isCellEditable(int rowIndex,
int columnIndex)
isCellEditable in interface javax.swing.table.TableModelisCellEditable in class javax.swing.table.AbstractTableModelrowIndex - the row being queriedcolumnIndex - the column being queriedpublic void tableChanged(javax.swing.event.TableModelEvent e)
tableChanged in interface javax.swing.event.TableModelListenere - instance of TableModelEventpublic void showBackupInfo(java.lang.String name,
java.lang.String original,
java.lang.String backup,
boolean shallow,
java.util.Date date)
BackupManager
to show backup information in the view.showBackupInfo in interface BackupViewername - backup nameoriginal - original directorybackup - backup directoryshallow - specifies whether the backup is shallow or notdate - when the last synchronization took placepublic java.lang.String getBackupName()
getBackupName in interface BackupViewerpublic void setBackupName(java.lang.String name)
setBackupName in interface BackupViewerprivate void saveSelectedBackups()