-
Notifications
You must be signed in to change notification settings - Fork 321
Feature Notes: Task Sorting
We'd like to implement sorting of tasks in the task table by start/end date in ascending/descending order. This document describes user interface and technical aspects of the implementation.
The order of tasks is actually partial because tasks form a tree rather than a list. We can't compare two tasks from different subtrees by start dates, we can only compare sibling tasks. So, when we say "tasks are ordered by start date" we actually mean "sibling tasks are ordered by start date [and it applies recursively to subtasks]"
User can request task ordering by clicking column header in the table. When user clicks say "Begin date" header we should order tasks by begin date in ascending order and add arrow up icon to the header. If user clicks the header once again, we should change the ordering to descending and change the icon to arrow down.
We do not maintain the order. If user modifies the tree by adding a new task or removing/reordering existing tasks, the tree becomes unordered and subsequent clicks on the header behave like described above.
Relevant classes in GanttProject codebase:
- Classes which store the tree:
GanttTreeTableModel,TaskNode. - Classes which provide functions for manipulating and searching the tree:
TaskContainmentHierarchyFacadeImpl. It implementsTaskContainmentHierarchyFacadeinterface and its instance is available viaTaskManager.getTaskHierarchy()instance method. - Classes which wrap the tree model into treetable component:
GanttTree2,GanttTreeTable,GPTreeTableBase. The latter registersMouseListenerinstance on the column headers. - Class
TaskDefaultColumnprovides an enumeration of predefined columns with some specific properties for each column.
It seems that the best and cleanest way to implement this feature is:
- add a new method
TaskContainmentHierarchy::sort(Comparator), implement it properly - add
sortComparatorproperty toTaskDefaultColumninterface and its implementation inBEGIN_DATEandEND_DATE - register sorting actions in the table header on those columns which have sorting feature
This feature should eventually be merged into BRANCH_2_8_X and published in GanttProject 2.8.5. The base integration branch for pull requests is tkt_1216_master. Please target on using Java 7 (that is, do not use laguage features and libraries added in Java 8 and Java 9)