Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package nl.tudelft.oopp.demo.controllers;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.math.BigDecimal;
- import javafx.event.ActionEvent;
- import javafx.fxml.FXML;
- import javafx.fxml.FXMLLoader;
- import javafx.scene.Node;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.scene.control.Alert;
- import javafx.scene.control.MenuButton;
- import javafx.scene.control.Spinner;
- import javafx.scene.control.SpinnerValueFactory;
- import javafx.scene.control.TextField;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- import nl.tudelft.oopp.demo.communication.ServerCommunicationMerchandiseStore;
- import nl.tudelft.oopp.demo.usersession.UserSession;
- public class ManageMerchandiseController {
- @FXML private MenuButton adminManageButton;
- @FXML private TextField productName;
- @FXML private TextField imageUrl;
- @FXML private Text welcomeText;
- @FXML private Spinner<Double> merchandisePrice;
- @FXML private ImageView imageUrlPreview;
- /**
- * The initialize method appends the welcome text depending on the name of the
- * user and initializes the price spinner and the image URL preview.
- */
- public void initialize() {
- welcomeText.setText("Welcome " + UserSession.getInstance().getFullName());
- SpinnerValueFactory<Double> capacityValueFactory = new SpinnerValueFactory
- .DoubleSpinnerValueFactory(0.00, Double.MAX_VALUE, 0.00, 0.10);
- this.merchandisePrice.setValueFactory(capacityValueFactory);
- merchandisePrice.setEditable(true);
- try {
- imageUrlPreview.setImage(new Image(new FileInputStream(
- "client/src/main/resources/tud.jpg")));
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- /**When the add button is pressed, the method performs checks on the input field. If
- * everything conforms, the merchandise item is sent to the server.
- *
- */
- public void addButtonClicked() {
- Alert alert = new Alert(Alert.AlertType.INFORMATION);
- if (productName.getText().isEmpty() || productName.getText().length() == 0) {
- alert.setHeaderText(null);
- alert.setContentText("Please enter the name of the product in the given field.");
- alert.showAndWait();
- return;
- }
- if (BigDecimal.valueOf(merchandisePrice.getValue()).scale() > 2) {
- alert.setHeaderText(null);
- alert.setContentText("Please only enter maximum of 2 decimal points in price");
- alert.showAndWait();
- return;
- }
- String nameOfMerchandise = productName.getText().replace(" ", "%20");
- if (!ServerCommunicationMerchandiseStore.checkName(nameOfMerchandise)) {
- alert.setHeaderText(null);
- alert.setContentText("A product with the entered name already exists");
- alert.showAndWait();
- return;
- }
- String productNameString = productName.getText().replace(" ", "%20");
- String imageUrlString = imageUrl.getText().toString().replace(" ", "%20");
- ServerCommunicationMerchandiseStore.addMerchandise(merchandisePrice.getValue(),
- productNameString, imageUrlString);
- alert.setHeaderText(null);
- alert.setContentText("Merchandise item has been added successfully!");
- alert.showAndWait();
- productName.setText("");
- imageUrl.setText("");
- merchandisePrice.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(
- 0.00, Double.MAX_VALUE, 0.00, 0.10));
- }
- /**Display the image corresponding to the URL provided by the user.
- *
- * @param event which receives the I/O event.
- */
- public void previewImageClicked(ActionEvent event) {
- Alert alert = new Alert(Alert.AlertType.INFORMATION);
- if (imageUrl.getText().isEmpty() || imageUrl.getText().length() == 0) {
- alert.setHeaderText(null);
- alert.setContentText("Please enter the URL of the image to preview it.");
- alert.showAndWait();
- return;
- }
- try {
- imageUrlPreview.setImage(new Image(imageUrl.getText().toString()));
- } catch (IllegalArgumentException e) {
- try {
- imageUrlPreview.setImage(new Image(new FileInputStream(
- "client/src/main/resources/tud.jpg")));
- } catch (FileNotFoundException ex) {
- ex.printStackTrace();
- }
- alert.setHeaderText(null);
- alert.setContentText("The URL you entered is not valid");
- alert.showAndWait();
- return;
- }
- }
- /**
- * Changes scene to the loginScreen when the button is clicked. The user-session gets cleared.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void logOutClicked(ActionEvent event) throws IOException {
- UserSession.getInstance().cleanUserSession();
- Parent parent = FXMLLoader.load(getClass().getResource("/loginScreen.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the manage buildings page once the respective button has been clicked.
- * @throws IOException when load is unsuccessful.
- */
- public void manageBuildingClicked() throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/manageBuildings.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the manage rooms page once the respective button has been clicked.
- * @throws IOException when load is unsuccessful.
- */
- public void manageRoomsClicked() throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/manageRooms.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the create admin page once the respective button has been clicked.
- * @throws IOException when load is unsuccessful.
- */
- public void createAdminClicked() throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/createAdmin.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the manage food items page once the respective button has been clicked.
- * @throws IOException when load is unsuccessful.
- */
- public void manageFoodClicked() throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/manageFoodItems.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the home page once the respective button has been clicked.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void homeButtonClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/homeScreen.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the reserve a room page once the respective button has been clicked.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void reserveRoomClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/roomReservation.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the food order page once the respective button has been clicked.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void foodOrderClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/foodOrder.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the rent a bike page once the respective button has been clicked.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void bikeReservationClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/bikeReservation.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the FAQ page once the respective button has been clicked.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void faqClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/FAQ.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the merchandise store page once the respective button has been clicked.
- *
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void merchandiseStoreClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/MerchandiseStore.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the delete food item page once the respective button has been clicked.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void deleteFoodClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/deleteFoodItem.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the manage merchandise page once the respective button has been clicked.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void manageMerchandiseClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/manageMerchandise.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the delete merchandise page once the respective button has been clicked.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void deleteMerchandiseClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/deleteMerchandise.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- package nl.tudelft.oopp.demo.controllers;
- import com.google.gson.Gson;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.text.DecimalFormat;
- import java.time.LocalDate;
- import java.time.format.DateTimeFormatter;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
- import javafx.event.ActionEvent;
- import javafx.fxml.FXML;
- import javafx.fxml.FXMLLoader;
- import javafx.scene.Node;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.scene.control.Alert;
- import javafx.scene.control.ChoiceBox;
- import javafx.scene.control.Label;
- import javafx.scene.control.ListCell;
- import javafx.scene.control.ListView;
- import javafx.scene.control.MenuButton;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import javafx.scene.layout.Region;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- import nl.tudelft.oopp.demo.communication.ServerCommunicationMerchandiseStore;
- import nl.tudelft.oopp.demo.entities.Merchandise;
- import nl.tudelft.oopp.demo.usersession.UserSession;
- public class MerchandiseStoreController {
- @FXML
- private MenuButton adminManageButton;
- @FXML
- private ListView listViewMerchandise;
- @FXML
- private ListView listViewBasket;
- @FXML
- private Label totalPriceDisplay;
- @FXML
- private Text welcomeText;
- @FXML
- private ChoiceBox selectSortBy;
- @FXML
- private ArrayList<String> sortByList;
- private ArrayList<Merchandise> merchandiseBasket;
- private ArrayList<Merchandise> merchandiseOrderedList;
- private double totalPrice = 0.00;
- /**Constructor for the MerchandiseStoreController class.
- *
- */
- public MerchandiseStoreController() {
- this.sortByList = new ArrayList<>();
- this.merchandiseOrderedList = new ArrayList<>();
- this.merchandiseBasket = new ArrayList<>();
- this.totalPriceDisplay = new Label();
- }
- /**
- * Initialize method gets executed before the page has been loaded. It retrieves and loads
- * the names of the merchandise items.
- */
- public void initialize() {
- if (!UserSession.getInstance().getRole().equals("Admin")) {
- adminManageButton.setDisable(true);
- adminManageButton.setVisible(false);
- }
- welcomeText.setText("Welcome " + UserSession.getInstance().getFullName());
- ObservableList<String> tempList = FXCollections.observableArrayList();
- String regex = "\\{([^}]+)}";
- Pattern pattern = Pattern.compile(regex);
- Matcher matcher = pattern.matcher(ServerCommunicationMerchandiseStore
- .getMerchandiseOrderByName());
- Gson gson = new Gson();
- while (matcher.find()) {
- tempList.add(matcher.group());
- }
- ObservableList<String> res = FXCollections.observableArrayList();
- for (String jsonBuilding : tempList) {
- Merchandise merchandise = gson.fromJson(jsonBuilding, Merchandise.class);
- merchandiseOrderedList.add(merchandise);
- res.add(merchandise.toString());
- }
- listViewMerchandise.setMinHeight(60);
- listViewMerchandise.setItems(res);
- listViewMerchandise.setCellFactory(param -> new ListCell<String>() {
- @Override
- public void updateItem(String text, boolean empty) {
- super.updateItem(text, empty);
- if (empty) {
- setText(null);
- setGraphic(null);
- return;
- }
- ImageView picture = new ImageView();
- picture.setSmooth(true);
- picture.setPreserveRatio(true);
- picture.resize(75, 75);
- picture.setFitHeight(75);
- picture.setFitWidth(75);
- Merchandise merchandise = Merchandise
- .findMerchandiseInList(merchandiseOrderedList, text);
- setText(text);
- if (merchandise.hasImage()) {
- try {
- picture.setImage(new Image(merchandise.getImage()));
- setGraphic(picture);
- } catch (IllegalArgumentException e) {
- try {
- picture.setImage(new Image(new FileInputStream(
- "client/src/main/resources/tud.jpg")));
- setGraphic(picture);
- } catch (FileNotFoundException e2) {
- setGraphic(null);
- }
- }
- }
- }
- });
- }
- /**Sorts the list of merchandise items according to the selected sorting
- * parameter.
- *
- * @param actionEvent which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void sortBySelected(ActionEvent actionEvent) throws IOException {
- ObservableList<String> tempList = FXCollections.observableArrayList();
- String regex = "\\{([^}]+)}";
- Pattern pattern1 = Pattern.compile(regex);
- String selectedSortBy = selectSortBy.getValue().toString();
- Matcher matcher;
- if (selectedSortBy.equals("Name")) {
- matcher = pattern1.matcher(ServerCommunicationMerchandiseStore
- .getMerchandiseOrderByName());
- } else if (selectedSortBy.equals("Price (asc)")) {
- matcher = pattern1.matcher(ServerCommunicationMerchandiseStore
- .getMerchandiseOrderByPriceLowToHigh());
- } else if (selectedSortBy.equals("Price (desc)")) {
- matcher = pattern1.matcher(ServerCommunicationMerchandiseStore
- .getMerchandiseOrderByPriceHighToLow());
- } else {
- throw new IllegalArgumentException("Sort by parameter error");
- }
- Gson gson = new Gson();
- while (matcher.find()) {
- tempList.add(matcher.group());
- }
- ObservableList<String> res = FXCollections.observableArrayList();
- merchandiseOrderedList.clear();
- for (String jsonBuilding : tempList) {
- Merchandise merchandise = gson.fromJson(jsonBuilding, Merchandise.class);
- merchandiseOrderedList.add(merchandise);
- res.add(merchandise.toString());
- }
- listViewMerchandise.setItems(res);
- }
- /**When the add button us clicked, the selected merchandise item is added to the basket.
- *
- * @param actionEvent which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void addMerchandiseClicked(ActionEvent actionEvent) throws IOException {
- if (listViewMerchandise.getSelectionModel().getSelectedItems() != null) {
- Merchandise merchandise = Merchandise.findMerchandiseInList(merchandiseOrderedList,
- (String) listViewMerchandise.getSelectionModel().getSelectedItems().get(0));
- merchandiseBasket.add(merchandise);
- updateBasketDisplay(merchandiseBasket, listViewBasket);
- updateTotalPrice(merchandiseBasket);
- } else {
- Alert alert = new Alert(Alert.AlertType.INFORMATION);
- alert.setHeaderText(null);
- alert.setContentText("Please select an item to add to your basket");
- alert.showAndWait();
- }
- }
- /**When the delete button us clicked, the selected merchandise item is removed from the basket.
- *
- * @param actionEvent which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void deleteMerchandiseClicked(ActionEvent actionEvent) throws IOException {
- if (listViewMerchandise.getSelectionModel().getSelectedItems() != null) {
- Merchandise merchandise = Merchandise.findMerchandiseInList(merchandiseOrderedList,
- (String) listViewMerchandise.getSelectionModel().getSelectedItems().get(0));
- merchandiseBasket.remove(merchandise);
- updateBasketDisplay(merchandiseBasket, listViewBasket);
- updateTotalPrice(merchandiseBasket);
- } else {
- Alert alert = new Alert(Alert.AlertType.INFORMATION);
- alert.setHeaderText(null);
- alert.setContentText("Please select an item to delete from your basket");
- alert.showAndWait();
- }
- }
- /**Updates the total price displayed on screen by recalculating the
- * total cost of all merchandise items in the basket.
- *
- * @param merchandiseBasket ArrayList containing the merchandise items inside of the basket
- */
- public void updateTotalPrice(ArrayList<Merchandise> merchandiseBasket) {
- DecimalFormat decimalFormat = new DecimalFormat("0.00");
- totalPrice = 0;
- for (Merchandise m : this.merchandiseBasket) {
- totalPrice = totalPrice + m.getPrice();
- }
- totalPriceDisplay.setText(decimalFormat.format(totalPrice) + " euro");
- }
- /**Updates the merchandise items displayed on screen.This method is called after
- * a merchandise item has benn added/deleted from the basket.
- *
- * @param merchandiseBasket ArrayList containing the merchandise items inside of the basket
- * @param listViewBasket ArrayList containing the merchandise items inside of the basket
- * displayed on screen
- */
- public void updateBasketDisplay(ArrayList<Merchandise> merchandiseBasket,
- ListView listViewBasket) {
- ObservableList<String> res = FXCollections.observableArrayList();
- ArrayList<Merchandise> occurrences = new ArrayList<>();
- for (Merchandise m : this.merchandiseBasket) {
- if (!occurrences.contains(m)) {
- res.remove(m);
- res.add(m.toStringQuantity(Collections.frequency(this.merchandiseBasket, m)));
- }
- occurrences.add(m);
- }
- this.listViewBasket.setItems(res);
- }
- /**When the "place order" button is pressed, this method first perform checks to verify
- * that all fields are provided. Then, merchandiseOrder objects are generated according
- * to the merchandise items in the basket.
- *
- * @param actionEvent event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void placeOrder(ActionEvent actionEvent) throws IOException {
- Alert alert = new Alert(Alert.AlertType.INFORMATION);
- if (merchandiseBasket.isEmpty()) {
- alert.setHeaderText(null);
- alert.setContentText("Please add items to your basket before placing your order");
- alert.showAndWait();
- return;
- }
- saveOrders(merchandiseBasket);
- Parent parent = FXMLLoader.load(getClass().getResource("/MerchandiseStore.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**Performs checks on the current time and date and then generates merchandise orders
- * with the merchandise items in the basket.
- *
- * @param merchandiseBasket ArrayList containing the merchandise items inside of the basket
- */
- public void saveOrders(ArrayList<Merchandise> merchandiseBasket) {
- LocalDate orderDate = LocalDate.now();
- DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- String date = dateFormat.format(orderDate);
- ArrayList<Merchandise> occurrences = new ArrayList<>();
- for (Merchandise m : merchandiseBasket) {
- if (!occurrences.contains(m)) {
- ServerCommunicationMerchandiseStore.addMerchandiseOrder(
- m.getId(), UserSession.getInstance().getId(),
- Collections.frequency(merchandiseBasket, m),
- date);
- occurrences.add(m);
- }
- }
- Alert alert = new Alert(Alert.AlertType.INFORMATION);
- alert.setHeaderText(null);
- alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
- alert.setContentText("Your order has been placed successfully. The TU Delft "
- + "gift shop will soon contact you to verify the availability of your "
- + "ordered products and arrange a pick-up date");
- alert.showAndWait();
- }
- /**
- * Changes scene to the loginScreen when the button is clicked. The user-session gets cleared.
- *
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void logOutClicked(ActionEvent event) throws IOException {
- UserSession.getInstance().cleanUserSession();
- Parent parent = FXMLLoader.load(getClass().getResource("/loginScreen.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the manage buildings page once the respective button has been clicked.
- *
- * @throws IOException when load is unsuccessful.
- */
- public void manageBuildingClicked() throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/manageBuildings.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the manage rooms page once the respective button has been clicked.
- *
- * @throws IOException when load is unsuccessful.
- */
- public void manageRoomsClicked() throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/manageRooms.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the create admin page once the respective button has been clicked.
- *
- * @throws IOException when load is unsuccessful.
- */
- public void createAdminClicked() throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/createAdmin.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the manage food items page once the respective button has been clicked.
- *
- * @throws IOException when load is unsuccessful.
- */
- public void manageFoodClicked() throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/manageFoodItems.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the home page once the respective button has been clicked.
- *
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void homeButtonClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/homeScreen.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the reserve a room page once the respective button has been clicked.
- *
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void reserveRoomClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/roomReservation.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the food order page once the respective button has been clicked.
- *
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void foodOrderClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/foodOrder.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the rent a bike page once the respective button has been clicked.
- *
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void bikeReservationClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/bikeReservation.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the FAQ page once the respective button has been clicked.
- *
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void faqClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/FAQ.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the merchandise store page once the respective button has been clicked.
- *
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void merchandiseStoreClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/MerchandiseStore.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) (((Node) event.getSource()).getScene().getWindow());
- window.setScene(newScene);
- window.show();
- }
- /**
- * Changes scene to the manage merchandise page once the respective button has been clicked.
- * @param event which receives the I/O event.
- * @throws IOException when load is unsuccessful.
- */
- public void manageMerchandiseClicked(ActionEvent event) throws IOException {
- Parent parent = FXMLLoader.load(getClass().getResource("/manageMerchandise.fxml"));
- Scene newScene = new Scene(parent);
- Stage window = (Stage) adminManageButton.getScene().getWindow();
- window.setScene(newScene);
- window.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement