Skip to content

Commit

Permalink
Normal
Browse files Browse the repository at this point in the history
Normal
  • Loading branch information
MatthewMacri committed Nov 29, 2024
1 parent 760032e commit f46c546
Show file tree
Hide file tree
Showing 20 changed files with 378 additions and 301 deletions.
6 changes: 6 additions & 0 deletions Deliverable_3/SchoolRegistrationSystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,11 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.47.1.0</version>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void actionPerformed(ActionEvent e) {
});

// Return buttons in different panels to go back to main menu
view.getTeacherViewCourseDetailsPage().getReturnButton().addActionListener(new ActionListener() {
view.getTeacherViewCourseTeachingPage().getReturnButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
view.showMainMenuPanel();
Expand All @@ -66,6 +66,7 @@ public void actionPerformed(ActionEvent e) {
});
}


/**
* makes sure the login information is valid before opening the main menu.
*/
Expand All @@ -83,7 +84,7 @@ private void login() {
view.getTeacherMainMenuPage().getNameLabel().setText(teacher.getFullName());
view.showMainMenuPanel();
} else {
view.getTeacherLoginPage().getErrorLabel().setText("Error! Incorrect Teacher ID or Password");
view.getTeacherLoginPage().getErrorLabel().setText("no");
}
}

Expand All @@ -102,18 +103,12 @@ private TeacherModel verifyTeacherInputLogin(int id, String password) {
}
}
if (id == -20) {
CourseModel historyCourse = new CourseModel("HIST101", 1, 30, 3, 9, 11, "Monday");
CourseModel historyCourse2 = new CourseModel("HIST102", 1, 30, 3, 11, 1, "Wednesday");

List<CourseModel> coursesTeaching = new ArrayList<>();
coursesTeaching.add(historyCourse);
coursesTeaching.add(historyCourse2);
// Create TeacherModel with the courses they are teaching
return new TeacherModel("Sothearoum", "Thao", "438-725-8966", "[email protected]", "yeeteronii", coursesTeaching);
return new TeacherModel("Sothearoum", "Thao", "438-725-8966",
"[email protected]", "yeeteronii", coursesTeaching);
}
return null;
}

/**
* method to display schedule in the teacher view schedule panel
*/
Expand All @@ -127,7 +122,7 @@ private void showTeacherSchedule() {
* displays course details in the teacher course details page
*/
private void showCourseDetails() {
view.showViewCourseDetailsPanel();
view.showViewCourseTeachingPanel();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package org.vanier.view;

import org.vanier.view.adminPanels.AddCoursePanel;
import org.vanier.view.adminPanels.UpdateCoursePanel;
import org.vanier.view.adminPanels.DeleteCoursePanel;
import org.vanier.view.adminPanels.ViewEnrollmentsPanel;
import org.vanier.view.adminPanels.GenerateReportPanel;
import org.vanier.model.RegistrationSystem;
import org.vanier.view.adminPanels.*;

import javax.swing.*;
import java.awt.*;
Expand All @@ -14,11 +11,13 @@ public class AdminManagementView extends JFrame {
private CardLayout cardLayout;

private JPanel adminMainMenuPanel;
private AddCoursePanel addCoursePanel;
private UpdateCoursePanel updateCoursePanel;
private DeleteCoursePanel deleteCoursePanel;
private ViewEnrollmentsPanel viewEnrollmentsPanel;
private GenerateReportPanel generateReportPanel;

private AdminAddCoursePage adminAddCoursePage = new AdminAddCoursePage();
private AdminLoginPage adminLoginPage = new AdminLoginPage();
private AdminMainMenuPage adminMainMenuPage = new AdminMainMenuPage();
private AdminManageAndGenerateReportsPage adminManageAndGenerateReportsPage = new AdminManageAndGenerateReportsPage();
private AdminUpdateCoursePage adminUpdateCoursePage = new AdminUpdateCoursePage();
private AdminViewStudentEnrollmentPage adminViewStudentEnrollmentPage = new AdminViewStudentEnrollmentPage();

public AdminManagementView() throws HeadlessException {
setTitle("Admin Portal");
Expand All @@ -28,75 +27,60 @@ public AdminManagementView() throws HeadlessException {
cardLayout = new CardLayout();
mainPanel = new JPanel(cardLayout);

// Initialize the main menu panel for admin
// Initialize the main menu panel for admin with buttons
adminMainMenuPanel = new JPanel();
JButton addCourseButton = new JButton("Add Course");
JButton updateCourseButton = new JButton("Update Course");
JButton deleteCourseButton = new JButton("Delete Course");
JButton viewEnrollmentsButton = new JButton("View Enrollments");
JButton generateReportButton = new JButton("Generate Report");

// Add buttons to the main menu panel
// Add buttons to the panel
adminMainMenuPanel.add(addCourseButton);
adminMainMenuPanel.add(updateCourseButton);
adminMainMenuPanel.add(deleteCourseButton);
adminMainMenuPanel.add(viewEnrollmentsButton);
adminMainMenuPanel.add(generateReportButton);

// Initialize task-specific panels
addCoursePanel = new AddCoursePanel();
updateCoursePanel = new UpdateCoursePanel();
deleteCoursePanel = new DeleteCoursePanel();
viewEnrollmentsPanel = new ViewEnrollmentsPanel();
generateReportPanel = new GenerateReportPanel();
adminAddCoursePage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());
adminLoginPage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());
adminMainMenuPage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());
adminManageAndGenerateReportsPage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());
adminUpdateCoursePage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());
adminViewStudentEnrollmentPage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());

