Package org.cesilko.rachota.gui
Class DayTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
org.cesilko.rachota.gui.DayTableModel
- All Implemented Interfaces:
Serializable
,TableModel
Table model for day view of tasks.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) String[]
Translations of all column names.(package private) Hashtable
Table with information if columns are selected i.e.private Day
Day that is currently selected.private boolean
Does sorted column have ascending order ?private int
Which column is used to sort tasks.static final int
Identification of description column.static final int
Identification of duration column.static final int
Identification of keyword column.static final int
Identification of no column.static final int
Identification of notification column.static final int
Identification of priority column.static final int
Identification of keyword column.static final int
Identification of regular tasks column.static final int
Identification of state column.Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]
Returns all translated column names.int
Returns how many columns are available in total.getColumnClass
(int column) Returns class that should be used to render all values in given column.int
Returns how many columns are currently selected and should be displayed.int
getColumnID
(int column) Returns absolute column number identified by given visible column number i.e.getColumnName
(int column) Returns translated name of column identified by given visible column number.int
Returns number of row occupied by given task.int
Returns how many rows should be displayed depending on visibility of finished tasks.int
Returns column that is currently sorted.Returns sorting order that is currently used.getTask
(int row) Returns task located at given row depending on whether finished tasks are displayed or not.getValueAt
(int row, int column) Returns cell value located by given row and column.boolean
isSelectedColumn
(int columnID) Finds out if given column is visible i.e.void
Manually invokes resorting of all rows.void
Sets day to be represented by this model.void
setSelectedColumn
(int columnID, boolean state) Sets visibility for given column.void
setSortedColumn
(int column, boolean changeOrder) Changes sorting order (ascending <-> descending) for given column.Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
-
Field Details
-
TASK_PRIORITY
public static final int TASK_PRIORITYIdentification of priority column.- See Also:
-
TASK_DESCRIPTION
public static final int TASK_DESCRIPTIONIdentification of description column.- See Also:
-
TASK_DURATION
public static final int TASK_DURATIONIdentification of duration column.- See Also:
-
TASK_STATE
public static final int TASK_STATEIdentification of state column.- See Also:
-
TASK_REGULAR
public static final int TASK_REGULARIdentification of regular tasks column.- See Also:
-
TASK_NOTIFICATION
public static final int TASK_NOTIFICATIONIdentification of notification column.- See Also:
-
TASK_KEYWORD
public static final int TASK_KEYWORDIdentification of keyword column.- See Also:
-
TASK_PRIVATE
public static final int TASK_PRIVATEIdentification of keyword column.- See Also:
-
TASK_NONE
public static final int TASK_NONEIdentification of no column.- See Also:
-
sortedColumn
private int sortedColumnWhich column is used to sort tasks. -
sortedAscending
private boolean sortedAscendingDoes sorted column have ascending order ? -
columns
Hashtable columnsTable with information if columns are selected i.e. visible or not. -
day
Day that is currently selected. -
columnNames
String[] columnNamesTranslations of all column names.
-
-
Constructor Details
-
DayTableModel
Creates a new instance of DayTableModel.- Parameters:
day
- Day that this table model represents.
-
-
Method Details
-
setDay
Sets day to be represented by this model.- Parameters:
day
- Day that this table model represents.
-
getColumnCount
public int getColumnCount()Returns how many columns are currently selected and should be displayed.- Returns:
- Number of columns that are currently selected and should be displayed.
-
getAllColumnNames
Returns all translated column names.- Returns:
- All translated column names.
-
getRowCount
public int getRowCount()Returns how many rows should be displayed depending on visibility of finished tasks.- Returns:
- Number of rows to be displayed depending on visibility of finished tasks.
-
getColumnClass
Returns class that should be used to render all values in given column.- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
- Parameters:
column
- Column whose class should be returned.- Returns:
- Class best describing values in given column i.e. Boolean for regular tasks indication column and String for other columns.
-
getValueAt
Returns cell value located by given row and column.- Parameters:
row
- Row number to locate the interested cell.column
- Column number to locate the interested cell.- Returns:
- Value of cell located by given row and column.
-
getColumnName
Returns translated name of column identified by given visible column number. The value depends on selected columns and currently sorted column that gets [+] or [-] appended.- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
- Parameters:
column
- Visible column number whose name will be returned.- Returns:
- Translated name of column identified by given visible column number.
-
getColumnID
public int getColumnID(int column) Returns absolute column number identified by given visible column number i.e. if first two columns are not visible getColumnID(0) returns 2.- Parameters:
column
- Visible column number whose absolute column number will be calculated.- Returns:
- Absolute column number of given visible column.
-
isSelectedColumn
public boolean isSelectedColumn(int columnID) Finds out if given column is visible i.e. if first two columns are not visible isSelectedColumn(1) returns false.- Parameters:
columnID
- Absolute column number to be checked for visibility.- Returns:
- True if column is visible or false otherwise.
-
setSelectedColumn
public void setSelectedColumn(int columnID, boolean state) Sets visibility for given column.- Parameters:
columnID
- Absolute column number to be set.state
- True if column should be visible or false otherwise.
-
getAllColumnsCount
public int getAllColumnsCount()Returns how many columns are available in total.- Returns:
- Number of columns that can be selected.
-
setSortedColumn
public void setSortedColumn(int column, boolean changeOrder) Changes sorting order (ascending <-> descending) for given column.- Parameters:
column
- Visible column number.changeOrder
- True if sorting order should be changed.
-
resortRows
public void resortRows()Manually invokes resorting of all rows. -
getTask
Returns task located at given row depending on whether finished tasks are displayed or not.- Parameters:
row
- Number of row whose task should be returned.- Returns:
- Task located at given row.
-
getRow
Returns number of row occupied by given task.- Parameters:
task
- Task whose row number should be returned.- Returns:
- Number of row occupied by given task.
-
getSortedColumn
public int getSortedColumn()Returns column that is currently sorted.- Returns:
- Visible column number that is being sorted.
-
getSortedOrder
Returns sorting order that is currently used.- Returns:
- Returns + char in case of ascending order or - char in case of descending order.
-