package de.thdeg.grademanager.gui; import de.thdeg.grademanager.model.Course; import de.thdeg.grademanager.model.CoursesOfStudy; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.ListView; import javafx.scene.control.TextField; import java.io.IOException; public class CoursesOfStudyDetailsController { @FXML protected TextField name; @FXML protected TextField duration; @FXML protected TextField fieldOfStudy; @FXML protected TextField fees; @FXML protected ListView<Course> courseListView; static public ObservableList<Course> courseList = FXCollections.observableArrayList(); private static CoursesOfStudy coursesOfStudy; public static void setCourse(CoursesOfStudy value) { CoursesOfStudyDetailsController.coursesOfStudy = value; } @FXML protected void initialize() { if (coursesOfStudy != null){ name.setText(coursesOfStudy.getName()); duration.setText(Integer.toString(coursesOfStudy.getDuration())); fieldOfStudy.setText(coursesOfStudy.getFieldOfStudy()); fees.setText(Integer.toString(coursesOfStudy.getFees())); courseList.setAll(coursesOfStudy.getCourses()); if (!courseList.isEmpty()) { courseListView.setItems(courseList); } } } @FXML protected void switchToMain(ActionEvent event) throws IOException { SwitchWindowHelper.switchTo("Main", event); } @FXML protected void switchToCourseModification(ActionEvent event) throws IOException { CourseModificationController.setCoursesOfStudy(coursesOfStudy); SwitchWindowHelper.switchTo("Course Modification", event); } }