Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change MainWindow to update student and schedule list after each command #66

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public interface Logic {

/** Returns an unmodifiable view of the filtered list of students */
ObservableList<Student> getFilteredStudentList();

/**
* Returns the user prefs' address book file path.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@
}

private String generateSuccessMessage(Student editedStudent) {
return String.format(MESSAGE_ADD_LESSON_SUCCESS, editedStudent);
return String.format(MESSAGE_ADD_LESSON_SUCCESS, Messages.format(editedStudent));

Check warning on line 82 in src/main/java/seedu/address/logic/commands/AddLessonCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/AddLessonCommand.java#L82

Added line #L82 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
LocalTime timeDetail = LocalTime.parse(lessonDetails[1], TIME_FORMATTER);
int isCompleted;
if (lessonDetails.length == 3) {
isCompleted = Integer.parseInt(lessonDetails[3]);
isCompleted = Integer.parseInt(lessonDetails[2]);

Check warning on line 51 in src/main/java/seedu/address/logic/parser/AddLessonCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/AddLessonCommandParser.java#L51

Added line #L51 was not covered by tests
return new AddLessonCommand(index, dateDetail, timeDetail, isCompleted);
} else {
return new AddLessonCommand(index, dateDetail, timeDetail);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.function.Predicate;
import java.util.logging.Logger;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import seedu.address.commons.core.GuiSettings;
Expand Down Expand Up @@ -119,7 +120,7 @@ public void setStudent(Student target, Student editedStudent) {
*/
@Override
public ObservableList<Student> getFilteredStudentList() {
return filteredStudents;
return FXCollections.unmodifiableObservableList(filteredStudents);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/student/Lesson.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ public int hashCode() {
* Format state as text for viewing.
*/
public String toString() {
return this.subject + " " + this.date.toString() + " " + this.time;
return this.subject + " " + this.date.toString() + " " + this.time + " ";
}
}
19 changes: 17 additions & 2 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,21 @@
primaryStage.hide();
}

public StudentListPanel getStudentListPanel() {
return studentListPanel;
/**
* Updates Schedule List Panel.
*/
public void updateScheduleListPanel() {
scheduleListPanelPlaceholder.getChildren().clear();
scheduleListPanel = new ScheduleListPanel(logic.getFilteredStudentList());
scheduleListPanelPlaceholder.getChildren().add(scheduleListPanel.getRoot());
}

Check warning on line 185 in src/main/java/seedu/address/ui/MainWindow.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/MainWindow.java#L182-L185

Added lines #L182 - L185 were not covered by tests
/**
* Updates Student List Panel.
*/
public void updateStudentListPanel() {
studentListPanelPlaceholder.getChildren().clear();
studentListPanel = new StudentListPanel(logic.getFilteredStudentList());
studentListPanelPlaceholder.getChildren().add(studentListPanel.getRoot());

Check warning on line 192 in src/main/java/seedu/address/ui/MainWindow.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/MainWindow.java#L190-L192

Added lines #L190 - L192 were not covered by tests
}

/**
Expand All @@ -197,6 +210,8 @@
if (commandResult.isExit()) {
handleExit();
}
updateStudentListPanel();
updateScheduleListPanel();

Check warning on line 214 in src/main/java/seedu/address/ui/MainWindow.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/MainWindow.java#L213-L214

Added lines #L213 - L214 were not covered by tests

return commandResult;
} catch (CommandException | ParseException e) {
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/seedu/address/ui/ScheduleListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
public class ScheduleListPanel extends UiPart<Region> {
private static final String FXML = "ScheduleListPanel.fxml";
private final Logger logger = LogsCenter.getLogger(ScheduleListPanel.class);
private ObservableList<Student> studentList;

@FXML
private ListView<Pair<Student, Lesson>> scheduleListView;
Expand All @@ -32,8 +33,9 @@
*/
public ScheduleListPanel(ObservableList<Student> studentList) {
super(FXML);
this.studentList = studentList;

Check warning on line 36 in src/main/java/seedu/address/ui/ScheduleListPanel.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/ScheduleListPanel.java#L36

Added line #L36 was not covered by tests

scheduleListView.setItems(transformList(studentList));
scheduleListView.setItems(transformList(this.studentList));

Check warning on line 38 in src/main/java/seedu/address/ui/ScheduleListPanel.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/ScheduleListPanel.java#L38

Added line #L38 was not covered by tests
scheduleListView.setCellFactory(listView -> new ScheduleListViewCell());
}

Expand All @@ -48,7 +50,9 @@
for (Student student : studentList) {
List<Lesson> studentLesson = student.getLessons();
for (Lesson l : studentLesson) {
scheduleList.add(new Pair(student, l));
if (l.getLessonStatus() == 0) {
scheduleList.add(new Pair(student, l));

Check warning on line 54 in src/main/java/seedu/address/ui/ScheduleListPanel.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/ScheduleListPanel.java#L54

Added line #L54 was not covered by tests
}
}
}

Expand Down Expand Up @@ -78,7 +82,6 @@

@Override
public int compare(Pair<Student, Lesson> o1, Pair<Student, Lesson> o2) {
// TODO: implement your logic here
return o1.getValue().getDate().compareTo(o2.getValue().getDate());
}
}
Expand Down
Loading