Package org.cesilko.rachota.gui
Class FilteredTasksTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
org.cesilko.rachota.gui.FilteredTasksTableModel
- All Implemented Interfaces:
Serializable
,TableModel
Table model for filtered tasks.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Identification of filter name column.static final int
Identification of filter content column.static final int
Identification of filter content rule column.Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Returns number of columns in the table i.e.getColumnName
(int column) Returns name of column by given column number.int
Returns number of rows in the table i.e.getSimilarTask
(int row) Returns similar task to the one at given row.int
Returns column that is currently sorted.Returns sorting order that is currently used.double
Returns total time spent on all displayed tasks.getValueAt
(int row, int column) Returns value of cell located in given row and column.void
setGroupSameTasks
(boolean groupSameTasks) Sets whether to group tasks with same description or not.void
Sets filtered tasks with new vector and refreshes the table.void
sortTable
(int column, boolean changeOrder) Sorts table according to given column and known order.Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
-
Field Details
-
DESCRIPTION
public static final int DESCRIPTIONIdentification of filter name column.- See Also:
-
DURATION_TIME
public static final int DURATION_TIMEIdentification of filter content rule column.- See Also:
-
DURATION_DAYS
public static final int DURATION_DAYSIdentification of filter content column.- See Also:
-
-
Constructor Details
-
FilteredTasksTableModel
public FilteredTasksTableModel()Creates a new instance of FilteredTasksTableModel
-
-
Method Details
-
setGroupSameTasks
public void setGroupSameTasks(boolean groupSameTasks) Sets whether to group tasks with same description or not.- Parameters:
groupSameTasks
- If true, tasks with same description will occupy one row.
-
setTasks
Sets filtered tasks with new vector and refreshes the table.- Parameters:
tasks
- Vector of filtered tasks to be displayed in the table.
-
getValueAt
Returns value of cell located in given row and column.- Parameters:
row
- Number of row.column
- Number of column.- Returns:
- Value of cell at specified location.
-
getSimilarTask
Returns similar task to the one at given row.- Parameters:
row
- Row of task to be found.- Returns:
- Either same task or new task with same description.
-
getRowCount
public int getRowCount()Returns number of rows in the table i.e. filtered tasks. The number depends on the groupSameTasks setting.- Returns:
- Number of rows in the table i.e. number of filtered tasks either unique or same depending on whether they should be grouped.
-
getColumnCount
public int getColumnCount()Returns number of columns in the table i.e. 3.- Returns:
- Always 3 since table has three columns.
-
getColumnName
Returns name of column by given column number.- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
- Parameters:
column
- Number of column.- Returns:
- Name of column by given column number.
-
getTotalTime
public double getTotalTime()Returns total time spent on all displayed tasks.- Returns:
- Total time spent on all displayed tasks in miliseconds.
-
getSortedColumn
public int getSortedColumn()Returns column that is currently sorted.- Returns:
- Column 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.
-
sortTable
public void sortTable(int column, boolean changeOrder) Sorts table according to given column and known order.- Parameters:
column
- Column that will be used for sorting.changeOrder
- Should the sorting order be changed ?
-