// Add panels to the CardLayout with unique names
// Add main menu panel to card layout
mainPanel.add(adminMainMenuPanel, "adminMainMenu");
mainPanel.add(addCoursePanel, "addCourse");
mainPanel.add(updateCoursePanel, "updateCourse");
mainPanel.add(deleteCoursePanel, "deleteCourse");
mainPanel.add(viewEnrollmentsPanel, "viewEnrollments");
mainPanel.add(generateReportPanel, "generateReport");

// Add the main panel to the frame
add(mainPanel);

// Add action listeners to buttons for panel navigation
addCourseButton.addActionListener(e -> showPanel("addCourse"));
updateCourseButton.addActionListener(e -> showPanel("updateCourse"));
deleteCourseButton.addActionListener(e -> showPanel("deleteCourse"));
viewEnrollmentsButton.addActionListener(e -> showPanel("viewEnrollments"));
generateReportButton.addActionListener(e -> showPanel("generateReport"));
}

// Method to show a specific panel by name
public void showPanel(String panelName) {
cardLayout.show(mainPanel, panelName);
public JPanel getAdminMainMenuPanel() {
return adminMainMenuPanel;
}

// Method to return to the main menu
public void showAdminMainMenuPanel() {
cardLayout.show(mainPanel, "adminMainMenu");
public JButton getAddCourseButton() {
return (JButton) adminMainMenuPanel.getComponent(0);
}

// Getters for the individual panels
public AddCoursePanel getAddCoursePanel() {
return addCoursePanel;
public JButton getUpdateCourseButton() {
return (JButton) adminMainMenuPanel.getComponent(1);
}

public UpdateCoursePanel getUpdateCoursePanel() {
return updateCoursePanel;
public JButton getDeleteCourseButton() {
return (JButton) adminMainMenuPanel.getComponent(2);
}

public DeleteCoursePanel getDeleteCoursePanel() {
return deleteCoursePanel;
public JButton getViewEnrollmentsButton() {
return (JButton) adminMainMenuPanel.getComponent(3);
}

public ViewEnrollmentsPanel getViewEnrollmentsPanel() {
return viewEnrollmentsPanel;
public JButton getGenerateReportButton() {
return (JButton) adminMainMenuPanel.getComponent(4);
}

public GenerateReportPanel getGenerateReportPanel() {
return generateReportPanel;
public void showAdminMainMenuPanel() {
cardLayout.show(mainPanel, "adminMainMenu");
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.vanier.view;

import org.vanier.view.teachersPanels.TeacherLoginPage;
import org.vanier.view.teachersPanels.TeacherMainMenuPage;
import org.vanier.view.teachersPanels.TeacherViewCourseDetailsPage;
import org.vanier.view.teachersPanels.TeacherViewSchedulePage;
import org.vanier.model.RegistrationSystem;
import org.vanier.view.teachersPanels.*;

import javax.swing.*;
import java.awt.*;
Expand All @@ -14,8 +12,9 @@ public class TeacherView extends JFrame {

private TeacherLoginPage teacherLoginPage;
private TeacherMainMenuPage teacherMainMenuPage;
private TeacherViewCourseDetailsPage teacherViewCourseDetailsPage;
private TeacherViewCourseTeachingPage teacherViewCourseTeachingPage;
private TeacherViewSchedulePage teacherViewSchedulePage;
private TeacherViewCourseDetailsPage teacherViewCourseDetailsPage;

public TeacherView() throws HeadlessException {
setTitle("Teacher Portal");
Expand All @@ -29,14 +28,21 @@ public TeacherView() throws HeadlessException {
// Initialize all the teacher pages
teacherLoginPage = new TeacherLoginPage();
teacherMainMenuPage = new TeacherMainMenuPage();
teacherViewCourseDetailsPage = new TeacherViewCourseDetailsPage();
teacherViewCourseTeachingPage = new TeacherViewCourseTeachingPage();
teacherViewSchedulePage = new TeacherViewSchedulePage();
teacherViewCourseDetailsPage = new TeacherViewCourseDetailsPage();

teacherLoginPage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());
teacherMainMenuPage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());
teacherViewCourseTeachingPage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());
teacherViewSchedulePage.changeLanguage(RegistrationSystem.getInstance().getResourceBundle());

// Add pages to the CardLayout panel with unique names
mainPanel.add(teacherLoginPage.getTeacherLoginPagePanel(), "login");
mainPanel.add(teacherMainMenuPage.getTeacherMainMenuPanel(), "mainMenu");
mainPanel.add(teacherViewCourseDetailsPage.getTeacherViewCoursePanel(), "viewCourseDetails"); // updated panel name
mainPanel.add(teacherViewCourseTeachingPage.getTeacherViewCoursePanel(), "viewCourseTeaching"); // updated panel name
mainPanel.add(teacherViewSchedulePage.getTeacherViewSchedulePanel(), "viewSchedule");
mainPanel.add(teacherViewCourseDetailsPage.getTeacherCourseDetailsPanel(),"viewCourseDetails");

// Add the mainPanel to the JFrame
add(mainPanel);
Expand All @@ -56,14 +62,16 @@ public void showMainMenuPanel() {
cardLayout.show(mainPanel, "mainMenu");
}

public void showViewCourseDetailsPanel() {
cardLayout.show(mainPanel, "viewCourseDetails"); // updated panel name
public void showViewCourseTeachingPanel() {
cardLayout.show(mainPanel, "viewCourseTeaching"); // updated panel name
}

public void showViewSchedulePanel() {
cardLayout.show(mainPanel, "viewSchedule");
}

public void showViewCourseDetailsPanel() {cardLayout.show(mainPanel, "viewCourseDetails");}

// Getters for the individual pages, in case they are needed
public TeacherLoginPage getTeacherLoginPage() {
return teacherLoginPage;
Expand All @@ -73,11 +81,15 @@ public TeacherMainMenuPage getTeacherMainMenuPage() {
return teacherMainMenuPage;
}

public TeacherViewCourseDetailsPage getTeacherViewCourseDetailsPage() {
return teacherViewCourseDetailsPage;
public TeacherViewCourseTeachingPage getTeacherViewCourseTeachingPage() {
return teacherViewCourseTeachingPage;
}

public TeacherViewSchedulePage getTeacherViewSchedulePage() {
return teacherViewSchedulePage;
}

public TeacherViewCourseDetailsPage getTeacherViewCourseDetailsPage() {
return teacherViewCourseDetailsPage;
}
}
Original file line number Diff line number Diff line change
@@ -1,54 +1,23 @@
package org.vanier.view.adminPanels;

import javax.swing.*;
import java.awt.*;
import java.util.ResourceBundle;

public class AdminAddCoursePage extends JPanel {
public class AdminAddCoursePage extends JFrame {
private JTextField courseIdTextField;
private JLabel addCourseMenuLabel;
private JPanel addCourseMenu;
private JLabel courseIdLabel;
private JTextField courseNumberField, courseSectionField, courseCapacityField, courseCreditsField, startTimeField, endTimeField, dayOfWeekField;
private JButton courseAddButton;
private JButton returnToPreviousPageButton;

public AdminAddCoursePage() {
setLayout(new GridLayout(9, 2, 10, 10)); // Arrange components in a grid layout

// Initialize UI components
addCourseMenuLabel = new JLabel("Add Course");
courseIdLabel = new JLabel("Course ID:");
courseIdTextField = new JTextField();
courseNumberField = new JTextField();
courseSectionField = new JTextField();
courseCapacityField = new JTextField();
courseCreditsField = new JTextField();
startTimeField = new JTextField();
endTimeField = new JTextField();
dayOfWeekField = new JTextField();
courseAddButton = new JButton("Add Course");
returnToPreviousPageButton = new JButton("Back");

// Add components to the panel
add(addCourseMenuLabel);
add(new JLabel()); // Empty cell for spacing
add(courseIdLabel);
add(courseIdTextField);
add(new JLabel("Course Number:"));
add(courseNumberField);
add(new JLabel("Course Section:"));
add(courseSectionField);
add(new JLabel("Course Capacity:"));
add(courseCapacityField);
add(new JLabel("Course Credits:"));
add(courseCreditsField);
add(new JLabel("Start Time:"));
add(startTimeField);
add(new JLabel("End Time:"));
add(endTimeField);
add(new JLabel("Day of Week:"));
add(dayOfWeekField);
add(courseAddButton);
add(returnToPreviousPageButton);
setTitle("Add Course");
setContentPane(addCourseMenu);
setSize(400, 300);
setLocationRelativeTo(null);
setVisible(true);
}

// Getters for UI elements that the controller will interact with
Expand Down Expand Up @@ -91,4 +60,15 @@ public JButton getCourseAddButton() {
public JButton getReturnToPreviousPageButton() {
return returnToPreviousPageButton;
}
}

public JPanel getAddCourseMenu() {
return addCourseMenu;
}

public void changeLanguage(ResourceBundle resourceBundle){
addCourseMenuLabel.setText(resourceBundle.getString("addCourseMenu"));
courseIdLabel.setText(resourceBundle.getString("courseIdLabel"));
returnToPreviousPageButton.setText(resourceBundle.getString("returnToPreviousPageButton"));
courseAddButton.setText(resourceBundle.getString("courseAddButton"));
}
}
Loading

0 comments on commit f46c546

Please sign in to comment.