Package org.cesilko.rachota.core
Class Day
java.lang.Object
org.cesilko.rachota.core.Day
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
Day with plan of tasks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Date
Calendar date representing day.private Date
Time when the last task was worked on.private boolean
Identification whether day was modified compared to its saved state.private PropertyChangeSupport
Class containing all registered listeners interested in day.private Date
Time when the very first task was started.private Vector
Set of all (including regular kind) tasks planned for day. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds new listener to set of objects interested in this day.void
Adds new task to plan of day.boolean
existsMorePriorityTask
(int priority) Checks if there is some unfinished task in plan with higher priority.getDate()
Returns identification of day.Returns finish time of day.Returns idle task of the day.long
Returns the remaining work time for this day.Returns start time of day.Returns task with given description or null if such does not exist.getTasks()
Returns tasks planned for day.long
Get total time spent on tasks without idle time.long
getTotalTime
(boolean includePrivateTasks) Get total time spent on tasks without idle time.boolean
Returns if day was modified or not since it was created.void
Method called when some property of task was changed.void
Removes all not started regular tasks from plan of day.void
Adds new listener to set of objects interested in this day.void
removeTask
(Task task) Removes given task from plan of day.void
Sets identification of day.void
setFinishTime
(Date finishTime) Sets finish time of day.void
setStartTime
(Date startTime) Sets start time of day.void
Sets tasks of day.void
sortTasks
(int attribute, boolean ascendingOrder) Sort tasks by given attribute and sorting order.toString()
Returns textual representation of day's date e.g.void
write
(PrintStream stream) Write day to given writer.
-
Field Details
-
tasks
Set of all (including regular kind) tasks planned for day. -
date
Calendar date representing day. -
startTime
Time when the very first task was started. -
finishTime
Time when the last task was worked on. -
modified
private boolean modifiedIdentification 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
Class containing all registered listeners interested in day.
-
-
Constructor Details
-
Day
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 Details
-
setTasks
Sets tasks of day.- Parameters:
tasks
- Tasks of day.
-
getTasks
Returns tasks planned for day.- Returns:
- Tasks planned for day.
-
addPropertyChangeListener
Adds new listener to set of objects interested in this day.- Parameters:
listener
- Object interested in this day.
-
removePropertyChangeListener
Adds new listener to set of objects interested in this day.- Parameters:
listener
- Object interested in this day.
-
addTask
Adds new task to plan of day.- Parameters:
task
- New task to be added.
-
removeTask
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
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
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
Sets identification of day.- Parameters:
date
- Identification of day.
-
getDate
Returns identification of day.- Returns:
- Identification of day.
-
setStartTime
Sets start time of day.- Parameters:
startTime
- Start time of day.
-
getStartTime
Returns start time of day.- Returns:
- Start time of day.
-
setFinishTime
Sets finish time of day.- Parameters:
finishTime
- Finish time of day.
-
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:
-
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_PRIORITYascendingOrder
- Sorting order. If true, tasks will be sorted in ascending order.
-
write
Write day to given writer.- Parameters:
stream
- Print stream where day will be written.- Throws:
IOException
- Input/Output exception thrown whenever any problem while writing day occurs.
-
toString
Returns textual representation of day's date e.g. 11/25 or 25.11. -
propertyChange
Method called when some property of task was changed.- Specified by:
propertyChange
in interfacePropertyChangeListener
- 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.
-