Class FilteredTasksTableModel

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.table.TableModel

    public class FilteredTasksTableModel
    extends javax.swing.table.AbstractTableModel
    Table model for filtered tasks.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static boolean ASCENDING
      Ascending sorting order.
      private static boolean DESCENDING
      Descending sorting order.
      static int DESCRIPTION
      Identification of filter name column.
      static int DURATION_DAYS
      Identification of filter content column.
      static int DURATION_TIME
      Identification of filter content rule column.
      private boolean groupSameTasks
      Whether to group tasks with same description.
      private int sortedColumn
      Currently selected sorting column.
      private boolean sortingOrder
      Currently selected sorting order.
      private java.util.Vector tasks
      Vector of tasks to be displayed by this table model.
      • Fields inherited from class javax.swing.table.AbstractTableModel

        listenerList
    • Constructor Summary

      Constructors 
      Constructor Description
      FilteredTasksTableModel()
      Creates a new instance of FilteredTasksTableModel
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getColumnCount()
      Returns number of columns in the table i.e.
      java.lang.String getColumnName​(int column)
      Returns name of column by given column number.
      private java.util.Vector getRow​(int row)
      Returns vector of three objects that should be displayed at given row when tasks with same description are displayed.
      int getRowCount()
      Returns number of rows in the table i.e.
      Task getSimilarTask​(int row)
      Returns similar task to the one at given row.
      int getSortedColumn()
      Returns column that is currently sorted.
      java.lang.String getSortedOrder()
      Returns sorting order that is currently used.
      double getTotalTime()
      Returns total time spent on all displayed tasks.
      private java.util.Vector getUniqueTaskDescriptions()
      Returns vector of all unique task descriptions.
      java.lang.Object 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 setTasks​(java.util.Vector tasks)
      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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DESCRIPTION

        public static final int DESCRIPTION
        Identification of filter name column.
        See Also:
        Constant Field Values
      • DURATION_TIME

        public static final int DURATION_TIME
        Identification of filter content rule column.
        See Also:
        Constant Field Values
      • DURATION_DAYS

        public static final int DURATION_DAYS
        Identification of filter content column.
        See Also:
        Constant Field Values
      • groupSameTasks

        private boolean groupSameTasks
        Whether to group tasks with same description.
      • tasks

        private java.util.Vector tasks
        Vector of tasks to be displayed by this table model.
      • sortedColumn

        private int sortedColumn
        Currently selected sorting column.
      • sortingOrder

        private boolean sortingOrder
        Currently selected sorting order.
      • ASCENDING

        private static final boolean ASCENDING
        Ascending sorting order.
        See Also:
        Constant Field Values
      • DESCENDING

        private static final boolean DESCENDING
        Descending sorting order.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FilteredTasksTableModel

        public FilteredTasksTableModel()
        Creates a new instance of FilteredTasksTableModel
    • Method Detail

      • 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

        public void setTasks​(java.util.Vector tasks)
        Sets filtered tasks with new vector and refreshes the table.
        Parameters:
        tasks - Vector of filtered tasks to be displayed in the table.
      • getValueAt

        public java.lang.Object getValueAt​(int row,
                                           int column)
        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

        public Task getSimilarTask​(int row)
        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

        public java.lang.String getColumnName​(int column)
        Returns name of column by given column number.
        Specified by:
        getColumnName in interface javax.swing.table.TableModel
        Overrides:
        getColumnName in class javax.swing.table.AbstractTableModel
        Parameters:
        column - Number of column.
        Returns:
        Name of column by given column number.
      • getUniqueTaskDescriptions

        private java.util.Vector getUniqueTaskDescriptions()
        Returns vector of all unique task descriptions.
        Returns:
        Vector of all unique task descriptions.
      • getTotalTime

        public double getTotalTime()
        Returns total time spent on all displayed tasks.
        Returns:
        Total time spent on all displayed tasks in miliseconds.
      • getRow

        private java.util.Vector getRow​(int row)
        Returns vector of three objects that should be displayed at given row when tasks with same description are displayed.
        Parameters:
        row - Number of row whose data will be returned.
        Returns:
        Vector consisting of task description, total duration for all tasks with the description and number of days the tasks were planned for.
      • getSortedColumn

        public int getSortedColumn()
        Returns column that is currently sorted.
        Returns:
        Column 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.
      • 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 ?