Class Day

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener

    public class Day
    extends java.lang.Object
    implements java.beans.PropertyChangeListener
    Day with plan of tasks.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Date date
      Calendar date representing day.
      private java.util.Date finishTime
      Time when the last task was worked on.
      private boolean modified
      Identification whether day was modified compared to its saved state.
      private java.beans.PropertyChangeSupport propertyChangeSupport
      Class containing all registered listeners interested in day.
      private java.util.Date startTime
      Time when the very first task was started.
      private java.util.Vector tasks
      Set of all (including regular kind) tasks planned for day.
    • Constructor Summary

      Constructors 
      Constructor Description
      Day​(java.util.Vector tasks, java.util.Date date, java.util.Date startTime, java.util.Date finishTime)
      Creates a new instance of day.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Adds new listener to set of objects interested in this day.
      void addTask​(Task task)
      Adds new task to plan of day.
      boolean existsMorePriorityTask​(int priority)
      Checks if there is some unfinished task in plan with higher priority.
      java.util.Date getDate()
      Returns identification of day.
      java.util.Date getFinishTime()
      Returns finish time of day.
      Task getIdleTask()
      Returns idle task of the day.
      long getRemainingWorkingTime()
      Returns the remaining work time for this day.
      java.util.Date getStartTime()
      Returns start time of day.
      Task getTask​(java.lang.String description)
      Returns task with given description or null if such does not exist.
      java.util.Vector getTasks()
      Returns tasks planned for day.
      long getTotalTime()
      Get total time spent on tasks without idle time.
      long getTotalTime​(boolean includePrivateTasks)
      Get total time spent on tasks without idle time.
      boolean isModified()
      Returns if day was modified or not since it was created.
      void propertyChange​(java.beans.PropertyChangeEvent evt)
      Method called when some property of task was changed.
      void removeNotStartedRegularTasks()
      Removes all not started regular tasks from plan of day.
      void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Adds new listener to set of objects interested in this day.
      void removeTask​(Task task)
      Removes given task from plan of day.
      void setDate​(java.util.Date date)
      Sets identification of day.
      void setFinishTime​(java.util.Date finishTime)
      Sets finish time of day.
      void setStartTime​(java.util.Date startTime)
      Sets start time of day.
      void setTasks​(java.util.Vector tasks)
      Sets tasks of day.
      void sortTasks​(int attribute, boolean ascendingOrder)
      Sort tasks by given attribute and sorting order.
      java.lang.String toString()
      Returns textual representation of day's date e.g.
      void write​(java.io.PrintStream stream)
      Write day to given writer.
      • Methods inherited from class java.lang.Object

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

      • tasks

        private java.util.Vector tasks
        Set of all (including regular kind) tasks planned for day.
      • date

        private java.util.Date date
        Calendar date representing day.
      • startTime

        private java.util.Date startTime
        Time when the very first task was started.
      • finishTime

        private java.util.Date finishTime
        Time when the last task was worked on.
      • modified

        private boolean modified
        Identification whether day was modified compared to its saved state. Day gets modified when irregular task is added to its plan or any task is removed or its start or finish times are changed.
      • propertyChangeSupport

        private java.beans.PropertyChangeSupport propertyChangeSupport
        Class containing all registered listeners interested in day.
    • Constructor Detail

      • Day

        public Day​(java.util.Vector tasks,
                   java.util.Date date,
                   java.util.Date startTime,
                   java.util.Date finishTime)
        Creates a new instance of day.
        Parameters:
        tasks - Vector of tasks planned for day.
        date - Identification of day.
        startTime - Time when first task was started.
        finishTime - Last time when some task was worked on.
    • Method Detail

      • setTasks

        public void setTasks​(java.util.Vector tasks)
        Sets tasks of day.
        Parameters:
        tasks - Tasks of day.
      • getTasks

        public java.util.Vector getTasks()
        Returns tasks planned for day.
        Returns:
        Tasks planned for day.
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Adds new listener to set of objects interested in this day.
        Parameters:
        listener - Object interested in this day.
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Adds new listener to set of objects interested in this day.
        Parameters:
        listener - Object interested in this day.
      • addTask

        public void addTask​(Task task)
        Adds new task to plan of day.
        Parameters:
        task - New task to be added.
      • removeTask

        public void removeTask​(Task task)
        Removes given task from plan of day.
        Parameters:
        task - Task to be removed from plan.
      • removeNotStartedRegularTasks

        public void removeNotStartedRegularTasks()
        Removes all not started regular tasks from plan of day.
      • getTask

        public Task getTask​(java.lang.String description)
        Returns task with given description or null if such does not exist.
        Parameters:
        description - Description of task to be searched for.
        Returns:
        Task with given description or null otherwise.
      • getIdleTask

        public Task getIdleTask()
        Returns idle task of the day.
      • existsMorePriorityTask

        public boolean existsMorePriorityTask​(int priority)
        Checks if there is some unfinished task in plan with higher priority.
        Parameters:
        priority - Priority to be compared with.
        Returns:
        True if plan contains at least one task with higher priority than given one, else false.
      • setDate

        public void setDate​(java.util.Date date)
        Sets identification of day.
        Parameters:
        date - Identification of day.
      • getDate

        public java.util.Date getDate()
        Returns identification of day.
        Returns:
        Identification of day.
      • setStartTime

        public void setStartTime​(java.util.Date startTime)
        Sets start time of day.
        Parameters:
        startTime - Start time of day.
      • getStartTime

        public java.util.Date getStartTime()
        Returns start time of day.
        Returns:
        Start time of day.
      • setFinishTime

        public void setFinishTime​(java.util.Date finishTime)
        Sets finish time of day.
        Parameters:
        finishTime - Finish time of day.
      • getFinishTime

        public java.util.Date getFinishTime()
        Returns finish time of day.
        Returns:
        Finish time of day.
      • isModified

        public boolean isModified()
        Returns if day was modified or not since it was created.
        Returns:
        True if some task was added, removed or start or finish times were changed.
      • getTotalTime

        public long getTotalTime​(boolean includePrivateTasks)
        Get total time spent on tasks without idle time.
        Parameters:
        includePrivateTasks - If true, also time spent on private tasks will be calculated.
        Returns:
        Total time spent on tasks in milliseconds.
      • getTotalTime

        public long getTotalTime()
        Get total time spent on tasks without idle time. This will use the preference stored in the settings determine whether or not to count private tasks.
        Returns:
        Total time spent on tasks in milliseconds.
        See Also:
        getTotalTime(boolean), Settings.getCountPrivateTasks()
      • sortTasks

        public void sortTasks​(int attribute,
                              boolean ascendingOrder)
        Sort tasks by given attribute and sorting order.
        Parameters:
        attribute - Attribute used for sorting tasks e.g. DayTableModel.TASK_PRIORITY
        ascendingOrder - Sorting order. If true, tasks will be sorted in ascending order.
      • write

        public void write​(java.io.PrintStream stream)
                   throws java.io.IOException
        Write day to given writer.
        Parameters:
        stream - Print stream where day will be written.
        Throws:
        java.io.IOException - Input/Output exception thrown whenever any problem while writing day occurs.
      • toString

        public java.lang.String toString()
        Returns textual representation of day's date e.g. 11/25 or 25.11.
        Overrides:
        toString in class java.lang.Object
        Returns:
        Tex representation of days' date.
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent evt)
        Method called when some property of task was changed.
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Parameters:
        evt - Event describing what was changed.
      • getRemainingWorkingTime

        public long getRemainingWorkingTime()
        Returns the remaining work time for this day.
        Returns:
        the remaining work time for this day in milli seconds.