package view; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import database.*; import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBoxBuilder; import javafx.scene.text.Text; import javafx.stage.Modality; import javafx.stage.Stage; import schedule.NewSchedController; import schedule.ScheduleListView; import schedule.SchedulesListController; /** * FXML Controller class * * @author jmiran03 */ public class MenuBar_Controller implements Initializable { Stage stage; @FXML void aboutAction(ActionEvent event) { Stage dialogStage = new Stage(); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.setScene(new Scene(VBoxBuilder.create(). children(new Text("Welcome to the Scheduler!\n" + "For more information please go to " + "http://users.csc.calpoly.edu/~jmiran03/scheduler."), new Button("Ok.")). alignment(Pos.CENTER).padding( new Insets(5)).build())); dialogStage.show(); } @FXML void buildingsListAction(ActionEvent event) { BuildingsListView blView = new BuildingsListView(); } @FXML void coursesListAction(ActionEvent event) { CourseListView clView = new CourseListView(); } @FXML void instructorsListAction(ActionEvent event) { InstructorListView ilView = new InstructorListView(); } @FXML void roomsListAction(ActionEvent event) { RoomsListView rlView = new RoomsListView(); } @FXML void viewScheduleAction(ActionEvent event) { schedule.AdminViewScheduleView avsView = new schedule.AdminViewScheduleView(); } @FXML void exitAction(ActionEvent event) { Platform.exit(); } @FXML void newScheduleAction(ActionEvent event) { try { Stage stage = new Stage(); final FXMLLoader loader = new FXMLLoader(getClass().getResource("newSched.fxml")); final Parent root = (Parent) loader.load(); final NewSchedController controller = loader.getController(); Scene scene = new Scene(root); controller.setStage(stage); stage.setScene(scene); stage.show(); // Hide the current screen //((Node)(event.getSource())).getScene().getWindow().hide(); } catch (IOException ex) { Logger.getLogger(SchedulesListController.class.getName()).log(Level.SEVERE, null, ex); } } @FXML void scheduleListAction(ActionEvent event) { Stage main = new Stage(); try { FXMLLoader loader = new FXMLLoader(ScheduleListView.class.getResource("schedulesList.fxml")); StackPane page = (StackPane) loader.load(); Scene scene = new Scene(page); SchedulesListController slController = loader.< SchedulesListController>getController(); slController.setStage(main); main.setScene(scene); main.show(); } catch (IOException ex) { System.err.println("Error loading schedulesList.fxml"); ex.printStackTrace(); } } @Override public void initialize(URL url, ResourceBundle rb) { } public void setStage(Stage main) { this.stage = main; } }