package de.thdeg.grademanager.gui; import de.thdeg.grademanager.model.CoursesOfStudy; import de.thdeg.grademanager.model.Student; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.control.ComboBox; import javafx.scene.*; import javafx.scene.Node; import javafx.stage.*; import java.io.IOException; public class MainController { @FXML protected ComboBox<CoursesOfStudy> coursesOfStudyComboBox; @FXML protected ComboBox<Student> studentComboBox; static public ObservableList<CoursesOfStudy> coursesOfStudyList = FXCollections.observableArrayList(); static public ObservableList<Student> studentList = FXCollections.observableArrayList(); @FXML protected void initialize() { if (!coursesOfStudyList.isEmpty()) { coursesOfStudyComboBox.setItems(coursesOfStudyList); } if (!studentList.isEmpty()) { studentComboBox.setItems(studentList); } } private Stage stage; private Scene scene; private FXMLLoader root; @FXML protected void switchToMain(ActionEvent event) throws IOException { root = new FXMLLoader(Main.class.getResource("main.fxml")); stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); scene = new Scene(root.load(), 960, 540); stage.setTitle("Main"); stage.setScene(scene); stage.show(); } @FXML protected void switchToStudentDetails(ActionEvent event) throws IOException { root = new FXMLLoader(Main.class.getResource("student-details.fxml")); stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); scene = new Scene(root.load(), 960, 540); stage.setTitle("Student Details"); stage.setScene(scene); stage.show(); } @FXML protected void switchToStudentModification(ActionEvent event) throws IOException { root = new FXMLLoader(Main.class.getResource("student-modification.fxml")); stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); scene = new Scene(root.load(), 960, 540); stage.setTitle("Student Modification"); stage.setScene(scene); stage.show(); } @FXML protected void switchToCoursesOfStudyDetails(ActionEvent event) throws IOException { root = new FXMLLoader(Main.class.getResource("courses-of-study-details.fxml")); stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); scene = new Scene(root.load(), 960, 540); stage.setTitle("Degree Details"); stage.setScene(scene); stage.show(); } @FXML protected void switchToCoursesOfStudyModification(ActionEvent event) throws IOException { root = new FXMLLoader(Main.class.getResource("courses-of-study-modification.fxml")); stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); scene = new Scene(root.load(), 960, 540); stage.setTitle("CoursesOfStudy Modification"); stage.setScene(scene); stage.show(); } }