Package org.cesilko.rachota.gui
Class DayTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- org.cesilko.rachota.gui.DayTableModel
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.table.TableModel
public class DayTableModel extends javax.swing.table.AbstractTableModel
Table model for day view of tasks.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
TASK_DESCRIPTION
Identification of description column.static int
TASK_DURATION
Identification of duration column.static int
TASK_KEYWORD
Identification of keyword column.static int
TASK_NONE
Identification of no column.static int
TASK_NOTIFICATION
Identification of notification column.static int
TASK_PRIORITY
Identification of priority column.static int
TASK_PRIVATE
Identification of keyword column.static int
TASK_REGULAR
Identification of regular tasks column.static int
TASK_STATE
Identification of state column.
-
Constructor Summary
Constructors Constructor Description DayTableModel(Day day)
Creates a new instance of DayTableModel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]
getAllColumnNames()
Returns all translated column names.int
getAllColumnsCount()
Returns how many columns are available in total.java.lang.Class
getColumnClass(int column)
Returns class that should be used to render all values in given column.int
getColumnCount()
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.java.lang.String
getColumnName(int column)
Returns translated name of column identified by given visible column number.int
getRow(Task task)
Returns number of row occupied by given task.int
getRowCount()
Returns how many rows should be displayed depending on visibility of finished tasks.int
getSortedColumn()
Returns column that is currently sorted.java.lang.String
getSortedOrder()
Returns sorting order that is currently used.Task
getTask(int row)
Returns task located at given row depending on whether finished tasks are displayed or not.java.lang.Object
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
resortRows()
Manually invokes resorting of all rows.void
setDay(Day day)
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 Detail
-
TASK_PRIORITY
public static final int TASK_PRIORITY
Identification of priority column.- See Also:
- Constant Field Values
-
TASK_DESCRIPTION
public static final int TASK_DESCRIPTION
Identification of description column.- See Also:
- Constant Field Values
-
TASK_DURATION
public static final int TASK_DURATION
Identification of duration column.- See Also:
- Constant Field Values
-
TASK_STATE
public static final int TASK_STATE
Identification of state column.- See Also:
- Constant Field Values
-
TASK_REGULAR
public static final int TASK_REGULAR
Identification of regular tasks column.- See Also:
- Constant Field Values
-
TASK_NOTIFICATION
public static final int TASK_NOTIFICATION
Identification of notification column.- See Also:
- Constant Field Values
-
TASK_KEYWORD
public static final int TASK_KEYWORD
Identification of keyword column.- See Also:
- Constant Field Values
-
TASK_PRIVATE
public static final int TASK_PRIVATE
Identification of keyword column.- See Also:
- Constant Field Values
-
TASK_NONE
public static final int TASK_NONE
Identification of no column.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DayTableModel
public DayTableModel(Day day)
Creates a new instance of DayTableModel.- Parameters:
day
- Day that this table model represents.
-
-
Method Detail
-
setDay
public void setDay(Day day)
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
public java.lang.String[] 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
public java.lang.Class getColumnClass(int column)
Returns class that should be used to render all values in given column.- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classjavax.swing.table.AbstractTableModel
- 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
public java.lang.Object getValueAt(int row, int column)
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
public java.lang.String getColumnName(int column)
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 interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classjavax.swing.table.AbstractTableModel
- 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
public Task getTask(int row)
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
public int getRow(Task task)
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
public java.lang.String getSortedOrder()
Returns sorting order that is currently used.- Returns:
- Returns + char in case of ascending order or - char in case of descending order.
-
-