Class DayTableModel

java.lang.Object
javax.swing.table.AbstractTableModel
org.cesilko.rachota.gui.DayTableModel
All Implemented Interfaces:
Serializable, TableModel

public class DayTableModel extends AbstractTableModel
Table model for day view of tasks.
See Also:
  • Field Details

    • TASK_PRIORITY

      public static final int TASK_PRIORITY
      Identification of priority column.
      See Also:
    • TASK_DESCRIPTION

      public static final int TASK_DESCRIPTION
      Identification of description column.
      See Also:
    • TASK_DURATION

      public static final int TASK_DURATION
      Identification of duration column.
      See Also:
    • TASK_STATE

      public static final int TASK_STATE
      Identification of state column.
      See Also:
    • TASK_REGULAR

      public static final int TASK_REGULAR
      Identification of regular tasks column.
      See Also:
    • TASK_NOTIFICATION

      public static final int TASK_NOTIFICATION
      Identification of notification column.
      See Also:
    • TASK_KEYWORD

      public static final int TASK_KEYWORD
      Identification of keyword column.
      See Also:
    • TASK_PRIVATE

      public static final int TASK_PRIVATE
      Identification of keyword column.
      See Also:
    • TASK_NONE

      public static final int TASK_NONE
      Identification of no column.
      See Also:
    • sortedColumn

      private int sortedColumn
      Which column is used to sort tasks.
    • sortedAscending

      private boolean sortedAscending
      Does sorted column have ascending order ?
    • columns

      Hashtable columns
      Table with information if columns are selected i.e. visible or not.
    • day

      private Day day
      Day that is currently selected.
    • columnNames

      String[] columnNames
      Translations of all column names.
  • Constructor Details

    • DayTableModel

      public DayTableModel(Day day)
      Creates a new instance of DayTableModel.
      Parameters:
      day - Day that this table model represents.
  • Method Details

    • 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 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 Class getColumnClass(int column)
      Returns class that should be used to render all values in given column.
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class 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 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 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 interface TableModel
      Overrides:
      getColumnName in class 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 invalid input: '<'-> 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 String getSortedOrder()
      Returns sorting order that is currently used.
      Returns:
      Returns + char in case of ascending order or - char in case of descending order.