From 3bef6a6bf66477413e833d0b2e0a1d39b1048f35 Mon Sep 17 00:00:00 2001 From: Wen Jin Date: Thu, 8 Oct 2020 10:32:31 +0800 Subject: [PATCH] Fix bug for view lesson command --- .../seedu/address/logic/commands/ViewLsnCommand.java | 1 + .../address/logic/parser/ViewLsnCommandParser.java | 1 + src/main/java/seedu/address/model/ModelManager.java | 10 +++++----- src/main/java/seedu/address/model/group/Group.java | 3 ++- src/main/java/seedu/address/model/group/Lesson.java | 5 +++++ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/ViewLsnCommand.java b/src/main/java/seedu/address/logic/commands/ViewLsnCommand.java index c6540ecad56..136bcc875b1 100644 --- a/src/main/java/seedu/address/logic/commands/ViewLsnCommand.java +++ b/src/main/java/seedu/address/logic/commands/ViewLsnCommand.java @@ -46,6 +46,7 @@ private String getMessage(Model model) { @Override public CommandResult execute(Model model) { requireNonNull(model); + model.updateFilteredGroupList(grpPredicate); model.updateFilteredLessonList(lsnPredicate); return new CommandResult(this.getMessage(model)); } diff --git a/src/main/java/seedu/address/logic/parser/ViewLsnCommandParser.java b/src/main/java/seedu/address/logic/parser/ViewLsnCommandParser.java index ef5ae880130..9e351cd72fd 100644 --- a/src/main/java/seedu/address/logic/parser/ViewLsnCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/ViewLsnCommandParser.java @@ -43,4 +43,5 @@ public ViewLsnCommand parse(String args) throws ParseException { private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); } + } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 9ebdd653da0..153e663247d 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -58,7 +58,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs filteredGroups = new FilteredList<>(this.serenity.getGroupList()); students = new ArrayObservableList<>(new UniqueStudentList().asUnmodifiableObservableList()); lessons = new ArrayObservableList<>(new UniqueLessonList().asUnmodifiableObservableList()); - filteredLessons = new FilteredList<>(new UniqueLessonList().asUnmodifiableObservableList()); + filteredLessons = new FilteredList<>(lessons); studentsInfo = new ArrayObservableList<>(new UniqueStudentInfoList().asUnmodifiableObservableList()); } @@ -79,7 +79,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs filteredGroups = new FilteredList<>(this.serenity.getGroupList()); students = new ArrayObservableList<>(new UniqueStudentList().asUnmodifiableObservableList()); lessons = new ArrayObservableList<>(new UniqueLessonList().asUnmodifiableObservableList()); - filteredLessons = new FilteredList<>(new UniqueLessonList().asUnmodifiableObservableList()); + filteredLessons = new FilteredList<>(lessons); studentsInfo = new ArrayObservableList<>(new UniqueStudentInfoList().asUnmodifiableObservableList()); } @@ -223,8 +223,8 @@ public void updateFilteredLessonList(Predicate predicate) { @Override public void updateStudentInfoList() { - if (!filteredGroups.isEmpty() || !lessons.isEmpty()) { - this.studentsInfo.setAll(this.lessons.get(0).getStudentsInfoAsUnmodifiableObservableList()); + if (!filteredGroups.isEmpty() || !filteredLessons.isEmpty()) { + this.studentsInfo.setAll(this.filteredLessons.get(0).getStudentsInfoAsUnmodifiableObservableList()); } } @@ -245,7 +245,7 @@ public ObservableList getLessonList() { @Override public ObservableList getFilteredLessonList() { - return lessons; + return filteredLessons; } @Override diff --git a/src/main/java/seedu/address/model/group/Group.java b/src/main/java/seedu/address/model/group/Group.java index 9a25d039a34..3fa66dd376e 100644 --- a/src/main/java/seedu/address/model/group/Group.java +++ b/src/main/java/seedu/address/model/group/Group.java @@ -143,6 +143,7 @@ public int hashCode() { @Override public String toString() { - return name + "," + students.toString(); + return String.format("Group %s", name); } + } diff --git a/src/main/java/seedu/address/model/group/Lesson.java b/src/main/java/seedu/address/model/group/Lesson.java index d283b3b851b..06e37fb2314 100644 --- a/src/main/java/seedu/address/model/group/Lesson.java +++ b/src/main/java/seedu/address/model/group/Lesson.java @@ -64,5 +64,10 @@ public boolean equals(Object obj) { return otherClass.getName().equals(getName()) && otherClass.getStudentsInfo().equals(getStudentsInfo()); } + + @Override + public String toString() { + return String.format("Lesson %s", name); + } }