diff --git a/src/main/java/seedu/savvytasker/logic/Logic.java b/src/main/java/seedu/savvytasker/logic/Logic.java old mode 100644 new mode 100755 index bc55816f290a..7c6ab1691820 --- a/src/main/java/seedu/savvytasker/logic/Logic.java +++ b/src/main/java/seedu/savvytasker/logic/Logic.java @@ -1,8 +1,10 @@ package seedu.savvytasker.logic; +import java.util.Date; + import javafx.collections.ObservableList; -import seedu.savvytasker.logic.commands.CommandResult; import seedu.savvytasker.model.alias.AliasSymbol; +import seedu.savvytasker.logic.commands.CommandResult; import seedu.savvytasker.model.task.ReadOnlyTask; /** @@ -18,10 +20,23 @@ public interface Logic { /** Returns the filtered list of tasks */ ObservableList getFilteredTaskList(); - + /** Returns the filtered list of alias symbol */ ObservableList getAliasSymbolList(); /** */ boolean canParseHeader(String keyword); + + /** Returns the list of tasks that are overdue */ + ObservableList getFilteredOverdueTasks(); + + /** Returns the list of floating tasks */ + ObservableList getFilteredFloatingTasks(); + + /** Returns the list of tasks on a specific day */ + ObservableList getFilteredDailyTasks(Date date); + + /** Returns the list of tasks that occur after the selected week */ + ObservableList getFilteredUpcomingTasks(Date date); + } diff --git a/src/main/java/seedu/savvytasker/logic/LogicManager.java b/src/main/java/seedu/savvytasker/logic/LogicManager.java old mode 100644 new mode 100755 index 1a8f140f9125..5abe3aab9800 --- a/src/main/java/seedu/savvytasker/logic/LogicManager.java +++ b/src/main/java/seedu/savvytasker/logic/LogicManager.java @@ -1,5 +1,6 @@ package seedu.savvytasker.logic; +import java.util.Date; import java.util.List; import java.util.Stack; import java.util.logging.Logger; @@ -92,18 +93,38 @@ else if (command.canUndo()){ return result; } - + //@@author A0139915W @Override public ObservableList getFilteredTaskList() { return model.getFilteredTaskList(); } - @Override public ObservableList getAliasSymbolList() { return parser.getAliasSymbolList(); - } + } //@@author + + //@@author A0138431L + @Override + public ObservableList getFilteredOverdueTasks() { + return model.getFilteredOverdueTasks(); + } + + @Override + public ObservableList getFilteredFloatingTasks() { + return model.getFilteredFloatingTasks(); + } + + @Override + public ObservableList getFilteredDailyTasks(Date date) { + return model.getFilteredDailyTasks(date); + } + + @Override + public ObservableList getFilteredUpcomingTasks(Date date) { + return model.getFilteredUpcomingTasks(date); + } //@@author A0139916U private void registerAllDefaultCommandParsers() { diff --git a/src/main/java/seedu/savvytasker/model/Model.java b/src/main/java/seedu/savvytasker/model/Model.java old mode 100644 new mode 100755 index 4702191da93c..42cbf29705cf --- a/src/main/java/seedu/savvytasker/model/Model.java +++ b/src/main/java/seedu/savvytasker/model/Model.java @@ -1,6 +1,7 @@ package seedu.savvytasker.model; import java.util.LinkedList; +import java.util.Date; import seedu.savvytasker.commons.core.UnmodifiableObservableList; import seedu.savvytasker.model.alias.AliasSymbol; @@ -77,4 +78,33 @@ public interface Model { /** Removes an the given AliasSymbol. */ void removeAliasSymbol(AliasSymbol symbol) throws SymbolKeywordNotFoundException; + + //@@author A0138431L + /** Returns the filtered task list of overdue task as an {@code UnmodifiableObservableList} + * as of current date */ + UnmodifiableObservableList getFilteredOverdueTasks(); + + /** Returns the filtered task list of floating task as an {@code UnmodifiableObservableList} */ + UnmodifiableObservableList getFilteredFloatingTasks(); + + /** Returns the filtered task list of daily task as an {@code UnmodifiableObservableList} + * as of expected date */ + UnmodifiableObservableList getFilteredDailyTasks(Date date); + + /** Returns the filtered task list of upcoming task as an {@code UnmodifiableObservableList} + * as of expected date */ + UnmodifiableObservableList getFilteredUpcomingTasks(Date date); + + /** Updates the filter of the filtered task list to show all overdue tasks */ + void updateFilteredListToShowOverdue(); + + /** Updates the filter of the filtered task list to show all floating tasks */ + void updateFilteredListToShowFloating(); + + /** Updates the filter of the filtered task list to show all tasks of the selected week*/ + void updateFilteredListToShowDaily(); + + /** Updates the filter of the filtered task list to show all upcoming tasks after the selected week*/ + void updateFilteredListToShowUpcoming(); + //@@author } diff --git a/src/main/java/seedu/savvytasker/model/ModelManager.java b/src/main/java/seedu/savvytasker/model/ModelManager.java old mode 100644 new mode 100755 index 129c4c6a53c9..3addfa1f9199 --- a/src/main/java/seedu/savvytasker/model/ModelManager.java +++ b/src/main/java/seedu/savvytasker/model/ModelManager.java @@ -1,14 +1,17 @@ package seedu.savvytasker.model; import java.util.Arrays; +import java.util.Calendar; import java.util.Comparator; +import java.util.Date; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.logging.Logger; +import org.apache.commons.lang.time.DateUtils; + import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.SortedList; import seedu.savvytasker.commons.core.ComponentManager; @@ -23,6 +26,7 @@ import seedu.savvytasker.model.task.FindType; import seedu.savvytasker.model.task.ReadOnlyTask; import seedu.savvytasker.model.task.Task; +import seedu.savvytasker.model.task.TaskList.DuplicateTaskException; import seedu.savvytasker.model.task.TaskList.InvalidDateException; import seedu.savvytasker.model.task.TaskList.TaskNotFoundException; @@ -31,69 +35,141 @@ * All changes to any model should be synchronized. */ public class ModelManager extends ComponentManager implements Model { - private static final Logger logger = LogsCenter.getLogger(ModelManager.class); - - //@@author A0139915W - private final SavvyTasker savvyTasker; - private final FilteredList filteredTasks; - private final SortedList sortedAndFilteredTasks; - - /** - * Initializes a ModelManager with the given SavvyTasker - * and its variables should not be null - */ - public ModelManager(SavvyTasker src) { - super(); - assert src != null; - - logger.fine("Initializing with savvy tasker: " + src); - - savvyTasker = new SavvyTasker(src); - filteredTasks = new FilteredList<>(savvyTasker.getTasks()); - sortedAndFilteredTasks = new SortedList<>(filteredTasks, new TaskSortedByDueDate()); - updateFilteredListToShowActive(); // shows only active tasks on start - } - - public ModelManager() { - this(new SavvyTasker()); - } - - public ModelManager(ReadOnlySavvyTasker initialData) { - savvyTasker = new SavvyTasker(initialData); - filteredTasks = new FilteredList<>(savvyTasker.getTasks()); - sortedAndFilteredTasks = new SortedList<>(filteredTasks, new TaskSortedByDueDate()); - updateFilteredListToShowActive(); // shows only active tasks on start - } - //@@author - - @Override - public void resetData(ReadOnlySavvyTasker newData) { - savvyTasker.resetData(newData); - indicateSavvyTaskerChanged(); - } - - @Override - public ReadOnlySavvyTasker getSavvyTasker() { - return savvyTasker; - } - - /** Raises an event to indicate the model has changed */ - private void indicateSavvyTaskerChanged() { - raise(new SavvyTaskerChangedEvent(savvyTasker)); - } - //@@author A0139916U - - private void indicateAliasSymbolAdded(AliasSymbol symbol) { - raise(new AliasSymbolChangedEvent(symbol, AliasSymbolChangedEvent.Action.Added)); - } - - private void indicateAliasSymbolRemoved(AliasSymbol symbol) { - raise(new AliasSymbolChangedEvent(symbol, AliasSymbolChangedEvent.Action.Removed)); - } - //@@author - - - //@@author A0139915W + private static final Logger logger = LogsCenter.getLogger(ModelManager.class); + Date onDate = new Date(); + Date firstDayOfSelectedWeek = new Date(); + + //@@author A0139915W + private final SavvyTasker savvyTasker; + private final FilteredList filteredTasks; + private final SortedList sortedAndFilteredTasks; + private final FilteredList filteredFloatingTasks; + private final SortedList sortedAndFilteredFloatingTasks; + private final FilteredList filteredOverdueTasks; + private final SortedList sortedAndFilteredOverdueTasks; + private final FilteredList filteredDay1Tasks; + private final SortedList sortedAndFilteredDay1Tasks; + private final FilteredList filteredDay2Tasks; + private final SortedList sortedAndFilteredDay2Tasks; + private final FilteredList filteredDay3Tasks; + private final SortedList sortedAndFilteredDay3Tasks; + private final FilteredList filteredDay4Tasks; + private final SortedList sortedAndFilteredDay4Tasks; + private final FilteredList filteredDay5Tasks; + private final SortedList sortedAndFilteredDay5Tasks; + private final FilteredList filteredDay6Tasks; + private final SortedList sortedAndFilteredDay6Tasks; + private final FilteredList filteredDay7Tasks; + private final SortedList sortedAndFilteredDay7Tasks; + private final FilteredList filteredUpcomingTasks; + private final SortedList sortedAndFilteredUpcomingTasks; + + /** + * Initializes a ModelManager with the given SavvyTasker + * and its variables should not be null + */ + public ModelManager(SavvyTasker src) { + super(); + assert src != null; + + logger.fine("Initializing with savvy tasker: " + src); + + savvyTasker = new SavvyTasker(src); + filteredTasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredTasks = new SortedList<>(filteredTasks, new TaskSortedByDefault()); + + filteredFloatingTasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredFloatingTasks = new SortedList<>(filteredFloatingTasks, new TaskSortedByDefault()); + + filteredOverdueTasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredOverdueTasks = new SortedList<>(filteredOverdueTasks, new TaskSortedByDefault()); + + filteredDay1Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay1Tasks = new SortedList<>(filteredDay1Tasks, new TaskSortedByDefault()); + filteredDay2Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay2Tasks = new SortedList<>(filteredDay2Tasks, new TaskSortedByDefault()); + filteredDay3Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay3Tasks = new SortedList<>(filteredDay3Tasks, new TaskSortedByDefault()); + filteredDay4Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay4Tasks = new SortedList<>(filteredDay4Tasks, new TaskSortedByDefault()); + filteredDay5Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay5Tasks = new SortedList<>(filteredDay5Tasks, new TaskSortedByDefault()); + filteredDay6Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay6Tasks = new SortedList<>(filteredDay6Tasks, new TaskSortedByDefault()); + filteredDay7Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay7Tasks = new SortedList<>(filteredDay7Tasks, new TaskSortedByDefault()); + + filteredUpcomingTasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredUpcomingTasks = new SortedList<>(filteredUpcomingTasks, new TaskSortedByDefault()); + + updateFilteredListToShowActive(); // shows only active tasks on start + } + + public ModelManager() { + this(new SavvyTasker()); + } + + public ModelManager(ReadOnlySavvyTasker initialData) { + savvyTasker = new SavvyTasker(initialData); + filteredTasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredTasks = new SortedList<>(filteredTasks, new TaskSortedByDefault()); + + filteredFloatingTasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredFloatingTasks = new SortedList<>(filteredFloatingTasks, new TaskSortedByDefault()); + + filteredOverdueTasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredOverdueTasks = new SortedList<>(filteredOverdueTasks, new TaskSortedByDefault()); + + filteredDay1Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay1Tasks = new SortedList<>(filteredDay1Tasks, new TaskSortedByDefault()); + filteredDay2Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay2Tasks = new SortedList<>(filteredDay2Tasks, new TaskSortedByDefault()); + filteredDay3Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay3Tasks = new SortedList<>(filteredDay3Tasks, new TaskSortedByDefault()); + filteredDay4Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay4Tasks = new SortedList<>(filteredDay4Tasks, new TaskSortedByDefault()); + filteredDay5Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay5Tasks = new SortedList<>(filteredDay5Tasks, new TaskSortedByDefault()); + filteredDay6Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay6Tasks = new SortedList<>(filteredDay6Tasks, new TaskSortedByDefault()); + filteredDay7Tasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredDay7Tasks = new SortedList<>(filteredDay7Tasks, new TaskSortedByDefault()); + + filteredUpcomingTasks = new FilteredList<>(savvyTasker.getTasks()); + sortedAndFilteredUpcomingTasks = new SortedList<>(filteredUpcomingTasks, new TaskSortedByDefault()); + + updateFilteredListToShowActive(); // shows only active tasks on start + } + //@@author + + @Override + public void resetData(ReadOnlySavvyTasker newData) { + savvyTasker.resetData(newData); + indicateSavvyTaskerChanged(); + } + + @Override + public ReadOnlySavvyTasker getSavvyTasker() { + return savvyTasker; + } + + /** Raises an event to indicate the model has changed */ + private void indicateSavvyTaskerChanged() { + raise(new SavvyTaskerChangedEvent(savvyTasker)); + } + //@@author A0139916U + + private void indicateAliasSymbolAdded(AliasSymbol symbol) { + raise(new AliasSymbolChangedEvent(symbol, AliasSymbolChangedEvent.Action.Added)); + } + + private void indicateAliasSymbolRemoved(AliasSymbol symbol) { + raise(new AliasSymbolChangedEvent(symbol, AliasSymbolChangedEvent.Action.Removed)); + } + //@@author + + + //@@author A0139915W @Override public synchronized Task deleteTask(ReadOnlyTask target) throws TaskNotFoundException { Task taskDeleted = savvyTasker.removeTask(target); @@ -124,8 +200,8 @@ public synchronized LinkedList addRecurringTask(Task recurringTask) throws return recurringTasks; } //@@author - - //@@author A0139916U + + //@@author A0139916U @Override public synchronized void addAliasSymbol(AliasSymbol symbol) throws DuplicateSymbolKeywordException { savvyTasker.addAliasSymbol(symbol); @@ -141,7 +217,7 @@ public synchronized void removeAliasSymbol(AliasSymbol symbol) throws SymbolKeyw } //@@author - //=========== Filtered/Sorted Task List Accessors =============================================================== + //=========== Filtered/Sorted Task List Accessors =============================================================== //@@author A0139915W @Override @@ -163,52 +239,182 @@ public void updateFilteredListToShowActiveSortedByPriorityLevel() { public void updateFilteredListToShowActive() { updateFilteredTaskList(new PredicateExpression(new TaskIsActiveQualifier())); } - private void updateFilteredListToShowActive(Comparator comparator) { - updateFilteredTaskList( - new PredicateExpression(new TaskIsActiveQualifier()), - comparator); - } - - @Override - public void updateFilteredListToShowArchived() { - updateFilteredTaskList(new PredicateExpression(new TaskIsArchivedQualifier())); - } - @Override - public void updateFilteredTaskList(FindType findType, String[] keywords) { - assert findType != null; - Qualifier qualifier = null; - switch (findType) - { - case Partial: - qualifier = new TaskNamePartialMatchQualifier(keywords); - break; - case Full: - qualifier = new TaskNameFullMatchQualifier(keywords); - break; - case Exact: - qualifier = new TaskNameExactMatchQualifier(keywords); - break; - case Category: - qualifier = new CategoryPartialMatchQualifier(keywords); - break; - default: - assert false; // should never get here. - } - updateFilteredTaskList(new PredicateExpression(qualifier)); - } - - private void updateFilteredTaskList(Expression expression) { - updateFilteredTaskList(expression, new TaskSortedByDefault()); - } - - private void updateFilteredTaskList(Expression expression, Comparator comparator) { - filteredTasks.setPredicate(expression::satisfies); - sortedAndFilteredTasks.setComparator(comparator); - } - //@@author - - //========== Inner classes/interfaces used for filtering ================================================== + private void updateFilteredListToShowActive(Comparator comparator) { + updateFilteredTaskList( + new PredicateExpression(new TaskIsActiveQualifier()), + comparator); + } + + @Override + public void updateFilteredListToShowArchived() { + updateFilteredTaskList(new PredicateExpression(new TaskIsArchivedQualifier())); + } + + @Override + public void updateFilteredTaskList(FindType findType, String[] keywords) { + assert findType != null; + Qualifier qualifier = null; + switch (findType) + { + case Partial: + qualifier = new TaskNamePartialMatchQualifier(keywords); + break; + case Full: + qualifier = new TaskNameFullMatchQualifier(keywords); + break; + case Exact: + qualifier = new TaskNameExactMatchQualifier(keywords); + break; + case Category: + qualifier = new CategoryPartialMatchQualifier(keywords); + break; + default: + assert false; // should never get here. + } + updateFilteredTaskList(new PredicateExpression(qualifier)); + } + + private void updateFilteredTaskList(Expression expression) { + updateFilteredTaskList(expression, new TaskSortedByDefault()); + } + + private void updateFilteredTaskList(Expression expression, Comparator comparator) { + filteredTasks.setPredicate(expression::satisfies); + sortedAndFilteredTasks.setComparator(comparator); + } + //@@author + + //@author A0138431L + //Get filtered task list according to date category + @Override + public UnmodifiableObservableList getFilteredOverdueTasks() { + updateFilteredListToShowOverdue(); + return new UnmodifiableObservableList(filteredOverdueTasks); + } + + @Override + public UnmodifiableObservableList getFilteredFloatingTasks() { + updateFilteredListToShowFloating(); + return new UnmodifiableObservableList(filteredFloatingTasks); + } + + @Override + public UnmodifiableObservableList getFilteredDailyTasks(int dayOfWeek, Date date) { + this.onDate = date; + updateFilteredListToShowDaily(dayOfWeek); + switch(dayOfWeek) { + case 0: + return new UnmodifiableObservableList(filteredDay1Tasks); + case 1: + return new UnmodifiableObservableList(filteredDay2Tasks); + case 2: + return new UnmodifiableObservableList(filteredDay3Tasks); + case 3: + return new UnmodifiableObservableList(filteredDay4Tasks); + case 4: + return new UnmodifiableObservableList(filteredDay5Tasks); + case 5: + return new UnmodifiableObservableList(filteredDay6Tasks); + case 6: + return new UnmodifiableObservableList(filteredDay7Tasks); + default: + return new UnmodifiableObservableList(filteredDay1Tasks); + } + } + + @Override + public UnmodifiableObservableList getFilteredUpcomingTasks(Date date) { + this.firstDayOfSelectedWeek = date; + updateFilteredListToShowUpcoming(); + return new UnmodifiableObservableList(filteredUpcomingTasks); + } + + //Binding isOverdue quantifier predicate to filtered list + @Override + public void updateFilteredListToShowOverdue() { + updateFilteredOverdueTaskList(new PredicateExpression(new TaskIsOverdueQualifier())); + } + + private void updateFilteredOverdueTaskList(Expression expression) { + updateFilteredOverdueTaskList(expression, new TaskSortedByDefault()); + } + + private void updateFilteredOverdueTaskList(Expression expression, Comparator comparator) { + filteredOverdueTasks.setPredicate(expression::satisfies); + sortedAndFilteredOverdueTasks.setComparator(comparator); + } + + //Binding isFloating quantifier predicate to filtered list + @Override + public void updateFilteredListToShowFloating() { + updateFilteredFloatingTaskList(new PredicateExpression(new TaskIsFloatingQualifier())); + } + + private void updateFilteredFloatingTaskList(Expression expression) { + updateFilteredFloatingTaskList(expression, new TaskSortedByDefault()); + } + + private void updateFilteredFloatingTaskList(Expression expression, Comparator comparator) { + filteredFloatingTasks.setPredicate(expression::satisfies); + sortedAndFilteredFloatingTasks.setComparator(comparator); + } + + //Binding isOnDate quantifier predicate to filtered list + @Override + public void updateFilteredListToShowDaily(int dayOfWeek) { + updateFilteredDailyTaskList(new PredicateExpression(new TaskIsOnDateQualifier()), dayOfWeek); + } + + private void updateFilteredDailyTaskList(Expression expression, int dayOfWeek) { + updateFilteredDailyTaskList(expression, new TaskSortedByDefault(), dayOfWeek); + } + + private void updateFilteredDailyTaskList(Expression expression, Comparator comparator, int dayOfWeek) { + switch(dayOfWeek) { + case 0: + filteredDay1Tasks.setPredicate(expression::satisfies); + sortedAndFilteredDay1Tasks.setComparator(comparator); + case 1: + filteredDay2Tasks.setPredicate(expression::satisfies); + sortedAndFilteredDay2Tasks.setComparator(comparator); + case 2: + filteredDay3Tasks.setPredicate(expression::satisfies); + sortedAndFilteredDay3Tasks.setComparator(comparator); + case 3: + filteredDay4Tasks.setPredicate(expression::satisfies); + sortedAndFilteredDay4Tasks.setComparator(comparator); + case 4: + filteredDay5Tasks.setPredicate(expression::satisfies); + sortedAndFilteredDay5Tasks.setComparator(comparator); + case 5: + filteredDay6Tasks.setPredicate(expression::satisfies); + sortedAndFilteredDay6Tasks.setComparator(comparator); + case 6: + filteredDay7Tasks.setPredicate(expression::satisfies); + sortedAndFilteredDay7Tasks.setComparator(comparator); + + } + } + + //Binding isUpcoming quantifier predicate to filtered list + @Override + public void updateFilteredListToShowUpcoming() { + updateFilteredUpcomingTaskList(new PredicateExpression(new TaskIsUpcomingQualifier())); + } + + private void updateFilteredUpcomingTaskList(Expression expression) { + updateFilteredUpcomingTaskList(expression, new TaskSortedByDefault()); + } + + private void updateFilteredUpcomingTaskList(Expression expression, Comparator comparator) { + filteredUpcomingTasks.setPredicate(expression::satisfies); + sortedAndFilteredUpcomingTasks.setComparator(comparator); + } + + //@@author + + //========== Inner classes/interfaces used for filtering ================================================== interface Expression { boolean satisfies(ReadOnlyTask task); @@ -405,9 +611,224 @@ public boolean run(ReadOnlyTask task) { public String toString() { return "isArchived=true"; } - } + }//@@author + + //@@author A0138431L + /** + * Qualifier for checking if {@link Task} is an overdue task + * @author A0138431L + * + * A overdue task is a deadline or event task with end dateTime after current dateTime + * + * @return true if the task is overdue + * + */ + private class TaskIsOverdueQualifier implements Qualifier { + + @Override + public boolean run(ReadOnlyTask task) { + + Date today = new Date(); + + boolean isOverdue = false; + + if (task.getEndDateTime() != null) { + + Date endDateTime = task.getEndDateTime(); + + if (endDateTime.compareTo(today)<0 && task.isArchived() == false) { + + isOverdue = true; + } + + } + + return isOverdue; + + } + + @Override + public String toString() { + return "isOverdue=true"; + } + } + + /** + * Qualifier for checking if {@link Task} is a floating task + * @author A0138431L + * + * A floating task do not have start or end time + * + * @return true if the task falls on the date specified. else return false + * + */ + private class TaskIsFloatingQualifier implements Qualifier { + + @Override + public boolean run(ReadOnlyTask task) { + + boolean isFloating = false; + + if(task.getStartDateTime() == null && task.getEndDateTime() == null && task.isArchived() == false) { + + isFloating = true; + + } + + return isFloating; + + } + + @Override + public String toString() { + return "isFloating=true"; + } + } + + /** + * Qualifier for checking if {@link Task} falls on the selected date + * @author A0138431L + * + * Check whether the task is on the date specified (for deadline tasks) + * Check whether the date specified is within the range of date the task (for event tasks) + * Includes task that are completed. + * + * @return true if the task falls on the date specified. else return false + * + */ + private class TaskIsOnDateQualifier implements Qualifier { + + @Override + public boolean run(ReadOnlyTask task) { + + Date expectedDate = onDate; + + boolean isOnDate = false; + + //Archived Task + if(task.isArchived() == true){ + + isOnDate = false; + + } + //Deadline Task + else if(task.getStartDateTime() == null && task.getEndDateTime() != null) { + + Date endDateTime = task.getEndDateTime(); + + if (DateUtils.isSameDay(endDateTime, expectedDate)) { + + isOnDate = true; + + } + + } + //Event Task + else if(task.getStartDateTime() != null && task.getEndDateTime() != null) { + + Date startDateTime = task.getStartDateTime(); + Date endDateTime = task.getEndDateTime(); + + if (DateUtils.isSameDay(startDateTime, expectedDate)) { + + isOnDate = true; + + } else if (DateUtils.isSameDay(endDateTime, expectedDate)) { + + isOnDate = true; + + } else if (startDateTime.compareTo(expectedDate)<0 && expectedDate.compareTo(endDateTime)<0) { + + isOnDate = true; + + } + } + + return isOnDate; + } + + @Override + public String toString() { + return "isOnDate=true"; + } + } + + /** + * Qualifier for checking if {@link Task} task is upcoming + * @author A0138431L + * + * A upcoming task is a task that will happen after the last day, 2359 of selected week + * + * @return true if the task is a upcoming task + * + */ + private class TaskIsUpcomingQualifier implements Qualifier { + + @Override + public boolean run(ReadOnlyTask task) { + + Date lastDateOfExpectedWeek = firstDayOfSelectedWeek; + + //convert date object to calendar object and add 7 days, last day of the selected week + Calendar calendarExpectedDate = Calendar.getInstance(); + calendarExpectedDate.setTime(lastDateOfExpectedWeek); + calendarExpectedDate.add(Calendar.DAY_OF_MONTH, 7); + calendarExpectedDate.set(Calendar.HOUR_OF_DAY,23); + calendarExpectedDate.set(Calendar.MINUTE,59); + calendarExpectedDate.set(Calendar.SECOND,59); + + //convert calendar object back to date object + lastDateOfExpectedWeek = calendarExpectedDate.getTime(); + + boolean isUpcoming = true; + + //Archived Task + if(task.isArchived() == true){ + + isUpcoming = false; + + } + + //Floating Task + else if(task.getStartDateTime() == null && task.getEndDateTime() == null) { + + isUpcoming = false; + + } + //Deadline Task + else if(task.getStartDateTime() == null && task.getEndDateTime() != null) { + + + if (task.getEndDateTime().compareTo(lastDateOfExpectedWeek)<0) { + + isUpcoming = false; + + } + + } + //Event Task + else { + + if (task.getStartDateTime().compareTo(lastDateOfExpectedWeek)<0) { + + isUpcoming = false; + + } + + } + + return isUpcoming; + } + + @Override + public String toString() { + return "isUpcoming=true"; + } + }//@@author - //========== Inner classes/interfaces used for sorting ================================================== + //@@author A0139915W + + //========== Inner classes/interfaces used for sorting ================================================== /** * Compares {@link Task} by their default field, id @@ -476,4 +897,4 @@ public int compare(Task task1, Task task2) { } //@@author -} +} \ No newline at end of file diff --git a/src/main/java/seedu/savvytasker/ui/MainWindow.java b/src/main/java/seedu/savvytasker/ui/MainWindow.java old mode 100644 new mode 100755 index cd0a710fcb4a..a68da8c0b682 --- a/src/main/java/seedu/savvytasker/ui/MainWindow.java +++ b/src/main/java/seedu/savvytasker/ui/MainWindow.java @@ -1,5 +1,7 @@ package seedu.savvytasker.ui; +import java.util.Date; + import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.Scene; @@ -18,18 +20,21 @@ /** * The Main Window. Provides the basic application layout containing * a menu bar and space where other JavaFX elements can be placed. + * + * @author A0138431L + * */ public class MainWindow extends UiPart { private static final String ICON = "/images/address_book_32.png"; private static final String FXML = "MainWindow.fxml"; public static final int MIN_HEIGHT = 600; - public static final int MIN_WIDTH = 450; + public static final int MIN_WIDTH = 850; private Logic logic; - + Date date = new Date(); // Independent Ui parts residing in this Ui container - private BrowserPanel browserPanel; + //private BrowserPanel browserPanel; private TaskListPanel taskListPanel; private AliasSymbolListPanel aliasSymbolListPanel; private ResultDisplay resultDisplay; @@ -37,7 +42,13 @@ public class MainWindow extends UiPart { private CommandBox commandBox; private Config config; private UserPrefs userPrefs; - + @FXML + private FloatingPanel floatingPanel; + @FXML + private OverduePanel overduePanel; + @FXML + private UpcomingPanel upcomingPanel; + // Handles to elements of this Ui container private VBox rootLayout; private Scene scene; @@ -59,16 +70,26 @@ public class MainWindow extends UiPart { @FXML private AnchorPane aliasSymbolListPanelPlaceholder; + private AnchorPane personListPanelPlaceholder; + @FXML private AnchorPane resultDisplayPlaceholder; @FXML private AnchorPane statusbarPlaceholder; - + @FXML private VBox listPanel; - + @FXML + private AnchorPane floatingPanelPlaceholder; + /* + @FXML + private AnchorPane overduePanelPlaceholder; + + @FXML + private AnchorPane upcomingPanelPlaceholder; +*/ public MainWindow() { super(); } @@ -115,16 +136,19 @@ private void setAccelerators() { } void fillInnerParts() { - browserPanel = BrowserPanel.load(browserPlaceholder); + //browserPanel = BrowserPanel.load(browserPlaceholder); taskListPanel = TaskListPanel.load(primaryStage, getTaskListPlaceholder(), logic.getFilteredTaskList()); aliasSymbolListPanel = AliasSymbolListPanel.load(primaryStage, getAliasSymbolPlaceholder(), logic.getAliasSymbolList()); setDefaultView(); resultDisplay = ResultDisplay.load(primaryStage, getResultDisplayPlaceholder()); statusBarFooter = StatusBarFooter.load(primaryStage, getStatusbarPlaceholder(), config.getAddressBookFilePath()); commandBox = CommandBox.load(primaryStage, getCommandBoxPlaceholder(), resultDisplay, logic); + floatingPanel = FloatingPanel.load(primaryStage, getFloatingPanelPlaceholder(), logic.getFilteredFloatingTasks()); + overduePanel = OverduePanel.load(primaryStage, getOverduePanelPlaceholder(), logic.getFilteredOverdueTasks()); + upcomingPanel = UpcomingPanel.load(primaryStage, getUpcomingPanelPlaceholder(), logic.getFilteredUpcomingTasks(date)); } - /** + /** * Removes all the children in the taskPanel VBox * Shows the default list, which is the list of tasks */ @@ -151,7 +175,7 @@ public void showTaskList(boolean isShown) { private VBox getListPanel() { return listPanel; } - + private AnchorPane getCommandBoxPlaceholder() { return commandBoxPlaceholder; } @@ -171,7 +195,19 @@ public AnchorPane getTaskListPlaceholder() { public AnchorPane getAliasSymbolPlaceholder() { return aliasSymbolListPanelPlaceholder; } - + + //private AnchorPane getOverduePanelPlaceholder() { + // return overduePanelPlaceholder; + //} + + private AnchorPane getFloatingPanelPlaceholder() { + return floatingPanelPlaceholder; + } + + //private AnchorPane getUpcomingPanelPlaceholder() { + // return upcomingPanelPlaceholder; + //} + public void hide() { primaryStage.hide(); } @@ -222,7 +258,7 @@ public void show() { private void handleExit() { raise(new ExitAppRequestEvent()); } - + public AliasSymbolListPanel getAliasSymbolListPanel() { return this.aliasSymbolListPanel; } @@ -232,10 +268,10 @@ public TaskListPanel getTaskListPanel() { } public void loadPersonPage(ReadOnlyTask task) { - browserPanel.loadPersonPage(task); + //browserPanel.loadPersonPage(task); } public void releaseResources() { - browserPanel.freeResources(); + //browserPanel.freeResources(); } } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml old mode 100644 new mode 100755 index e2567ee9ad65..7d84882e3947 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -1,10 +1,20 @@ - - - - + + + + + + + + + + + + + + @@ -24,32 +34,59 @@ - + - + - + - + - + - + - + - - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +