From 19546177f3ce536f6892890099bb67c3cdacb1d1 Mon Sep 17 00:00:00 2001 From: Erik Aasen Date: Wed, 22 Apr 2026 15:00:24 +0200 Subject: [PATCH 1/5] javadoc for aboutscreen og accountscreen --- .../idatt1005/group03/UI/AboutUsScreen.java | 28 +++++++++++++++++-- .../idatt1005/group03/UI/AccountScreen.java | 25 +++++++++++++++-- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/main/java/no/ntnu/idatt1005/group03/UI/AboutUsScreen.java b/src/main/java/no/ntnu/idatt1005/group03/UI/AboutUsScreen.java index cd43759..48803c7 100644 --- a/src/main/java/no/ntnu/idatt1005/group03/UI/AboutUsScreen.java +++ b/src/main/java/no/ntnu/idatt1005/group03/UI/AboutUsScreen.java @@ -12,14 +12,36 @@ import javafx.stage.Stage; import no.ntnu.idatt1005.group03.Model.User; -public class AboutUsScreen { - private final User user; +/** + * Displays the "About Us" screen in the application. + * + *

This class is part of the UI layer in the MVC architecture and is responsible + * for presenting informational content about the application. It builds and displays a + * JavaFX screen containing a top menu, a large image, and a button for navigating back + * to the home screen.

+ * + *

The screen content is wrapped in a {@code ScrollPane} to support vertical scrolling + * when the content exceeds the available window height.

+ */ +public class AboutUsScreen { + /** + * Constructs a new {@code AboutUsScreen} instance. + * + * @param user the current user context for the screen + */ public AboutUsScreen(User user) { - this.user = user; } + /** + * Builds and displays the About Us screen on the provided stage. + * + *

This method creates the layout, applies the stylesheet, sets the scene on the stage, + * and shows the window.

+ * + * @param stage the JavaFX stage on which the screen will be displayed + */ public void start(Stage stage) { BorderPane layout = new BorderPane(); diff --git a/src/main/java/no/ntnu/idatt1005/group03/UI/AccountScreen.java b/src/main/java/no/ntnu/idatt1005/group03/UI/AccountScreen.java index 9e6867c..7d864d6 100644 --- a/src/main/java/no/ntnu/idatt1005/group03/UI/AccountScreen.java +++ b/src/main/java/no/ntnu/idatt1005/group03/UI/AccountScreen.java @@ -8,8 +8,6 @@ import javafx.scene.layout.VBox; import javafx.scene.layout.Priority; import javafx.geometry.Insets; -import javafx.scene.control.Hyperlink; -import javafx.scene.layout.StackPane; import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.image.ImageView; @@ -17,14 +15,37 @@ import javafx.scene.layout.Region; import no.ntnu.idatt1005.group03.Model.Donation; +/** + * Displays the account screen for a logged-in user. + * + *

This class is part of the UI layer in the MVC architecture and is responsible + * for presenting account-related information to the user. It builds and displays a JavaFX + * screen containing the user's profile details, donation history, and logout option.

+ * + *

The screen is composed of separate sections for profile information, donation records, + * and logout functionality.

+ */ public class AccountScreen { private final User user; + /** + * Constructs a new {@code AccountScreen} instance. + * + * @param user the currently logged-in user whose account information will be displayed + */ public AccountScreen(User user) { this.user = user; } + /** + * Builds and displays the account screen on the provided stage. + * + *

This method creates the layout, applies the stylesheet, sets the scene on the stage, + * and shows the window.

+ * + * @param stage the JavaFX stage on which the screen will be displayed + */ public void start(Stage stage) { BorderPane accountLayout = new BorderPane(); accountLayout.setTop(new TopMenu("Account")); From 37ddbd20e0d687f448ca47451e1a55a40f06e27d Mon Sep 17 00:00:00 2001 From: Erik Aasen Date: Wed, 22 Apr 2026 15:07:09 +0200 Subject: [PATCH 2/5] javadoc donationscreen og loginscreen --- .../idatt1005/group03/UI/DonationScreen.java | 27 +++++++++++++++++-- .../idatt1005/group03/UI/FavoriteScreen.java | 4 --- .../idatt1005/group03/UI/LoginScreen.java | 20 ++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) delete mode 100644 src/main/java/no/ntnu/idatt1005/group03/UI/FavoriteScreen.java diff --git a/src/main/java/no/ntnu/idatt1005/group03/UI/DonationScreen.java b/src/main/java/no/ntnu/idatt1005/group03/UI/DonationScreen.java index b40f33c..dd2cee9 100644 --- a/src/main/java/no/ntnu/idatt1005/group03/UI/DonationScreen.java +++ b/src/main/java/no/ntnu/idatt1005/group03/UI/DonationScreen.java @@ -3,7 +3,6 @@ import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; -import javafx.scene.control.Hyperlink; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.HBox; @@ -19,19 +18,43 @@ import java.net.URI; import java.time.LocalDate; +/** + * Displays the donation screen for a selected organization. + * + *

This class is part of the UI layer in the MVC architecture and is responsible + * for presenting donation-related actions to the user. It allows the user to view the + * selected organization, visit its website, add or remove it from favorites, and register + * a donation.

+ * + *

The screen validates donation input before creating a {@link Donation} object and + * adding it to the current user's donation list.

+ */ public class DonationScreen { private final Organization organization; private final User user; private final FavoriteController favoriteController; - + /** + * Constructs a new {@code DonationScreen} instance. + * + * @param organization the organization the user may donate to + * @param user the currently logged-in user + */ public DonationScreen(Organization organization, User user) { this.organization = organization; this.user = user; this.favoriteController = new FavoriteController(); } + /** + * Builds and displays the donation screen on the provided stage. + * + *

This method creates the layout, applies the stylesheet, sets the scene on the stage, + * and shows the window.

+ * + * @param stage the JavaFX stage on which the screen will be displayed + */ public void start(Stage stage) { VBox layout = new VBox(15); diff --git a/src/main/java/no/ntnu/idatt1005/group03/UI/FavoriteScreen.java b/src/main/java/no/ntnu/idatt1005/group03/UI/FavoriteScreen.java deleted file mode 100644 index fe50803..0000000 --- a/src/main/java/no/ntnu/idatt1005/group03/UI/FavoriteScreen.java +++ /dev/null @@ -1,4 +0,0 @@ -package no.ntnu.idatt1005.group03.UI; - -public class FavoriteScreen { -} diff --git a/src/main/java/no/ntnu/idatt1005/group03/UI/LoginScreen.java b/src/main/java/no/ntnu/idatt1005/group03/UI/LoginScreen.java index 4c2183f..cf7bfae 100644 --- a/src/main/java/no/ntnu/idatt1005/group03/UI/LoginScreen.java +++ b/src/main/java/no/ntnu/idatt1005/group03/UI/LoginScreen.java @@ -19,6 +19,17 @@ import java.util.Optional; +/** + * Displays the login and sign-up screen for the application. + * + *

This class is part of the UI layer in the MVC architecture and serves as the + * entry point for user authentication. It provides two scenes: one for user registration + * and one for user login. The class coordinates user input with the authentication + * controller and handles navigation to the home screen after successful authentication.

+ * + *

The class extends {@link Application} and is responsible for initializing the + * primary stage used for login and registration.

+ */ public class LoginScreen extends Application { // homepage private Scene scene1; // Sign Up @@ -29,6 +40,15 @@ public class LoginScreen extends Application { // homepage private Label loginErrLabel; private FavoriteController favoriteController; + /** + * Initializes and displays the login screen on the provided primary stage. + * + *

This method creates the authentication controller and favorite controller, + * initializes feedback labels, builds both the sign-up and login scenes, + * and displays the initial scene.

+ * + * @param primaryStage the primary JavaFX stage for the application + */ @Override public void start(Stage primaryStage) { this.stage = primaryStage; From f9926d6bf0cdc6f01175a6dd4f94454092bc6ab7 Mon Sep 17 00:00:00 2001 From: Erik Aasen Date: Wed, 22 Apr 2026 15:10:20 +0200 Subject: [PATCH 3/5] javadoc for organizationscreen + removed unused method create oldheader --- .../group03/UI/OrganizationsScreen.java | 58 ++++++++----------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/src/main/java/no/ntnu/idatt1005/group03/UI/OrganizationsScreen.java b/src/main/java/no/ntnu/idatt1005/group03/UI/OrganizationsScreen.java index 548b4c3..95fe06f 100644 --- a/src/main/java/no/ntnu/idatt1005/group03/UI/OrganizationsScreen.java +++ b/src/main/java/no/ntnu/idatt1005/group03/UI/OrganizationsScreen.java @@ -27,18 +27,43 @@ import java.util.List; +/** + * Displays the main organization overview screen for the user. + * + *

This class is part of the UI layer in the MVC architecture and is responsible + * for presenting available organizations to the user. It allows the user to browse + * organizations, search by name or category, view favorite organizations, mark or unmark + * favorites, and navigate to the donation screen for a selected organization.

+ * + *

The screen retrieves organization data through the {@link OrganizationController} + * and favorite-related actions through the {@link FavoriteController}.

+ */ public class OrganizationsScreen { private final User user; private final OrganizationController orgController; private final FavoriteController favoriteController; + /** + * Constructs a new {@code OrganizationsScreen} instance. + * + * @param user the currently logged-in user + */ public OrganizationsScreen(User user) { this.user = user; this.orgController = new OrganizationController(); this.favoriteController = new FavoriteController(); } + + /** + * Builds and displays the organizations screen on the provided stage. + * + *

This method creates the layout, loads the list of organizations, applies the stylesheet, + * sets the scene on the stage, and shows the window.

+ * + * @param stage the JavaFX stage on which the screen will be displayed + */ public void start(Stage stage) { BorderPane mainLayout = new BorderPane(); @@ -186,37 +211,4 @@ private ScrollPane wrapInScrollPane(VBox content) { scrollPane.getStyleClass().add("transparent-scroll-pane"); return scrollPane; } - - private HBox createOldHeader(User user, Stage stage) { - HBox header = new HBox(15); - header.setPadding(new Insets(15)); - header.getStyleClass().add("top-header"); - header.setAlignment(javafx.geometry.Pos.CENTER_LEFT); - - Image image = new Image(getClass().getResourceAsStream("/images/donate2.png")); - ImageView imageView = new ImageView(image); - imageView.setFitWidth(40); - imageView.setFitHeight(40); - imageView.setPreserveRatio(true); - - Hyperlink aboutUs = new Hyperlink("About us"); - aboutUs.getStyleClass().add("nav-link"); - aboutUs.setOnAction(e -> { - AboutUsScreen abscreen = new AboutUsScreen(user); - abscreen.start(stage); - }); - - Region spacer = new Region(); - HBox.setHgrow(spacer, Priority.ALWAYS); - - Button accountButton = new Button("Account"); - accountButton.getStyleClass().addAll("btn", "btn-primary"); - accountButton.setOnAction(e -> { - AccountScreen accScreen = new AccountScreen(user); - accScreen.start(stage); - }); - - header.getChildren().addAll(imageView, spacer, aboutUs, accountButton); - return header; - } } \ No newline at end of file From c553a21dd76dd28ea4570feb5a8459dd7fe748b8 Mon Sep 17 00:00:00 2001 From: Erik Aasen Date: Wed, 22 Apr 2026 15:15:24 +0200 Subject: [PATCH 4/5] javadoc for screenmanager + made a private contructor --- .../idatt1005/group03/UI/ScreenManager.java | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/main/java/no/ntnu/idatt1005/group03/UI/ScreenManager.java b/src/main/java/no/ntnu/idatt1005/group03/UI/ScreenManager.java index 71b4369..4b76259 100644 --- a/src/main/java/no/ntnu/idatt1005/group03/UI/ScreenManager.java +++ b/src/main/java/no/ntnu/idatt1005/group03/UI/ScreenManager.java @@ -4,42 +4,93 @@ import no.ntnu.idatt1005.group03.Model.Organization; import no.ntnu.idatt1005.group03.Model.User; +/** + * Manages screen navigation and shared UI state in the application. + * + *

This class is part of the UI layer in the MVC architecture and is responsible + * for centralizing navigation between screens. It stores references to the main application + * stage and the currently logged-in user, allowing different screens to be shown without + * passing these values around manually each time.

+ * + *

The class provides static methods for switching between the main screens of the + * application, including the home screen, account screen, about screen, donation screen, + * and login screen.

+ */ public class ScreenManager { private static Stage mainStage; private static User currentUser; + /** + * Prevents instantiation of this utility class. + */ + private ScreenManager() { + } + // Setup methods + /** + * Sets the main stage used for screen navigation. + * + * @param stage the main JavaFX stage of the application + */ public static void setMainStage(Stage stage) { mainStage = stage; } + /** + * Sets the currently logged-in user. + * + * @param user the user to store as the current user + */ public static void setCurrentUser(User user) { currentUser = user; } + /** + * Returns the currently logged-in user. + * + * @return the current user, or {@code null} if no user is logged in + */ public static User getCurrentUser() { return currentUser; } // Navigation Methods + /** + * Displays the home screen for the current user. + */ public static void showHomeScreen() { new OrganizationsScreen(currentUser).start(mainStage); } + /** + * Displays the About Us screen for the current user. + */ public static void showAboutUsScreen() { new AboutUsScreen(currentUser).start(mainStage); } + /** + * Displays the account screen for the current user. + */ public static void showAccountScreen() { new AccountScreen(currentUser).start(mainStage); } + /** + * Displays the donation screen for the selected organization. + * + * @param org the organization the user may donate to + */ public static void showDonationScreen(Organization org) { new DonationScreen(org, currentUser).start(mainStage); } - // Add this for later when we build the Login/Logout flow! + /** + * Logs out the current user and returns to the login screen. + * + *

This method clears the stored user reference and displays the login screen again.

+ */ public static void logout() { currentUser = null; new LoginScreen().start(mainStage); From 1b969dbfe7066373d6ce7b62df6a40a8ba50ce55 Mon Sep 17 00:00:00 2001 From: Erik Aasen Date: Wed, 22 Apr 2026 15:21:39 +0200 Subject: [PATCH 5/5] javadoc for topmenu and App --- .../java/no/ntnu/idatt1005/group03/App.java | 24 ++++++++++++++++- .../no/ntnu/idatt1005/group03/UI/TopMenu.java | 27 +++++++++++++++---- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/main/java/no/ntnu/idatt1005/group03/App.java b/src/main/java/no/ntnu/idatt1005/group03/App.java index 04b71d7..872a56f 100644 --- a/src/main/java/no/ntnu/idatt1005/group03/App.java +++ b/src/main/java/no/ntnu/idatt1005/group03/App.java @@ -5,8 +5,26 @@ import no.ntnu.idatt1005.group03.DAO.DatabaseConnection; import no.ntnu.idatt1005.group03.UI.LoginScreen; +/** + * Starts the application and initializes required resources. + * + *

This class serves as the main entry point of the application. It is part of the + * overall application bootstrap layer and is responsible for starting the JavaFX runtime, + * initializing the database, and launching the first user interface screen.

+ * + *

When the application starts, the database schema is initialized before the login + * screen is displayed to the user.

+ */ public class App extends Application { + /** + * Starts the JavaFX application. + * + *

This method initializes the database and launches the login screen on the provided + * primary stage. If the user interface fails to load, an error message is printed.

+ * + * @param primaryStage the primary JavaFX stage for the application + */ @Override public void start(Stage primaryStage) { // 1. Initialize the database so it is ready for the rest of the app @@ -21,8 +39,12 @@ public void start(Stage primaryStage) { } } + /** + * Launches the JavaFX application. + * + * @param args command-line arguments passed to the application + */ public static void main(String[] args) { - // This command tells JavaFX to start the visual application launch(args); } } \ No newline at end of file diff --git a/src/main/java/no/ntnu/idatt1005/group03/UI/TopMenu.java b/src/main/java/no/ntnu/idatt1005/group03/UI/TopMenu.java index 04fd09d..673710e 100644 --- a/src/main/java/no/ntnu/idatt1005/group03/UI/TopMenu.java +++ b/src/main/java/no/ntnu/idatt1005/group03/UI/TopMenu.java @@ -9,11 +9,28 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.scene.layout.Region; -import javafx.stage.Stage; -import no.ntnu.idatt1005.group03.Model.User; +/** + * Represents the top navigation menu used across application screens. + * + *

This class is part of the UI layer in the MVC architecture and is responsible + * for providing a consistent navigation header for the main screens of the application. + * It includes a clickable logo, navigation links, and an account button.

+ * + *

The menu highlights the currently active screen and disables navigation for that + * screen by showing it as styled text instead of an active link or button.

+ */ public class TopMenu extends HBox { + /** + * Constructs a new {@code TopMenu} for the specified current screen. + * + *

The menu adapts its navigation behavior depending on which screen is currently + * displayed. The active screen is visually highlighted, while navigation controls + * for other screens remain available.

+ * + * @param currentScreen the name of the currently active screen + */ public TopMenu(String currentScreen) { this.setSpacing(15); this.setPadding(new Insets(15)); @@ -32,7 +49,7 @@ public TopMenu(String currentScreen) { Hyperlink homeLink = new Hyperlink("Home"); homeLink.getStyleClass().add("nav-link"); - if (currentScreen.equals("Home")) { + if ("Home".equals(currentScreen)) { homeLink.getStyleClass().add("bold-text"); } else { homeLink.setOnAction(e -> ScreenManager.showHomeScreen()); @@ -41,7 +58,7 @@ public TopMenu(String currentScreen) { Hyperlink aboutUsLink = new Hyperlink("About us"); aboutUsLink.getStyleClass().add("nav-link"); - if (currentScreen.equals("AboutUs")) { + if ("AboutUs".equals(currentScreen)) { aboutUsLink.getStyleClass().add("bold-text"); } else { aboutUsLink.setOnAction(e -> ScreenManager.showAboutUsScreen()); @@ -55,7 +72,7 @@ public TopMenu(String currentScreen) { this.getChildren().addAll(imageView, homeLink, aboutUsLink, spacer); // Account Button - if (!currentScreen.equals("Account")) { + if (!"Account".equals(currentScreen)) { Button accountButton = new Button("Account"); accountButton.getStyleClass().addAll("btn", "btn-primary"); accountButton.setOnAction(e -> ScreenManager.showAccountScreen());