From 594e5dba9d6d11c80e800f59a9c4e52536abed20 Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Sun, 17 Mar 2024 01:35:03 +0800 Subject: [PATCH 01/14] Add ui panel for task list --- .../java/seedu/address/ui/MainWindow.java | 1 + src/main/java/seedu/address/ui/TaskCard.java | 58 +++++++++++++++++++ .../java/seedu/address/ui/TaskListPanel.java | 49 ++++++++++++++++ src/main/resources/view/MainWindow.fxml | 41 ++++++++----- src/main/resources/view/TaskListCard.fxml | 41 +++++++++++++ src/main/resources/view/TaskListPanel.fxml | 8 +++ 6 files changed, 183 insertions(+), 15 deletions(-) create mode 100644 src/main/java/seedu/address/ui/TaskCard.java create mode 100644 src/main/java/seedu/address/ui/TaskListPanel.java create mode 100644 src/main/resources/view/TaskListCard.fxml create mode 100644 src/main/resources/view/TaskListPanel.fxml diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 79e74ef37c0..1e98dd22ee6 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -32,6 +32,7 @@ public class MainWindow extends UiPart { // Independent Ui parts residing in this Ui container private PersonListPanel personListPanel; + private TaskListPanel taskListPanel; private ResultDisplay resultDisplay; private HelpWindow helpWindow; diff --git a/src/main/java/seedu/address/ui/TaskCard.java b/src/main/java/seedu/address/ui/TaskCard.java new file mode 100644 index 00000000000..b473546326d --- /dev/null +++ b/src/main/java/seedu/address/ui/TaskCard.java @@ -0,0 +1,58 @@ +package seedu.address.ui; + +import java.util.Comparator; + +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.layout.FlowPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Region; +import seedu.address.model.task.Task; + +/** + * An UI component that displays information of a {@code Person}. + */ +public class TaskCard extends UiPart { + + private static final String FXML = "TaskListCard.fxml"; + + /** + * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. + * As a consequence, UI elements' variable names cannot be set to such keywords + * or an exception will be thrown by JavaFX during runtime. + * + * @see The issue on AddressBook level 4 + */ + + public final Task task; + + @FXML + private HBox cardPane; + @FXML + private Label name; + @FXML + private Label id; + @FXML + private Label mark; + @FXML + private Label description; + + /* + @FXML + private Label email; + @FXML + private FlowPane tags; + */ + + /** + * Creates a {@code TaskCode} with the given {@code Task} and index to display. + */ + public TaskCard(Task task, int displayedIndex) { + super(FXML); + this.task = task; + id.setText(displayedIndex + ". "); + //name.setText(task.getName().fullName); + //mark.setText(task.getMark().value); + description.setText(task.getDescription()); + } +} diff --git a/src/main/java/seedu/address/ui/TaskListPanel.java b/src/main/java/seedu/address/ui/TaskListPanel.java new file mode 100644 index 00000000000..880577c6da9 --- /dev/null +++ b/src/main/java/seedu/address/ui/TaskListPanel.java @@ -0,0 +1,49 @@ +package seedu.address.ui; + +import java.util.logging.Logger; + +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.scene.layout.Region; +import seedu.address.commons.core.LogsCenter; +import seedu.address.model.task.Task; + +/** + * Panel containing the list of persons. + */ +public class TaskListPanel extends UiPart { + private static final String FXML = "PersonListPanel.fxml"; + private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); + + @FXML + private ListView taskListView; + + /** + * Creates a {@code PersonListPanel} with the given {@code ObservableList}. + */ + public TaskListPanel(ObservableList taskList) { + super(FXML); + taskListView.setItems(taskList); + taskListView.setCellFactory(listView -> new TaskListViewCell()); + } + + /** + * Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}. + */ + class TaskListViewCell extends ListCell { + @Override + protected void updateItem(Task task, boolean empty) { + super.updateItem(task, empty); + + if (empty || task == null) { + setGraphic(null); + setText(null); + } else { + setGraphic(new TaskCard(task, getIndex() + 1).getRoot()); + } + } + } + +} diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 7778f666a0a..42141020a99 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -6,13 +6,13 @@ - + + - + @@ -33,25 +33,36 @@ - + - + - + - + - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/view/TaskListCard.fxml b/src/main/resources/view/TaskListCard.fxml new file mode 100644 index 00000000000..f0b6145460e --- /dev/null +++ b/src/main/resources/view/TaskListCard.fxml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/view/TaskListPanel.fxml b/src/main/resources/view/TaskListPanel.fxml new file mode 100644 index 00000000000..9753448ffdb --- /dev/null +++ b/src/main/resources/view/TaskListPanel.fxml @@ -0,0 +1,8 @@ + + + + + + + + From 45818bec35a4f9f1f90bd0464aa12ba55661778e Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 02:52:23 +0800 Subject: [PATCH 02/14] Add listtask command --- src/main/java/seedu/address/logic/Logic.java | 4 +++ .../seedu/address/logic/LogicManager.java | 7 +++++ .../logic/commands/ListTaskCommand.java | 24 +++++++++++++++ .../logic/parser/AddressBookParser.java | 14 +++------ src/main/java/seedu/address/model/Model.java | 12 ++++++++ .../seedu/address/model/ModelManager.java | 30 ++++++++++++++++++- .../java/seedu/address/ui/MainWindow.java | 8 +++++ .../java/seedu/address/ui/TaskListPanel.java | 2 +- src/main/resources/view/TaskListCard.fxml | 22 ++++++++------ 9 files changed, 102 insertions(+), 21 deletions(-) create mode 100644 src/main/java/seedu/address/logic/commands/ListTaskCommand.java diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 92cd8fa605a..5e1f29acc2b 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -9,6 +9,7 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Person; +import seedu.address.model.task.Task; /** * API of the Logic component @@ -33,6 +34,9 @@ public interface Logic { /** Returns an unmodifiable view of the filtered list of persons */ ObservableList getFilteredPersonList(); + /** Returns an unmodifiable view of the filtered list of tasks */ + ObservableList getFilteredTaskList(); + /** * Returns the user prefs' address book file path. */ diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index b60400449bf..5ac3fda1718 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -5,6 +5,7 @@ import java.nio.file.Path; import java.util.logging.Logger; +import javafx.collections.FXCollections; import javafx.collections.ObservableList; import seedu.address.commons.core.GuiSettings; import seedu.address.commons.core.LogsCenter; @@ -16,6 +17,7 @@ import seedu.address.model.Model; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Person; +import seedu.address.model.task.Task; import seedu.address.storage.Storage; /** @@ -72,6 +74,11 @@ public ObservableList getFilteredPersonList() { return model.getFilteredPersonList(); } + @Override + public ObservableList getFilteredTaskList() { + return model.getFilteredTaskList(); + } + @Override public Path getAddressBookFilePath() { return model.getAddressBookFilePath(); diff --git a/src/main/java/seedu/address/logic/commands/ListTaskCommand.java b/src/main/java/seedu/address/logic/commands/ListTaskCommand.java new file mode 100644 index 00000000000..379c2744014 --- /dev/null +++ b/src/main/java/seedu/address/logic/commands/ListTaskCommand.java @@ -0,0 +1,24 @@ +package seedu.address.logic.commands; + +import static java.util.Objects.requireNonNull; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_TASKS; + +import seedu.address.model.Model; + +/** + * Lists all tasks in the tasklist to the user. + */ +public class ListTaskCommand extends Command { + + public static final String COMMAND_WORD = "listtask"; + + public static final String MESSAGE_SUCCESS = "Listed all tasks"; + + + @Override + public CommandResult execute(Model model) { + requireNonNull(model); + model.updateFilteredTaskList(PREDICATE_SHOW_ALL_TASKS); + return new CommandResult(MESSAGE_SUCCESS); + } +} diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 5bb672aac79..1f086b71b9f 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -8,16 +8,7 @@ import java.util.regex.Pattern; import seedu.address.commons.core.LogsCenter; -import seedu.address.logic.commands.AddCommand; -import seedu.address.logic.commands.AddTaskCommand; -import seedu.address.logic.commands.ClearCommand; -import seedu.address.logic.commands.Command; -import seedu.address.logic.commands.DeleteCommand; -import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.ExitCommand; -import seedu.address.logic.commands.FindCommand; -import seedu.address.logic.commands.HelpCommand; -import seedu.address.logic.commands.ListCommand; +import seedu.address.logic.commands.*; import seedu.address.logic.parser.exceptions.ParseException; /** @@ -75,6 +66,9 @@ public Command parseCommand(String userInput) throws ParseException { case ListCommand.COMMAND_WORD: return new ListCommand(); + case ListTaskCommand.COMMAND_WORD: + return new ListTaskCommand(); + case ExitCommand.COMMAND_WORD: return new ExitCommand(); diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 5bc2d35e4de..03743f47713 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -15,6 +15,9 @@ public interface Model { /** {@code Predicate} that always evaluate to true */ Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; + /** {@code Predicate} that always evaluate to true */ + Predicate PREDICATE_SHOW_ALL_TASKS = unused -> true; + /** * Replaces user prefs data with the data in {@code userPrefs}. */ @@ -108,6 +111,15 @@ static void setTaskList(TaskList taskList) {} */ boolean hasTask(Task task); + /** + * Updates the filter of the filtered person list to filter by the given {@code predicate}. + * @throws NullPointerException if {@code predicate} is null. + */ + void updateFilteredTaskList(Predicate predicate); + + /** Returns an unmodifiable view of the filtered task list */ + ObservableList getFilteredTaskList(); + /** Returns an unmodifiable view of the filtered person list */ ObservableList getFilteredPersonList(); diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 24e6ff2a8d6..5c2deeb1945 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -23,6 +23,7 @@ public class ModelManager implements Model { private final TaskList taskList; private final UserPrefs userPrefs; private final FilteredList filteredPersons; + private final FilteredList filteredTasks; /** * Initializes a ModelManager with the given addressBook and userPrefs. @@ -37,6 +38,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, TaskList taskList, ReadOnly this.taskList = taskList; this.userPrefs = new UserPrefs(userPrefs); filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); + filteredTasks = new FilteredList<>(this.taskList.getSerializeTaskList()); } public ModelManager() { @@ -138,6 +140,7 @@ public void setPerson(Person target, Person editedPerson) { @Override public void addTask(Task task) { taskList.addTask(task); + updateFilteredTaskList(PREDICATE_SHOW_ALL_TASKS); } @Override @@ -163,6 +166,30 @@ public TaskList getTaskList() { return taskList; } + /** + * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of + * {@code versionedAddressBook} + */ + @Override + public ObservableList getFilteredTaskList() { + return filteredTasks; + } + + @Override + public void updateFilteredTaskList(Predicate predicate) { + requireNonNull(predicate); + //filteredTasks = new FilteredList<>(taskList.getSerializeTaskList()); + filteredTasks.setPredicate(predicate); + + for (Task t : filteredTasks) { + System.out.println(t.getDescription()); + } + + for (Task t : taskList.getSerializeTaskList()) { + System.out.println(t.getDescription()); + } + } + //=========== Filtered Person List Accessors ============================================================= /** @@ -194,7 +221,8 @@ public boolean equals(Object other) { ModelManager otherModelManager = (ModelManager) other; return addressBook.equals(otherModelManager.addressBook) && userPrefs.equals(otherModelManager.userPrefs) - && filteredPersons.equals(otherModelManager.filteredPersons); + && filteredPersons.equals(otherModelManager.filteredPersons) + && filteredTasks.equals(otherModelManager.filteredTasks); } } diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 1e98dd22ee6..dcca984cd4d 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -44,6 +44,8 @@ public class MainWindow extends UiPart { @FXML private StackPane personListPanelPlaceholder; + @FXML + private StackPane taskListPanelPlaceholder; @FXML private StackPane resultDisplayPlaceholder; @@ -111,6 +113,10 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { * Fills up all the placeholders of this window. */ void fillInnerParts() { + + taskListPanel = new TaskListPanel(logic.getFilteredTaskList()); + taskListPanelPlaceholder.getChildren().add(taskListPanel.getRoot()); + personListPanel = new PersonListPanel(logic.getFilteredPersonList()); personListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); @@ -168,6 +174,8 @@ public PersonListPanel getPersonListPanel() { return personListPanel; } + public TaskListPanel getTaskListPanel() { return taskListPanel; } + /** * Executes the command and returns the result. * diff --git a/src/main/java/seedu/address/ui/TaskListPanel.java b/src/main/java/seedu/address/ui/TaskListPanel.java index 880577c6da9..a32c710456a 100644 --- a/src/main/java/seedu/address/ui/TaskListPanel.java +++ b/src/main/java/seedu/address/ui/TaskListPanel.java @@ -14,7 +14,7 @@ * Panel containing the list of persons. */ public class TaskListPanel extends UiPart { - private static final String FXML = "PersonListPanel.fxml"; + private static final String FXML = "TaskListPanel.fxml"; private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); @FXML diff --git a/src/main/resources/view/TaskListCard.fxml b/src/main/resources/view/TaskListCard.fxml index f0b6145460e..f01053882fc 100644 --- a/src/main/resources/view/TaskListCard.fxml +++ b/src/main/resources/view/TaskListCard.fxml @@ -7,35 +7,39 @@ + - + - + - + - + + + + + + - - - - - + + + From 8713ea0c79fec11705fe8e6df46183c44e84b129 Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 03:29:38 +0800 Subject: [PATCH 03/14] Add observableList to Task --- src/main/java/seedu/address/model/ModelManager.java | 9 --------- src/main/java/seedu/address/model/TaskList.java | 6 +++++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 5c2deeb1945..e2d8ce183f8 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -178,16 +178,7 @@ public ObservableList getFilteredTaskList() { @Override public void updateFilteredTaskList(Predicate predicate) { requireNonNull(predicate); - //filteredTasks = new FilteredList<>(taskList.getSerializeTaskList()); filteredTasks.setPredicate(predicate); - - for (Task t : filteredTasks) { - System.out.println(t.getDescription()); - } - - for (Task t : taskList.getSerializeTaskList()) { - System.out.println(t.getDescription()); - } } //=========== Filtered Person List Accessors ============================================================= diff --git a/src/main/java/seedu/address/model/TaskList.java b/src/main/java/seedu/address/model/TaskList.java index 828f5ead783..6fd647040e0 100644 --- a/src/main/java/seedu/address/model/TaskList.java +++ b/src/main/java/seedu/address/model/TaskList.java @@ -12,17 +12,20 @@ */ public class TaskList { private ArrayList taskList; + private ObservableList observableList; /** * Constructor of the class. */ public TaskList() { taskList = new ArrayList<>(); + observableList = FXCollections.observableArrayList(taskList); } @SuppressWarnings("unchecked") public void setTaskList(TaskList tasks) { taskList.addAll((Collection) tasks); + observableList.addAll((Collection) tasks); } /** @@ -32,10 +35,11 @@ public void setTaskList(TaskList tasks) { */ public void addTask(Task task) { taskList.add(task); + observableList.add(task); } public ObservableList getSerializeTaskList() { - return FXCollections.unmodifiableObservableList(FXCollections.observableArrayList(taskList)); + return observableList; } public boolean hasTask(Task task) { From 2e7c29263be3c9e201154a418c0f89733f57129a Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 16:24:23 +0800 Subject: [PATCH 04/14] Fix checkstyle issues --- src/main/java/seedu/address/logic/LogicManager.java | 1 - .../java/seedu/address/logic/parser/AddressBookParser.java | 6 +++--- src/main/java/seedu/address/model/TaskList.java | 1 + src/main/java/seedu/address/ui/MainWindow.java | 4 +++- src/main/java/seedu/address/ui/TaskCard.java | 3 --- src/main/resources/view/MainWindow.fxml | 6 +++--- src/main/resources/view/TaskListCard.fxml | 4 ++-- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index 5ac3fda1718..727226a8cbd 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -5,7 +5,6 @@ import java.nio.file.Path; import java.util.logging.Logger; -import javafx.collections.FXCollections; import javafx.collections.ObservableList; import seedu.address.commons.core.GuiSettings; import seedu.address.commons.core.LogsCenter; diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 4ab89bf436e..7f3f0d44fef 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -19,7 +19,7 @@ import seedu.address.logic.commands.FindCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCommand; - +import seedu.address.logic.commands.ListTaskCommand; import seedu.address.logic.parser.exceptions.ParseException; /** @@ -76,10 +76,10 @@ public Command parseCommand(String userInput) throws ParseException { case ListCommand.COMMAND_WORD: return new ListCommand(); - + case ListTaskCommand.COMMAND_WORD: return new ListTaskCommand(); - + case AssignCommand.COMMAND_WORD: return new AssignCommandParser().parse(arguments); diff --git a/src/main/java/seedu/address/model/TaskList.java b/src/main/java/seedu/address/model/TaskList.java index b06a8d5a99a..b0cbfa9165b 100644 --- a/src/main/java/seedu/address/model/TaskList.java +++ b/src/main/java/seedu/address/model/TaskList.java @@ -3,6 +3,7 @@ import static java.util.Objects.requireNonNull; import java.util.ArrayList; +import java.util.Collection; import javafx.collections.FXCollections; import javafx.collections.ObservableList; diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index dcca984cd4d..ecb69d9a635 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -174,7 +174,9 @@ public PersonListPanel getPersonListPanel() { return personListPanel; } - public TaskListPanel getTaskListPanel() { return taskListPanel; } + public TaskListPanel getTaskListPanel() { + return taskListPanel; + } /** * Executes the command and returns the result. diff --git a/src/main/java/seedu/address/ui/TaskCard.java b/src/main/java/seedu/address/ui/TaskCard.java index b473546326d..f19ee87d499 100644 --- a/src/main/java/seedu/address/ui/TaskCard.java +++ b/src/main/java/seedu/address/ui/TaskCard.java @@ -1,10 +1,7 @@ package seedu.address.ui; -import java.util.Comparator; - import javafx.fxml.FXML; import javafx.scene.control.Label; -import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; import seedu.address.model.task.Task; diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 42141020a99..0d75c470665 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -46,15 +46,15 @@ - + - - + + diff --git a/src/main/resources/view/TaskListCard.fxml b/src/main/resources/view/TaskListCard.fxml index f01053882fc..916993fd832 100644 --- a/src/main/resources/view/TaskListCard.fxml +++ b/src/main/resources/view/TaskListCard.fxml @@ -27,9 +27,9 @@ - + - + From d28921ceb10c4ebb8021bc50defbe06190e1bb3f Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 22:10:03 +0800 Subject: [PATCH 05/14] Modify observableList in TaskList --- src/main/java/seedu/address/model/TaskList.java | 6 +++--- .../seedu/address/logic/commands/AddCommandTest.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/model/TaskList.java b/src/main/java/seedu/address/model/TaskList.java index b0cbfa9165b..34c9543a0fe 100644 --- a/src/main/java/seedu/address/model/TaskList.java +++ b/src/main/java/seedu/address/model/TaskList.java @@ -14,14 +14,14 @@ */ public class TaskList { private ArrayList taskList; - private ObservableList observableList; + private ObservableList observableList = FXCollections.observableArrayList(); /** * Constructor of the class. */ public TaskList() { taskList = new ArrayList<>(); - observableList = FXCollections.observableArrayList(taskList); + //observableList = FXCollections.observableArrayList(taskList); } /** @@ -34,7 +34,7 @@ public TaskList(TaskList toBeCopied) { } public void setTaskList(TaskList tasks) { - observableList.addAll((Collection) tasks); + observableList.setAll(tasks.observableList); taskList = new ArrayList<>(tasks.getSerializeTaskList()); } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 3c434949b11..1a2aedc67cc 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -197,6 +197,16 @@ public boolean hasTask(Task task) { throw new AssertionError("This method should not be called."); } + @Override + public ObservableList getFilteredTaskList() { + throw new AssertionError("This method should not be called."); + } + + @Override + public void updateFilteredTaskList(Predicate predicate) { + throw new AssertionError("This method should not be called."); + } + @Override public ObservableList getFilteredPersonList() { throw new AssertionError("This method should not be called."); From ed24a0693635adddcc613cb71a0d5b764495f382 Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 22:12:15 +0800 Subject: [PATCH 06/14] Remove unused imports --- src/main/java/seedu/address/model/TaskList.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/seedu/address/model/TaskList.java b/src/main/java/seedu/address/model/TaskList.java index 34c9543a0fe..76713a2269e 100644 --- a/src/main/java/seedu/address/model/TaskList.java +++ b/src/main/java/seedu/address/model/TaskList.java @@ -3,7 +3,6 @@ import static java.util.Objects.requireNonNull; import java.util.ArrayList; -import java.util.Collection; import javafx.collections.FXCollections; import javafx.collections.ObservableList; From 02ed05c31e28d8dd14400556c42333759ff32097 Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 22:29:14 +0800 Subject: [PATCH 07/14] Write tests for filteredTaskLists and ListCommandTask --- .../java/seedu/address/ui/MainWindow.java | 1 - .../seedu/address/logic/LogicManagerTest.java | 5 +++ .../logic/commands/ListTaskCommandTest.java | 40 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index ecb69d9a635..240f6c8cac1 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -113,7 +113,6 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { * Fills up all the placeholders of this window. */ void fillInnerParts() { - taskListPanel = new TaskListPanel(logic.getFilteredTaskList()); taskListPanelPlaceholder.getChildren().add(taskListPanel.getRoot()); diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index 508344227ed..d726d85ede9 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -91,6 +91,11 @@ public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredPersonList().remove(0)); } + @Test + public void getFilteredTaskList_modifyList_throwsUnsupportedOperationException() { + assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredTaskList().remove(0)); + } + /** * Executes the command and confirms that * - no exceptions are thrown
diff --git a/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java b/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java new file mode 100644 index 00000000000..b1511673fb8 --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java @@ -0,0 +1,40 @@ +package seedu.address.logic.commands; + +import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST; +import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.TaskList; +import seedu.address.model.UserPrefs; + +/** + * Contains integration tests (interaction with the Model) and unit tests for ListCommand. + */ +public class ListTaskCommandTest { + + private Model model; + private Model expectedModel; + + @BeforeEach + public void setUp() { + model = new ModelManager(getTypicalAddressBook(), new TaskList(), new UserPrefs()); + expectedModel = new ModelManager(model.getAddressBook(), new TaskList(), new UserPrefs()); + } + + @Test + public void execute_listIsNotFiltered_showsSameList() { + assertCommandSuccess(new ListTaskCommand(), model, ListTaskCommand.MESSAGE_SUCCESS, expectedModel); + } + + @Test + public void execute_listIsFiltered_showsEverything() { + showPersonAtIndex(model, INDEX_FIRST); + assertCommandSuccess(new ListTaskCommand(), model, ListTaskCommand.MESSAGE_SUCCESS, expectedModel); + } +} From 5c40429e993bacd6fa600420ac37faf86f9a605d Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 22:39:02 +0800 Subject: [PATCH 08/14] Remove test for filtered lists --- .../seedu/address/logic/commands/ListTaskCommandTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java b/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java index b1511673fb8..947ad58bf25 100644 --- a/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java @@ -32,9 +32,12 @@ public void execute_listIsNotFiltered_showsSameList() { assertCommandSuccess(new ListTaskCommand(), model, ListTaskCommand.MESSAGE_SUCCESS, expectedModel); } + /* Test for find method */ + /* @Test public void execute_listIsFiltered_showsEverything() { showPersonAtIndex(model, INDEX_FIRST); - assertCommandSuccess(new ListTaskCommand(), model, ListTaskCommand.MESSAGE_SUCCESS, expectedModel); + assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); } + */ } From 0440c540f1db1f6d564726b6df9a3acf6aadd1be Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 22:43:07 +0800 Subject: [PATCH 09/14] Remove unused imports --- .../java/seedu/address/logic/commands/ListTaskCommandTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java b/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java index 947ad58bf25..a723830632c 100644 --- a/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListTaskCommandTest.java @@ -1,8 +1,6 @@ package seedu.address.logic.commands; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST; import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; import org.junit.jupiter.api.BeforeEach; From 2d159919dd17ea6e7e1b159c89b0739f3bc8093e Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:09:09 +0800 Subject: [PATCH 10/14] Write tests for AddressBookParser --- .../java/seedu/address/ui/TaskListPanel.java | 2 +- .../logic/parser/AddressBookParserTest.java | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/seedu/address/ui/TaskListPanel.java b/src/main/java/seedu/address/ui/TaskListPanel.java index a32c710456a..e8c6d35f94a 100644 --- a/src/main/java/seedu/address/ui/TaskListPanel.java +++ b/src/main/java/seedu/address/ui/TaskListPanel.java @@ -15,7 +15,7 @@ */ public class TaskListPanel extends UiPart { private static final String FXML = "TaskListPanel.fxml"; - private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); + private final Logger logger = LogsCenter.getLogger(TaskListPanel.class); @FXML private ListView taskListView; diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 9112b0066a4..350412f4924 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -15,17 +15,8 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.AddCommand; -import seedu.address.logic.commands.AddTaskCommand; -import seedu.address.logic.commands.AssignCommand; -import seedu.address.logic.commands.ClearCommand; -import seedu.address.logic.commands.DeleteCommand; -import seedu.address.logic.commands.EditCommand; +import seedu.address.logic.commands.*; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.logic.commands.ExitCommand; -import seedu.address.logic.commands.FindCommand; -import seedu.address.logic.commands.HelpCommand; -import seedu.address.logic.commands.ListCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.NameContainsKeywordsPredicate; import seedu.address.model.person.Person; @@ -108,6 +99,12 @@ public void parseCommand_list() throws Exception { assertTrue(parser.parseCommand(ListCommand.COMMAND_WORD + " 3") instanceof ListCommand); } + @Test + public void parseCommand_listTask() throws Exception { + assertTrue(parser.parseCommand(ListTaskCommand.COMMAND_WORD) instanceof ListTaskCommand); + assertTrue(parser.parseCommand(ListTaskCommand.COMMAND_WORD + " 3") instanceof ListTaskCommand); + } + @Test public void parseCommand_unrecognisedInput_throwsParseException() { assertThrows(ParseException.class, String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE), () From 44b4cde699d48a864d14f9a7bd36f34427f2ee5e Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:15:46 +0800 Subject: [PATCH 11/14] Fix imports --- .../address/logic/parser/AddressBookParserTest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 350412f4924..b2ead920744 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -15,8 +15,18 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.*; +import seedu.address.logic.commands.AddCommand; +import seedu.address.logic.commands.AddTaskCommand; +import seedu.address.logic.commands.AssignCommand; +import seedu.address.logic.commands.ClearCommand; +import seedu.address.logic.commands.DeleteCommand; +import seedu.address.logic.commands.EditCommand; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.ExitCommand; +import seedu.address.logic.commands.FindCommand; +import seedu.address.logic.commands.HelpCommand; +import seedu.address.logic.commands.ListCommand; +import seedu.address.logic.commands.ListTaskCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.NameContainsKeywordsPredicate; import seedu.address.model.person.Person; From df7a966eeb51daf3820ac8d0038cf474cf70fdca Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:37:01 +0800 Subject: [PATCH 12/14] Update test for ModelManager --- src/test/java/seedu/address/model/ModelManagerTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index c5549b6acb1..d23c8671486 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -149,6 +149,9 @@ public void equals() { // different addressBook -> returns false assertFalse(modelManager.equals(new ModelManager(differentAddressBook, taskList, userPrefs))); + // different taskList -> returns false + assertFalse(modelManager.equals(new ModelManager(addressBook, differentTaskList, userPrefs))); + // different filteredList -> returns false String[] keywords = ALICE.getName().fullName.split("\\s+"); modelManager.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); From f72129d694e353441d6a42ded2606247636d2eb9 Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:42:34 +0800 Subject: [PATCH 13/14] Remove equals check for filteredTaskList --- src/main/java/seedu/address/model/ModelManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index b977f9a6d8b..f30af7e5f6f 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -213,8 +213,7 @@ public boolean equals(Object other) { return addressBook.equals(otherModelManager.addressBook) && taskList.equals(otherModelManager.taskList) && userPrefs.equals(otherModelManager.userPrefs) - && filteredPersons.equals(otherModelManager.filteredPersons) - && filteredTasks.equals(otherModelManager.filteredTasks); + && filteredPersons.equals(otherModelManager.filteredPersons); } } From 3506b125df120bfd538115e564128320fb3e5e2c Mon Sep 17 00:00:00 2001 From: Abdul Khaliq <48424170+breezetall@users.noreply.github.com> Date: Wed, 20 Mar 2024 23:04:58 +0800 Subject: [PATCH 14/14] Fix javaDocs --- src/main/java/seedu/address/model/Model.java | 2 +- src/main/java/seedu/address/model/ModelManager.java | 2 +- src/main/java/seedu/address/model/TaskList.java | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 03743f47713..13a6bdaaf3c 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -112,7 +112,7 @@ static void setTaskList(TaskList taskList) {} boolean hasTask(Task task); /** - * Updates the filter of the filtered person list to filter by the given {@code predicate}. + * Updates the filter of the filtered task list to filter by the given {@code predicate}. * @throws NullPointerException if {@code predicate} is null. */ void updateFilteredTaskList(Predicate predicate); diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index f30af7e5f6f..78ff9ec3d5b 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -167,7 +167,7 @@ public TaskList getTaskList() { } /** - * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of + * Returns an unmodifiable view of the list of {@code Task} backed by the internal list of * {@code versionedAddressBook} */ @Override diff --git a/src/main/java/seedu/address/model/TaskList.java b/src/main/java/seedu/address/model/TaskList.java index 76713a2269e..95385796cca 100644 --- a/src/main/java/seedu/address/model/TaskList.java +++ b/src/main/java/seedu/address/model/TaskList.java @@ -20,7 +20,6 @@ public class TaskList { */ public TaskList() { taskList = new ArrayList<>(); - //observableList = FXCollections.observableArrayList(taskList); } /**