Skip to content

Commit

Permalink
Merge pull request #35 from ahmedsiam0/link-scenes
Browse files Browse the repository at this point in the history
Link scenes
  • Loading branch information
ahmedsiam0 authored Dec 21, 2023
2 parents e1e72e4 + 105eaf6 commit e927b21
Show file tree
Hide file tree
Showing 38 changed files with 955 additions and 874 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/covers/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/covers/11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/covers/12.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/covers/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/covers/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/covers/4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 39 additions & 61 deletions src/main/java/com/asu/librarysystem/AdminController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,76 +19,54 @@ public class AdminController {
private Parent adminViewNodes;

@FXML
public void switchToManagingBooks(ActionEvent event)throws IOException {

try {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("CRUDBooks.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();

}catch (Exception e){
System.out.println(e.getMessage());
}

public void switchToManagingBooks(ActionEvent event) throws IOException {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("CRUDBooks.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();
}
@FXML
public void switchToManagingBorrowers(ActionEvent event)throws IOException {

try {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("ManagingBorrowers.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();

}catch (Exception e){
System.out.println(e.getMessage());
}

public void switchToManagingBorrowers(ActionEvent event) throws IOException {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("CRUD_Borrower-view.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();
}
@FXML
public void switchToManagingProfile(ActionEvent event)throws IOException {

try {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("ManagingAdminProfile.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();

}catch (Exception e){
System.out.println(e.getMessage());
}
public void switchToManagingProfile(ActionEvent event) throws IOException {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("managing-profile-view.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();
}
@FXML
public void switchToManagingDiscounts(ActionEvent event)throws IOException {
try {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("ManagingDiscounts.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();

}catch (Exception e){
System.out.println(e.getMessage());
}

public void switchToManagingDiscounts(ActionEvent event) throws IOException {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("discounts-view.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();
}
@FXML
public void switchToManagingOrderHistory(ActionEvent event)throws IOException {
try {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("OrderHistory.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();

}catch (Exception e){
System.out.println(e.getMessage());
}
public void switchToManagingOrderHistory(ActionEvent event) throws IOException {
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("orders-for-admin-view.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();

}
@FXML
void logout(ActionEvent event) throws IOException {
Library.logOut();
adminViewNodes= FXMLLoader.load(MainApplication.class.getResource("Login.fxml"));
adminStage = (Stage)((Node)event.getSource()).getScene().getWindow();
adminScene =new Scene(adminViewNodes);
adminStage.setScene(adminScene);
adminStage.show();
}

}
4 changes: 2 additions & 2 deletions src/main/java/com/asu/librarysystem/AllBooksController.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void backButton(ActionEvent event){
Account account = Library.getActiveAccount();
if (account instanceof Customer) {
Customer customer =(Customer) account;
FXMLLoader loader = new FXMLLoader(getClass().getResource("name of.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("CustomerMain.fxml"));
Parent root = loader.load();
// clsssName objName = loader.getController();
// objName.method;
Expand All @@ -58,7 +58,7 @@ public void backButton(ActionEvent event){
}
else if(account instanceof Borrower){
Borrower borrower =(Borrower) account;
FXMLLoader loader = new FXMLLoader(getClass().getResource("name.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("borrower-main-view.fxml"));
Parent root = loader.load();
// clsssName objName = loader.getController();
// objName.method;
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/com/asu/librarysystem/Book.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ public class Book {
private boolean status;
private int price;
private int quantity;
private String descreption;
private String description;
private File cover;
private ArrayList<Category> categories;




public Book(String title, String author, int publicationYear, boolean status, int price, int quantity
, String descreption, String coverPath, Category[] categories) {
, String description, String coverPath, Category[] categories) {
this.id = ++idCounter;
this.title = title;
this.author = author;
this.publicationYear = publicationYear;
this.status = status;
this.price = price;
this.quantity = quantity;
this.descreption = descreption;
this.description = description;

setCover(coverPath);

Expand Down Expand Up @@ -86,7 +87,11 @@ public void setPrice(int price) {

public boolean isAvailable() { return quantity > 0; }

public String getDescreption() { return descreption; }
public String getDescription() { return description; }
public void setDescription(String description) {
this.description = description;
}


public void setCover(String path) {
File newCover = new File(path);
Expand All @@ -108,9 +113,12 @@ public String getCoverPath() {
return cover.getAbsolutePath();
}

public ArrayList<Category> getCategories(){
public ArrayList<Category> getCategories() {
return this.categories;
}
public void setCategories(ArrayList<Category> categories) {
this.categories = categories;
}


}
36 changes: 29 additions & 7 deletions src/main/java/com/asu/librarysystem/BookController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
Expand Down Expand Up @@ -69,6 +70,9 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
notifyMe.setOnMouseClicked(mouseEvent -> {
Notifications notifications = new Notifications();
notifications.reservationConfirmation(currentBook);
Alert alert = new Alert(AlertType.INFORMATION);
alert.setContentText("You will be notified when book is available.");
alert.show();
});
}

Expand All @@ -78,7 +82,7 @@ public void setScene(Book book) throws IOException {
setCover(book.getCoverPath());

setProperties(book.getTitle(), book.getAuthor(), Integer.toString(book.getPublicationYear())
, book.getDescreption(), book.getPrice(), book.getQuantity());
, book.getDescription(), book.getPrice(), book.getQuantity());

Library.getReviewHandler().addReview(1, book.getId(), 3, "I don't love this book");
ArrayList<Integer> ratings = Library.getReviewHandler().getBookRatings(book.getId());
Expand Down Expand Up @@ -163,7 +167,13 @@ private void setProperties(String name, String author, String releaseDate,String

if (quantity > 0){
try {
InputStream imageLocation = new FileInputStream("data/bookSceneAssets/Status_icons/addToCartButton.png");
InputStream imageLocation;
if (Library.getActiveAccount() instanceof Customer) {
imageLocation = new FileInputStream("data/bookSceneAssets/Status_icons/addToCartButton.png");
} else {
imageLocation = new FileInputStream("data/bookSceneAssets/Status_icons/borrowButton.png");
}

Image available = new Image(imageLocation);

statusImage.setImage(available);
Expand All @@ -182,10 +192,11 @@ private void setProperties(String name, String author, String releaseDate,String
statusImage.setImage(outOfStock);
statusImage.setCursor(Cursor.DEFAULT);
statusImage.setOnMouseClicked(null);

InputStream notifyMeImage = new FileInputStream("data/bookSceneAssets/Status_icons/notifyMeButton.png");
Image notifyMe = new Image(notifyMeImage);
this.notifyMe.setImage(notifyMe);
if (Library.getActiveAccount() instanceof Borrower) {
InputStream notifyMeImage = new FileInputStream("data/bookSceneAssets/Status_icons/notifyMeButton.png");
Image notifyMe = new Image(notifyMeImage);
this.notifyMe.setImage(notifyMe);
}


} catch (FileNotFoundException e) {
Expand All @@ -195,7 +206,18 @@ private void setProperties(String name, String author, String releaseDate,String
}

public void addToCart(MouseEvent e) {
System.out.println("Hello");
if (Library.getActiveAccount() instanceof Customer) {
Library.getShoppingCart().addBook(currentBook.getId());
Alert alert = new Alert(AlertType.INFORMATION);
alert.setContentText("Added to Shopping Cart.");
alert.show();
} else {
Borrower account = (Borrower)Library.getActiveAccount();
account.addTransaction(currentBook);
Alert alert = new Alert(AlertType.INFORMATION);
alert.setContentText("You have borrowed this book successfully!\nEnjoy Reading.");
alert.show();
}
}

private String formatPrice(int price){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.Objects;
import java.util.ResourceBundle;

public class SideBarController implements Initializable {
public class BorrowerMainController implements Initializable {
private Stage primaryStage;
private Scene scene;

Expand Down Expand Up @@ -71,9 +71,9 @@ public class SideBarController implements Initializable {
private Label Transactions;
public void reservationConfirmationNotification()
{
for (int i = 0; i < BorrowerController.getCurrentBorrower().getReservedBooks().size(); i++)
for (int i = 0; i < TransactionsForBorrowersController.getCurrentBorrower().getReservedBooks().size(); i++)
{
Label label = new Label("You Have Successfully reserved \"" + BorrowerController.getCurrentBorrower().getReservedBooks().get(i).getTitle() + "\"");
Label label = new Label("You Have Successfully reserved \"" + TransactionsForBorrowersController.getCurrentBorrower().getReservedBooks().get(i).getTitle() + "\"");
label.setFont(Font.font(30));
label.setTextFill(Color.WHITE);
label.setPrefWidth(1280);
Expand All @@ -89,8 +89,8 @@ public void availableForPickupNotification()
{
Notifications notifications = new Notifications();
if (notifications.availableForPickup()) {
for (int i = 0; i < BorrowerController.getCurrentBorrower().getReservedBooks().size(); i++) {
Label label = new Label("\"" + BorrowerController.getCurrentBorrower().getReservedBooks().get(i).getTitle() + "\"" + " is Available for Pickup");
for (int i = 0; i < TransactionsForBorrowersController.getCurrentBorrower().getReservedBooks().size(); i++) {
Label label = new Label("\"" + TransactionsForBorrowersController.getCurrentBorrower().getReservedBooks().get(i).getTitle() + "\"" + " is Available for Pickup");
label.setFont(Font.font(30));
label.setTextFill(Color.WHITE);
label.setPrefWidth(1280);
Expand Down Expand Up @@ -121,7 +121,7 @@ public void CheckNotifications()
}

for (int i = 0; i < Notifications.booksDueDateIn3Days().size(); i++) {
Label label = new Label("Your Borrowed Book \"" + BorrowerController.getCurrentBorrower().getBorrowerTransactions().get(Notifications.booksDueDateIn3Days().get(i)).getBookName() +"\" is due in " + ChronoUnit.DAYS.between(LocalDate.now(),BorrowerController.getCurrentBorrower().getBorrowerTransactions().get(Notifications.booksDueDateIn3Days().get(i)).getReturnDate())+" days");
Label label = new Label("Your Borrowed Book \"" + TransactionsForBorrowersController.getCurrentBorrower().getBorrowerTransactions().get(Notifications.booksDueDateIn3Days().get(i)).getBookName() +"\" is due in " + ChronoUnit.DAYS.between(LocalDate.now(),TransactionsForBorrowersController.getCurrentBorrower().getBorrowerTransactions().get(Notifications.booksDueDateIn3Days().get(i)).getReturnDate())+" days");
label.setFont(Font.font(30));
label.setTextFill(Color.WHITE);
label.setPrefWidth(1280);
Expand All @@ -134,7 +134,7 @@ public void CheckNotifications()
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
Welcome.setText("Welcome, "+BorrowerController.getCurrentBorrower().getUserName());
Welcome.setText("Welcome, "+TransactionsForBorrowersController.getCurrentBorrower().getUserName());
Slider.setTranslateX(-278);
MiddlePane.setTranslateX(-278);
CheckNotifications();
Expand Down Expand Up @@ -188,7 +188,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
});
Transactions.setOnMouseClicked(mouseEvent -> {
try {
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("BorrowerTransactions.fxml")));
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("borrower-transactions-view.fxml")));
primaryStage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
scene = new Scene(root);
primaryStage.setScene(scene);
Expand All @@ -200,7 +200,11 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
});
MyBooks.setOnMouseClicked(mouseEvent -> {
try {
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("BorrowerTransactions.fxml")));
Parent root;
FXMLLoader loader = new FXMLLoader(getClass().getResource("My-Books.fxml"));
root = loader.load();
MyBooksController sceneController = loader.getController();
sceneController.startMyBooksController();
primaryStage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
scene = new Scene(root);
primaryStage.setScene(scene);
Expand All @@ -212,7 +216,11 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
});
Shopping.setOnMouseClicked(mouseEvent -> {
try {
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("BorrowerTransactions.fxml")));
Parent root;
FXMLLoader loader = new FXMLLoader(getClass().getResource("All-Books.fxml"));
root = loader.load();
AllBooksController sceneController = loader.getController();
sceneController.startAllBooksController();
primaryStage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
scene = new Scene(root);
primaryStage.setScene(scene);
Expand All @@ -224,7 +232,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
});
ManageProfile.setOnMouseClicked(mouseEvent -> {
try {
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("BorrowerTransactions.fxml")));
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("managing-profile-view.fxml")));
primaryStage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
scene = new Scene(root);
primaryStage.setScene(scene);
Expand All @@ -236,7 +244,8 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
});
Logout.setOnMouseClicked(mouseEvent -> {
try {
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("BorrowerTransactions.fxml")));
Library.logOut();
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("Login.fxml")));
primaryStage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
scene = new Scene(root);
primaryStage.setScene(scene);
Expand Down
Loading

0 comments on commit e927b21

Please sign in to comment.