Better UI, added LookAndFeel, changed fonts
This commit is contained in:
@@ -15,8 +15,11 @@ public class Faculty implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String abbreviation;
|
private String abbreviation;
|
||||||
|
|
||||||
private List<Group> groups = new ArrayList<>();
|
private List<Group> groups = new ArrayList<>();
|
||||||
|
|
||||||
private StudyField field;
|
private StudyField field;
|
||||||
|
|
||||||
public void addGroup(Group group) {
|
public void addGroup(Group group) {
|
||||||
@@ -43,10 +46,6 @@ public class Faculty implements Serializable {
|
|||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroups(List<Group> groups) {
|
|
||||||
this.groups = groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StudyField getField() {
|
public StudyField getField() {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
package org.lumijiez.base;
|
package org.lumijiez.base;
|
||||||
|
|
||||||
|
import org.lumijiez.enums.Subjects;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class Grade implements Serializable {
|
public class Grade implements Serializable {
|
||||||
private String subject;
|
private final Subjects subject;
|
||||||
private int grade;
|
private final int grade;
|
||||||
|
|
||||||
public void setSubject(String subject) {
|
public Grade(Subjects subject, int grade) {
|
||||||
this.subject = subject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGrade(int grade) {
|
|
||||||
this.grade = grade;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Grade(String subject, int grade) {
|
|
||||||
this.subject = subject;
|
this.subject = subject;
|
||||||
this.grade = grade;
|
this.grade = grade;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSubject() {
|
public Subjects getSubject() {
|
||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class Group implements Serializable {
|
|||||||
|
|
||||||
private Faculty faculty;
|
private Faculty faculty;
|
||||||
|
|
||||||
private List<Student> students = new ArrayList<>();
|
private final List<Student> students = new ArrayList<>();
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -23,10 +23,6 @@ public class Group implements Serializable {
|
|||||||
this.faculty = faculty;
|
this.faculty = faculty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStudents(List<Student> students) {
|
|
||||||
this.students = students;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Group(String name) {
|
public Group(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
@@ -47,14 +43,6 @@ public class Group implements Serializable {
|
|||||||
return students;
|
return students;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Student getStudent(String name, String surname) {
|
|
||||||
for (Student student : students)
|
|
||||||
if (student.getName().equals(name) && student.getSurname().equals(surname)) {
|
|
||||||
return student;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.lumijiez.base;
|
package org.lumijiez.base;
|
||||||
|
|
||||||
import org.lumijiez.util.FullStudentData;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -9,50 +7,45 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Student implements Serializable {
|
public class Student implements Serializable {
|
||||||
|
|
||||||
public Student(String name, String surname, Group group, Faculty faculty, Date birth, Date enrol) {
|
public Student(String name, String surname, String email, Group group, Faculty faculty, Date birth, Date enrol) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
this.fullname = name + " " + surname;
|
this.fullname = name + " " + surname;
|
||||||
|
this.email = email;
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this.faculty = faculty;
|
this.faculty = faculty;
|
||||||
this.dateOfBirth = birth;
|
this.dateOfBirth = birth;
|
||||||
this.enrollmentDate = enrol;
|
this.enrollmentDate = enrol;
|
||||||
this.FSD = new FullStudentData(name, surname, group.getName(), faculty.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean graduated = false;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String surname;
|
private String surname;
|
||||||
|
|
||||||
private String fullname;
|
private String fullname;
|
||||||
|
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
private Date enrollmentDate;
|
private Date enrollmentDate;
|
||||||
|
|
||||||
private Date dateOfBirth;
|
private Date dateOfBirth;
|
||||||
|
|
||||||
private Faculty faculty;
|
private Faculty faculty;
|
||||||
|
|
||||||
private Group group;
|
private Group group;
|
||||||
// This acts like an identification serial number for each student
|
|
||||||
private FullStudentData FSD;
|
|
||||||
private final List<Grade> grades = new ArrayList<>();
|
private final List<Grade> grades = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
// Student stores a reference to its own Group and Faculty, bidirectional association
|
|
||||||
|
|
||||||
public Faculty getFaculty() {
|
public Faculty getFaculty() {
|
||||||
return faculty;
|
return faculty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FullStudentData getFSD() {
|
|
||||||
return FSD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFSD(FullStudentData FSD) {
|
|
||||||
this.FSD = FSD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFaculty(Faculty faculty) {
|
public void setFaculty(Faculty faculty) {
|
||||||
this.faculty = faculty;
|
this.faculty = faculty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setGroup(Group gr) {
|
public void setGroup(Group gr) {
|
||||||
this.group.deleteStudent(this);
|
this.group.deleteStudent(this);
|
||||||
this.group = gr;
|
this.group = gr;
|
||||||
@@ -95,6 +88,10 @@ public class Student implements Serializable {
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGraduated() {
|
||||||
|
return this.graduated;
|
||||||
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
@@ -119,6 +116,10 @@ public class Student implements Serializable {
|
|||||||
this.dateOfBirth = dateOfBirth;
|
this.dateOfBirth = dateOfBirth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGraduated(boolean graduated) {
|
||||||
|
this.graduated = graduated;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return fullname;
|
return fullname;
|
||||||
|
|||||||
56
Lab2/src/main/java/org/lumijiez/enums/Subjects.java
Normal file
56
Lab2/src/main/java/org/lumijiez/enums/Subjects.java
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package org.lumijiez.enums;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public enum Subjects implements Serializable {
|
||||||
|
ENGLISH("English Language", "Eng"),
|
||||||
|
LINEAR_ALGEBRA("Linear Algebra", "AL"),
|
||||||
|
OBJECT_ORIENTED_PROGRAMMING("Object Oriented Programming", "OOP"),
|
||||||
|
DATABASES("Databases", "DB"),
|
||||||
|
MATHEMATICAL_ANALYSIS("Mathematical Analysis", "Mat. Anal"),
|
||||||
|
DISCRETE_MATH("Discrete Math", "MD"),
|
||||||
|
PROBABILITY_AND_STATISTICS("Probability and Statistics", "PSA"),
|
||||||
|
PHYSICS("Physics", "PHYS");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private final String abbreviation;
|
||||||
|
|
||||||
|
Subjects(String name, String abbreviation) {
|
||||||
|
this.name = name;
|
||||||
|
this.abbreviation = abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getAbbrevFromString(String str) {
|
||||||
|
for (Subjects st : values()) {
|
||||||
|
if (st.name.equals(str)) return st.abbreviation;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Subjects getEnum(String str) {
|
||||||
|
for (Subjects st : values()) {
|
||||||
|
if (st.name.equals(str)) return st;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbbreviation() {
|
||||||
|
return abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Subjects> getAllEnums() {
|
||||||
|
return Arrays.asList(values());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,13 +21,13 @@ import org.lumijiez.gui.forms.student.*;
|
|||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
public class StudentManagementGUI extends JFrame {
|
public class StudentManagementGUI extends JFrame {
|
||||||
private Supervisor sv;
|
private static Supervisor sv;
|
||||||
private final JLabel mainTextLabel = new JLabel();
|
|
||||||
private final JMenuBar menuBar = new JMenuBar();
|
private final JMenuBar menuBar = new JMenuBar();
|
||||||
private final JMenu fileMenu = new JMenu();
|
private final JMenu fileMenu = new JMenu();
|
||||||
private final JMenuItem loadBatchOption = new JMenuItem();
|
private final JMenuItem loadBatchOption = new JMenuItem();
|
||||||
@@ -38,6 +38,9 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
private final JMenuItem showAllStudentsOption = new JMenuItem();
|
private final JMenuItem showAllStudentsOption = new JMenuItem();
|
||||||
private final JMenuItem showParticularStudentOption = new JMenuItem();
|
private final JMenuItem showParticularStudentOption = new JMenuItem();
|
||||||
private final JMenuItem showStudentGrade = new JMenuItem();
|
private final JMenuItem showStudentGrade = new JMenuItem();
|
||||||
|
private final JMenuItem graduateStudent = new JMenuItem();
|
||||||
|
private final JMenuItem showGraduates = new JMenuItem();
|
||||||
|
private final JMenuItem showEnrolled = new JMenuItem();
|
||||||
private final JPopupMenu.Separator studentSeparator = new JPopupMenu.Separator();
|
private final JPopupMenu.Separator studentSeparator = new JPopupMenu.Separator();
|
||||||
private final JMenuItem gradeStudentOption = new JMenuItem();
|
private final JMenuItem gradeStudentOption = new JMenuItem();
|
||||||
private final JMenuItem addStudentOption = new JMenuItem();
|
private final JMenuItem addStudentOption = new JMenuItem();
|
||||||
@@ -57,9 +60,12 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
private final JMenuItem addFacultyOption = new JMenuItem();
|
private final JMenuItem addFacultyOption = new JMenuItem();
|
||||||
private final JMenuItem editFacultyOption = new JMenuItem();
|
private final JMenuItem editFacultyOption = new JMenuItem();
|
||||||
private final JMenuItem removeFacultyOption = new JMenuItem();
|
private final JMenuItem removeFacultyOption = new JMenuItem();
|
||||||
|
private final JScrollPane mainScrollPane = new javax.swing.JScrollPane();
|
||||||
|
private static final JTextArea mainTextLabel = new javax.swing.JTextArea();
|
||||||
|
|
||||||
public StudentManagementGUI() {
|
public StudentManagementGUI() {
|
||||||
this.sv = DataDeserializer.deserialize();
|
this.sv = DataDeserializer.deserialize();
|
||||||
|
this.setSize(new Dimension(1280, 720));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
@@ -89,6 +95,13 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
addFacultyOption.setText("Add Faculty");
|
addFacultyOption.setText("Add Faculty");
|
||||||
removeFacultyOption.setText("Remove Faculty");
|
removeFacultyOption.setText("Remove Faculty");
|
||||||
editFacultyOption.setText("Edit Faculty");
|
editFacultyOption.setText("Edit Faculty");
|
||||||
|
graduateStudent.setText("Graduate student");
|
||||||
|
showGraduates.setText("Show Graduates");
|
||||||
|
showEnrolled.setText("Show Enrolled");
|
||||||
|
|
||||||
|
mainTextLabel.setEditable(false);
|
||||||
|
mainTextLabel.setFont(new java.awt.Font("Segoe UI", 0, 14));
|
||||||
|
mainScrollPane.setViewportView(mainTextLabel);
|
||||||
|
|
||||||
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
|
||||||
@@ -99,8 +112,7 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
StudentManagementGUI.this,
|
StudentManagementGUI.this,
|
||||||
"Are you sure you want to exit?",
|
"Are you sure you want to exit?",
|
||||||
"Confirmation",
|
"Confirmation",
|
||||||
JOptionPane.YES_NO_OPTION
|
JOptionPane.YES_NO_OPTION);
|
||||||
);
|
|
||||||
|
|
||||||
if (result == JOptionPane.YES_OPTION) {
|
if (result == JOptionPane.YES_OPTION) {
|
||||||
DataSerializer.serialize(sv);
|
DataSerializer.serialize(sv);
|
||||||
@@ -127,11 +139,17 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
addStudentOption.addActionListener(this::addStudentOptionActionPerformed);
|
addStudentOption.addActionListener(this::addStudentOptionActionPerformed);
|
||||||
editStudentOption.addActionListener(this::editStudentOptionActionPerformed);
|
editStudentOption.addActionListener(this::editStudentOptionActionPerformed);
|
||||||
deleteStudentOption.addActionListener(this::deleteStudentOptionActionPerformed);
|
deleteStudentOption.addActionListener(this::deleteStudentOptionActionPerformed);
|
||||||
|
graduateStudent.addActionListener(this::graduateStudentOptionActionPerformed);
|
||||||
|
showEnrolled.addActionListener(this::showEnrolledOptionActionPerformed);
|
||||||
|
showGraduates.addActionListener(this::showGraduatesOptionActionPerformed);
|
||||||
|
|
||||||
studentMenu.add(showAllStudentsOption);
|
studentMenu.add(showAllStudentsOption);
|
||||||
studentMenu.add(showParticularStudentOption);
|
studentMenu.add(showParticularStudentOption);
|
||||||
studentMenu.add(showStudentGrade);
|
studentMenu.add(showStudentGrade);
|
||||||
|
studentMenu.add(showEnrolled);
|
||||||
|
studentMenu.add(showGraduates);
|
||||||
studentMenu.add(studentSeparator);
|
studentMenu.add(studentSeparator);
|
||||||
|
studentMenu.add(graduateStudent);
|
||||||
studentMenu.add(gradeStudentOption);
|
studentMenu.add(gradeStudentOption);
|
||||||
studentMenu.add(addStudentOption);
|
studentMenu.add(addStudentOption);
|
||||||
studentMenu.add(editStudentOption);
|
studentMenu.add(editStudentOption);
|
||||||
@@ -173,33 +191,73 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
|
|
||||||
setJMenuBar(menuBar);
|
setJMenuBar(menuBar);
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
StudentManagementGUI.displayStudents();
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 1280, Short.MAX_VALUE));
|
.addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1280, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE));
|
.addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showGraduatesOptionActionPerformed(ActionEvent actionEvent) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("=================== Students =====================\n");
|
||||||
|
for (Student st : sv.getFm().getGm().getSm().getStudents()) {
|
||||||
|
if (st.isGraduated()) {
|
||||||
|
text.append("Name: ").append(st.getFullname()).append("\nGroup: ").append(st.getGroup().getName())
|
||||||
|
.append("\nGraduated: ").append("Yes");
|
||||||
|
text.append("\n===============================================\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showEnrolledOptionActionPerformed(ActionEvent actionEvent) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("=================== Students =====================\n");
|
||||||
|
for (Student st : sv.getFm().getGm().getSm().getStudents()) {
|
||||||
|
if (!st.isGraduated()) {
|
||||||
|
text.append("Name: ").append(st.getFullname()).append("\nGroup: ").append(st.getGroup().getName())
|
||||||
|
.append("\nGraduated: ").append("No");
|
||||||
|
text.append("\n===============================================\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void graduateStudentOptionActionPerformed(ActionEvent actionEvent) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
GraduateStudentForm form = new GraduateStudentForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showAllStudentsOptionActionPerformed(ActionEvent actionEvent) {
|
private void showAllStudentsOptionActionPerformed(ActionEvent actionEvent) {
|
||||||
if (checkStudent() && checkGroup() && checkFaculty()) {
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("=================== Students =====================\n");
|
||||||
for (Student st : sv.getFm().getGm().getSm().getStudents()) {
|
for (Student st : sv.getFm().getGm().getSm().getStudents()) {
|
||||||
builder.append(st.getFullname()).append("\n");
|
text.append("Name: ").append(st.getFullname()).append("\nGroup: ").append(st.getGroup().getName());
|
||||||
|
text.append("\n===============================================\n");
|
||||||
}
|
}
|
||||||
mainTextLabel.setText(builder.toString());
|
mainTextLabel.setText(text.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showAllGroupsOptionActionPerformed(ActionEvent actionEvent) {
|
private void showAllGroupsOptionActionPerformed(ActionEvent actionEvent) {
|
||||||
if (checkGroup() && checkFaculty()) {
|
if (checkGroup() && checkFaculty()) {
|
||||||
StringBuilder builder = new StringBuilder();
|
displayGroups();
|
||||||
for (Group gr : sv.getFm().getGm().getGroups())
|
|
||||||
builder.append(gr.getName()).append("\n");
|
|
||||||
mainTextLabel.setText(builder.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,11 +287,15 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
|
|
||||||
private void showAllFacultiesOptionActionPerformed(ActionEvent evt) {
|
private void showAllFacultiesOptionActionPerformed(ActionEvent evt) {
|
||||||
if (checkFaculty()) {
|
if (checkFaculty()) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder text = new StringBuilder();
|
||||||
for (Faculty fc : sv.getFm().getFaculties()) {
|
text.append("==================== Faculties ======================\n");
|
||||||
builder.append(fc.getName()).append(" ").append(fc.getAbbreviation()).append(" ").append(fc.getField().getName());
|
for (Faculty fac : sv.getFm().getFaculties()) {
|
||||||
|
text.append("Name: ").append(fac.getName()).append("\nSpecialty: ").append(fac.getField().getName())
|
||||||
|
.append("\nAbbreviation: ").append(fac.getAbbreviation())
|
||||||
|
.append("\nNumber of groups: ").append(fac.getGroups().size());
|
||||||
|
text.append("\n===============================================\n");
|
||||||
}
|
}
|
||||||
mainTextLabel.setText(builder.toString());
|
mainTextLabel.setText(text.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,4 +415,38 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void displayStudents() {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("==================== Students ======================\n");
|
||||||
|
for (Student student : sv.getFm().getGm().getSm().getStudents()) {
|
||||||
|
text.append("Name: ").append(student.getFullname()).append("\nGroup: ").append(student.getGroup().getName())
|
||||||
|
.append("\nEmail:: ").append(student.getEmail()).append("\nGraduated: ").append((student.isGraduated() ? "Yes" : "No"));
|
||||||
|
text.append("\n===============================================\n");
|
||||||
|
}
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void displayGroups() {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("==================== Groups ======================\n");
|
||||||
|
for (Group group : sv.getFm().getGm().getGroups()) {
|
||||||
|
text.append("Name: ").append(group.getName()).append("\nFaculty: ").append(group.getFaculty().getName())
|
||||||
|
.append("\nNumber of students: ").append(group.getStudents().size());
|
||||||
|
text.append("\n===============================================\n");
|
||||||
|
}
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void displayFaculties() {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("==================== Faculties ======================\n");
|
||||||
|
for (Faculty fac : sv.getFm().getFaculties()) {
|
||||||
|
text.append("Name: ").append(fac.getName()).append("\nSpecialty: ").append(fac.getField().getName())
|
||||||
|
.append("\nAbbreviation: ").append(fac.getAbbreviation())
|
||||||
|
.append("\nNumber of groups: ").append(fac.getGroups().size());
|
||||||
|
text.append("\n===============================================\n");
|
||||||
|
}
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ package org.lumijiez.gui.forms.faculty;
|
|||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.enums.StudyField;
|
import org.lumijiez.enums.StudyField;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.text.Style;
|
|
||||||
|
|
||||||
public class AddFacultyForm extends JFrame {
|
public class AddFacultyForm extends JFrame {
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
private final JComboBox<String> specialtyCombo = new JComboBox<>();
|
private final JComboBox<String> specialtyCombo = new JComboBox<>();
|
||||||
private final JTextField nameField = new JTextField();
|
private final JTextField nameField = new JTextField();
|
||||||
@@ -23,7 +23,7 @@ public class AddFacultyForm extends JFrame {
|
|||||||
private final JLabel abbreviationLabel = new JLabel();
|
private final JLabel abbreviationLabel = new JLabel();
|
||||||
private final JLabel specialtyLabel = new JLabel();
|
private final JLabel specialtyLabel = new JLabel();
|
||||||
|
|
||||||
public AddFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
public AddFacultyForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
initComponents();
|
initComponents();
|
||||||
@@ -36,11 +36,9 @@ public class AddFacultyForm extends JFrame {
|
|||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18));
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18));
|
||||||
|
|
||||||
titleLabel.setText("Add a new faculty");
|
titleLabel.setText("Add a new faculty");
|
||||||
nameField.setText("Name...");
|
|
||||||
submitButton.setText("Submit");
|
submitButton.setText("Submit");
|
||||||
cancelButton.setText("Cancel");
|
cancelButton.setText("Cancel");
|
||||||
nameLabel.setText("Name:");
|
nameLabel.setText("Name:");
|
||||||
abbreviationField.setText("Abbreviation...");
|
|
||||||
abbreviationLabel.setText("Abbreviation:");
|
abbreviationLabel.setText("Abbreviation:");
|
||||||
specialtyLabel.setText("Specialty Field:");
|
specialtyLabel.setText("Specialty Field:");
|
||||||
|
|
||||||
@@ -57,6 +55,8 @@ public class AddFacultyForm extends JFrame {
|
|||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
|
abbreviationField.setText(StudyField.getAbbrevFromString(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString()));
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
@@ -113,9 +113,12 @@ public class AddFacultyForm extends JFrame {
|
|||||||
String name = nameField.getText();
|
String name = nameField.getText();
|
||||||
String abbreviation = abbreviationField.getText();
|
String abbreviation = abbreviationField.getText();
|
||||||
StudyField specialty = StudyField.getEnum(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString());
|
StudyField specialty = StudyField.getEnum(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString());
|
||||||
Faculty newFaculty = new Faculty(name, abbreviation, specialty);
|
if (!name.isEmpty()) {
|
||||||
sv.addFaculty(newFaculty);
|
Faculty newFaculty = new Faculty(name, abbreviation, specialty);
|
||||||
this.dispose();
|
sv.addFaculty(newFaculty);
|
||||||
|
StudentManagementGUI.displayFaculties();
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void specialtyComboActionPerformed(ActionEvent evt) {
|
private void specialtyComboActionPerformed(ActionEvent evt) {
|
||||||
|
|||||||
@@ -6,17 +6,17 @@ package org.lumijiez.gui.forms.faculty;
|
|||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.enums.StudyField;
|
import org.lumijiez.enums.StudyField;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class EditFacultyForm extends JFrame {
|
public class EditFacultyForm extends JFrame {
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JTextField abbreviationField = new JTextField();
|
private final JTextField abbreviationField = new JTextField();
|
||||||
private final JLabel abbreviationLabel = new JLabel();
|
private final JLabel abbreviationLabel = new JLabel();
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
@@ -29,7 +29,7 @@ public class EditFacultyForm extends JFrame {
|
|||||||
private final JComboBox<Faculty> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private final JComboBox<StudyField> specialtyCombo;
|
private final JComboBox<StudyField> specialtyCombo;
|
||||||
|
|
||||||
public EditFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
public EditFacultyForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
@@ -152,6 +152,7 @@ public class EditFacultyForm extends JFrame {
|
|||||||
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setName(nameField.getText());
|
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setName(nameField.getText());
|
||||||
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setAbbreviation(abbreviationField.getText());
|
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setAbbreviation(abbreviationField.getText());
|
||||||
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setField(((StudyField) Objects.requireNonNull(specialtyCombo.getSelectedItem())));
|
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setField(((StudyField) Objects.requireNonNull(specialtyCombo.getSelectedItem())));
|
||||||
|
StudentManagementGUI.displayFaculties();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package org.lumijiez.gui.forms.faculty;
|
package org.lumijiez.gui.forms.faculty;
|
||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -14,14 +15,14 @@ import java.awt.event.ActionEvent;
|
|||||||
public class RemoveFacultyForm extends JFrame {
|
public class RemoveFacultyForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JComboBox<Faculty> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private final JLabel facultyLabel = new JLabel();
|
private final JLabel facultyLabel = new JLabel();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public RemoveFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
public RemoveFacultyForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
@@ -93,6 +94,7 @@ public class RemoveFacultyForm extends JFrame {
|
|||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
sv.deleteFaculty(((Faculty)facultyCombo.getSelectedItem()));
|
sv.deleteFaculty(((Faculty)facultyCombo.getSelectedItem()));
|
||||||
|
StudentManagementGUI.displayFaculties();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ import java.awt.event.ActionEvent;
|
|||||||
public class ShowFacultyForm extends JFrame {
|
public class ShowFacultyForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JComboBox<Faculty> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private final JLabel facultyLabel = new JLabel();
|
private final JLabel facultyLabel = new JLabel();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public ShowFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
public ShowFacultyForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
@@ -101,11 +101,15 @@ public class ShowFacultyForm extends JFrame {
|
|||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
Faculty fac = (Faculty) facultyCombo.getSelectedItem();
|
Faculty fac = (Faculty) facultyCombo.getSelectedItem();
|
||||||
assert fac != null;
|
assert fac != null;
|
||||||
|
builder.append("================= Faculty Info ====================\n");
|
||||||
builder.append("Name: ").append(fac.getName()).append("\n");
|
builder.append("Name: ").append(fac.getName()).append("\n");
|
||||||
builder.append("Specialty: ").append(fac.getField()).append("\n");
|
builder.append("Specialty: ").append(fac.getField()).append("\n");
|
||||||
|
builder.append("==========\n");
|
||||||
builder.append("Groups: ").append("\n");
|
builder.append("Groups: ").append("\n");
|
||||||
for (Group gr : fac.getGroups())
|
for (Group gr : fac.getGroups())
|
||||||
builder.append(gr.getName()).append("\n");
|
builder.append(gr.getName()).append("\n");
|
||||||
|
builder.append("==========\n");
|
||||||
|
builder.append("===================================================");
|
||||||
mainTextLabel.setText(builder.toString());
|
mainTextLabel.setText(builder.toString());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package org.lumijiez.gui.forms.group;
|
|||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -15,7 +16,7 @@ import java.util.Objects;
|
|||||||
public class AddGroupForm extends JFrame {
|
public class AddGroupForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
private final JTextField nameField = new JTextField();
|
private final JTextField nameField = new JTextField();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
@@ -24,7 +25,7 @@ public class AddGroupForm extends JFrame {
|
|||||||
private final JComboBox<Faculty> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private final JLabel facultyLabel = new JLabel();
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
|
||||||
public AddGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
public AddGroupForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
@@ -107,6 +108,7 @@ public class AddGroupForm extends JFrame {
|
|||||||
Group gr = new Group(nameField.getText());
|
Group gr = new Group(nameField.getText());
|
||||||
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
sv.addGroup(gr, fac);
|
sv.addGroup(gr, fac);
|
||||||
|
StudentManagementGUI.displayGroups();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.group;
|
package org.lumijiez.gui.forms.group;
|
||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -14,14 +14,14 @@ import java.awt.event.ActionEvent;
|
|||||||
|
|
||||||
public class DeleteGroupForm extends JFrame {
|
public class DeleteGroupForm extends JFrame {
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JComboBox<Group> groupCombo;
|
private final JComboBox<Group> groupCombo;
|
||||||
private final JLabel groupLabel = new JLabel();
|
private final JLabel groupLabel = new JLabel();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public DeleteGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
public DeleteGroupForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||||
@@ -94,6 +94,7 @@ public class DeleteGroupForm extends JFrame {
|
|||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
sv.deleteGroup(((Group)groupCombo.getSelectedItem()));
|
sv.deleteGroup(((Group)groupCombo.getSelectedItem()));
|
||||||
|
StudentManagementGUI.displayGroups();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package org.lumijiez.gui.forms.group;
|
|||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.enums.StudyField;
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -17,7 +17,7 @@ import java.util.Objects;
|
|||||||
public class EditGroupForm extends JFrame {
|
public class EditGroupForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JComboBox<Faculty> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private final JLabel facultyLabel = new JLabel();
|
private final JLabel facultyLabel = new JLabel();
|
||||||
@@ -27,7 +27,7 @@ public class EditGroupForm extends JFrame {
|
|||||||
private final JLabel nameLabel = new JLabel();
|
private final JLabel nameLabel = new JLabel();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
public EditGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
public EditGroupForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
@@ -131,6 +131,7 @@ public class EditGroupForm extends JFrame {
|
|||||||
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
sv.editGroup(gr, nameField.getText(), fac);
|
sv.editGroup(gr, nameField.getText(), fac);
|
||||||
|
StudentManagementGUI.displayGroups();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ import java.util.Objects;
|
|||||||
public class ShowGroupForm extends JFrame {
|
public class ShowGroupForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JComboBox<Group> groupCombo;
|
private final JComboBox<Group> groupCombo;
|
||||||
private final JLabel groupLabel = new JLabel();
|
private final JLabel groupLabel = new JLabel();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
public ShowGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
public ShowGroupForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||||
@@ -94,13 +94,18 @@ public class ShowGroupForm extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder text = new StringBuilder();
|
||||||
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
builder.append(gr.getName()).append(" ").append(gr.getFaculty().getName()).append(" \n");
|
|
||||||
for (Student st : gr.getStudents()) {
|
text.append("==================== Group Info ======================\n");
|
||||||
builder.append(st.getFullname()).append("\n");
|
text.append("=================== Group: ").append(gr.getName()).append("=====================\n");
|
||||||
|
|
||||||
|
for (Student student : gr.getStudents()) {
|
||||||
|
text.append("Name: ").append(student.getName()).append("\nEmail: ").append(student.getEmail())
|
||||||
|
.append("\nEnrol date: ").append(student.getEnrollmentDate());
|
||||||
|
text.append("\n===============================================\n");
|
||||||
}
|
}
|
||||||
mainTextLabel.setText(builder.toString());
|
mainTextLabel.setText(text.toString());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,20 @@ package org.lumijiez.gui.forms.student;
|
|||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class AddStudentForm extends JFrame {
|
public class AddStudentForm extends JFrame {
|
||||||
|
Integer[] days = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||||
|
Integer[] months = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
|
||||||
|
Integer[] years = new Integer[100];
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
private final JComboBox<Group> groupCombo;
|
private final JComboBox<Group> groupCombo;
|
||||||
@@ -30,20 +34,27 @@ public class AddStudentForm extends JFrame {
|
|||||||
private final JComboBox<Faculty> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private final JLabel groupLabel = new javax.swing.JLabel();
|
private final JLabel groupLabel = new javax.swing.JLabel();
|
||||||
private final JLabel facultyLabel = new javax.swing.JLabel();
|
private final JLabel facultyLabel = new javax.swing.JLabel();
|
||||||
private final JTextField birthYearField = new javax.swing.JTextField();
|
private final JComboBox<Integer> birthYearField;
|
||||||
private final JTextField birthDayField = new javax.swing.JTextField();
|
private final JComboBox<Integer> birthDayField;
|
||||||
private final JTextField birthMonthField = new javax.swing.JTextField();
|
private final JComboBox<Integer> birthMonthField;
|
||||||
private final JLabel surnameLabel1 = new javax.swing.JLabel();
|
private final JLabel birthYearLabel = new javax.swing.JLabel();
|
||||||
private final JLabel birthDayLabel = new javax.swing.JLabel();
|
private final JLabel birthDayLabel = new javax.swing.JLabel();
|
||||||
private final JLabel birthMonthLabel = new javax.swing.JLabel();
|
private final JLabel birthMonthLabel = new javax.swing.JLabel();
|
||||||
private final JLabel enrolDayLabel = new javax.swing.JLabel();
|
private final JLabel enrolDayLabel = new javax.swing.JLabel();
|
||||||
private final JTextField enrolDayField = new javax.swing.JTextField();
|
private final JComboBox<Integer> enrolDayField;
|
||||||
private final JTextField enrolMonthField = new javax.swing.JTextField();
|
private final JComboBox<Integer> enrolMonthField;
|
||||||
|
private final JComboBox<Integer> enrolYearField;
|
||||||
private final JLabel enrolMonthLabel = new javax.swing.JLabel();
|
private final JLabel enrolMonthLabel = new javax.swing.JLabel();
|
||||||
private final JTextField enrolYearField = new javax.swing.JTextField();
|
|
||||||
private final JLabel enrolYearLabel = new javax.swing.JLabel();
|
private final JLabel enrolYearLabel = new javax.swing.JLabel();
|
||||||
public AddStudentForm(Supervisor sv) {
|
public AddStudentForm(Supervisor sv) {
|
||||||
|
for (int i = 0; i < 100; i++) years[i] = 1970 + i;
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
|
birthDayField = new JComboBox<>(days);
|
||||||
|
birthMonthField = new JComboBox<>(months);
|
||||||
|
birthYearField = new JComboBox<>(years);
|
||||||
|
enrolDayField = new JComboBox<>(days);
|
||||||
|
enrolMonthField = new JComboBox<>(months);
|
||||||
|
enrolYearField = new JComboBox<>(years);
|
||||||
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
@@ -51,8 +62,6 @@ public class AddStudentForm extends JFrame {
|
|||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
@@ -76,21 +85,16 @@ public class AddStudentForm extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
nameField.setText("Name...");
|
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
submitButton.setText("Submit");
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
cancelButton.setText("Cancel");
|
||||||
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
nameLabel.setText("Name:");
|
nameLabel.setText("Name:");
|
||||||
|
|
||||||
surnameField.setText("Surname...");
|
|
||||||
|
|
||||||
emailField.setText("Email...");
|
|
||||||
|
|
||||||
surnameLabel.setText("Surname:");
|
surnameLabel.setText("Surname:");
|
||||||
|
|
||||||
emailLabel.setText("Email:");
|
emailLabel.setText("Email:");
|
||||||
@@ -99,13 +103,7 @@ public class AddStudentForm extends JFrame {
|
|||||||
|
|
||||||
facultyLabel.setText("Faculty:");
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
birthYearField.setText("Surname...");
|
birthYearLabel.setText("Year of Birth:");
|
||||||
|
|
||||||
birthDayField.setText("Surname...");
|
|
||||||
|
|
||||||
birthMonthField.setText("Surname...");
|
|
||||||
|
|
||||||
surnameLabel1.setText("Year of Birth:");
|
|
||||||
|
|
||||||
birthDayLabel.setText("Day of Birth:");
|
birthDayLabel.setText("Day of Birth:");
|
||||||
|
|
||||||
@@ -113,14 +111,8 @@ public class AddStudentForm extends JFrame {
|
|||||||
|
|
||||||
enrolDayLabel.setText("Day of Enrollment:");
|
enrolDayLabel.setText("Day of Enrollment:");
|
||||||
|
|
||||||
enrolDayField.setText("Surname...");
|
|
||||||
|
|
||||||
enrolMonthField.setText("Surname...");
|
|
||||||
|
|
||||||
enrolMonthLabel.setText("Month of Enrollment:");
|
enrolMonthLabel.setText("Month of Enrollment:");
|
||||||
|
|
||||||
enrolYearField.setText("Surname...");
|
|
||||||
|
|
||||||
enrolYearLabel.setText("Year of Enrollment:");
|
enrolYearLabel.setText("Year of Enrollment:");
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
@@ -180,7 +172,7 @@ public class AddStudentForm extends JFrame {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(32, 32, 32)
|
.addGap(32, 32, 32)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(surnameLabel1)
|
.addComponent(birthYearLabel)
|
||||||
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -201,8 +193,7 @@ public class AddStudentForm extends JFrame {
|
|||||||
.addGap(43, 43, 43))
|
.addGap(43, 43, 43))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(enrolYearLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(enrolYearLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addContainerGap())))))
|
.addContainerGap()))))));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -234,7 +225,7 @@ public class AddStudentForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(birthDayLabel)
|
.addComponent(birthDayLabel)
|
||||||
.addComponent(birthMonthLabel)
|
.addComponent(birthMonthLabel)
|
||||||
.addComponent(surnameLabel1))
|
.addComponent(birthYearLabel))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
@@ -254,27 +245,48 @@ public class AddStudentForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addGap(21, 21, 21))
|
.addGap(21, 21, 21)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cancelButtonActionPerformed(ActionEvent actionEvent) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
String name = nameField.getText();
|
String name = nameField.getText();
|
||||||
String surname = surnameField.getText();
|
String surname = surnameField.getText();
|
||||||
|
String email = emailField.getText();
|
||||||
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
int birthYear = Integer.parseInt(birthYearField.getText());
|
|
||||||
int birthMonth = Integer.parseInt(birthMonthField.getText());
|
int birthYear = (Integer) Objects.requireNonNull(birthYearField.getSelectedItem());
|
||||||
int birthDay = Integer.parseInt(birthDayField.getText());
|
int birthMonth = (Integer) Objects.requireNonNull(birthMonthField.getSelectedItem());
|
||||||
int enrolYear = Integer.parseInt(enrolYearField.getText());
|
int birthDay = (Integer) Objects.requireNonNull(birthDayField.getSelectedItem());
|
||||||
int enrolMonth = Integer.parseInt(enrolMonthField.getText());
|
int enrolYear = (Integer) Objects.requireNonNull(enrolYearField.getSelectedItem());
|
||||||
int enrolDay = Integer.parseInt(enrolDayField.getText());
|
int enrolMonth = (Integer) Objects.requireNonNull(enrolMonthField.getSelectedItem());
|
||||||
Date birthDate = new Date(birthYear, birthMonth, birthDay);
|
int enrolDay = (Integer) Objects.requireNonNull(enrolDayField.getSelectedItem());
|
||||||
Date enrolDate = new Date(enrolYear, enrolMonth, enrolDay);
|
|
||||||
sv.addStudent(name, surname, group, faculty, birthDate, enrolDate);
|
if (!name.isEmpty() && !surname.isEmpty() && !email.isEmpty()) {
|
||||||
this.dispose();
|
Calendar birthCalendar = Calendar.getInstance();
|
||||||
|
Calendar enrolCalendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
birthCalendar.set(Calendar.YEAR, birthYear);
|
||||||
|
birthCalendar.set(Calendar.MONTH, birthMonth - 1);
|
||||||
|
birthCalendar.set(Calendar.DAY_OF_MONTH, birthDay);
|
||||||
|
|
||||||
|
enrolCalendar.set(Calendar.YEAR, enrolYear);
|
||||||
|
enrolCalendar.set(Calendar.MONTH, enrolMonth - 1);
|
||||||
|
enrolCalendar.set(Calendar.DAY_OF_MONTH, enrolDay);
|
||||||
|
|
||||||
|
Date birthDate = birthCalendar.getTime();
|
||||||
|
Date enrolDate = enrolCalendar.getTime();
|
||||||
|
sv.addStudent(name, surname, email, group, faculty, birthDate, enrolDate);
|
||||||
|
|
||||||
|
StudentManagementGUI.displayStudents();
|
||||||
|
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package org.lumijiez.gui.forms.student;
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
import org.lumijiez.base.Student;
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -14,14 +15,14 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class DeleteStudentForm extends JFrame {
|
public class DeleteStudentForm extends JFrame {
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JComboBox<Student> studentCombo;
|
private final JComboBox<Student> studentCombo;
|
||||||
private final JLabel studentLabel = new JLabel();
|
private final JLabel studentLabel = new JLabel();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public DeleteStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
public DeleteStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||||
@@ -95,6 +96,9 @@ public class DeleteStudentForm extends JFrame {
|
|||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
sv.deleteStudent(student);
|
sv.deleteStudent(student);
|
||||||
|
|
||||||
|
StudentManagementGUI.displayStudents();
|
||||||
|
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,18 +7,22 @@ package org.lumijiez.gui.forms.student;
|
|||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.base.Student;
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class EditStudentForm extends JFrame {
|
public class EditStudentForm extends JFrame {
|
||||||
|
Integer[] days = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||||
|
Integer[] months = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
|
||||||
|
Integer[] years = new Integer[100];
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JTextField emailField = new JTextField();
|
private final JTextField emailField = new JTextField();
|
||||||
private final JLabel emailLabel = new JLabel();
|
private final JLabel emailLabel = new JLabel();
|
||||||
@@ -27,6 +31,12 @@ public class EditStudentForm extends JFrame {
|
|||||||
private final JComboBox<Group> groupCombo;
|
private final JComboBox<Group> groupCombo;
|
||||||
private final JLabel groupLabel = new JLabel();
|
private final JLabel groupLabel = new JLabel();
|
||||||
private final JTextField nameField = new JTextField();
|
private final JTextField nameField = new JTextField();
|
||||||
|
private final JComboBox<Integer> birthYearField;
|
||||||
|
private final JComboBox<Integer> birthDayField;
|
||||||
|
private final JComboBox<Integer> birthMonthField;
|
||||||
|
private final JComboBox<Integer> enrolDayField;
|
||||||
|
private final JComboBox<Integer> enrolMonthField;
|
||||||
|
private final JComboBox<Integer> enrolYearField;
|
||||||
private final JLabel nameLabel = new JLabel();
|
private final JLabel nameLabel = new JLabel();
|
||||||
private final JComboBox<Student> studentCombo;
|
private final JComboBox<Student> studentCombo;
|
||||||
private final JLabel studentLabel = new JLabel();
|
private final JLabel studentLabel = new JLabel();
|
||||||
@@ -34,10 +44,22 @@ public class EditStudentForm extends JFrame {
|
|||||||
private final JTextField surnameField = new JTextField();
|
private final JTextField surnameField = new JTextField();
|
||||||
private final JLabel surnameLabel = new JLabel();
|
private final JLabel surnameLabel = new JLabel();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JLabel birthYearLabel = new javax.swing.JLabel();
|
||||||
|
private final JLabel birthDayLabel = new javax.swing.JLabel();
|
||||||
|
private final JLabel birthMonthLabel = new javax.swing.JLabel();
|
||||||
|
private final JLabel enrolDayLabel = new javax.swing.JLabel();
|
||||||
|
private final JLabel enrolMonthLabel = new javax.swing.JLabel();
|
||||||
|
private final JLabel enrolYearLabel = new javax.swing.JLabel();
|
||||||
|
|
||||||
public EditStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
public EditStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
birthDayField = new JComboBox<>(days);
|
||||||
|
birthMonthField = new JComboBox<>(months);
|
||||||
|
birthYearField = new JComboBox<>(years);
|
||||||
|
enrolDayField = new JComboBox<>(days);
|
||||||
|
enrolMonthField = new JComboBox<>(months);
|
||||||
|
enrolYearField = new JComboBox<>(years);
|
||||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||||
@@ -51,17 +73,28 @@ public class EditStudentForm extends JFrame {
|
|||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
|
|
||||||
titleLabel.setText("Edit a student");
|
titleLabel.setText("Edit a student");
|
||||||
nameField.setText("Name...");
|
nameField.setText(((Student)studentCombo.getSelectedItem()).getName());
|
||||||
submitButton.setText("Submit");
|
submitButton.setText("Submit");
|
||||||
cancelButton.setText("Cancel");
|
cancelButton.setText("Cancel");
|
||||||
studentLabel.setText("Student:");
|
studentLabel.setText("Student:");
|
||||||
surnameField.setText("Surname...");
|
surnameField.setText(((Student)studentCombo.getSelectedItem()).getSurname());
|
||||||
emailField.setText("Email...");
|
emailField.setText(((Student)studentCombo.getSelectedItem()).getEmail());
|
||||||
nameLabel.setText("New name:");
|
nameLabel.setText("New name:");
|
||||||
emailLabel.setText("New email:");
|
emailLabel.setText("New email:");
|
||||||
groupLabel.setText("New group:");
|
groupLabel.setText("New group:");
|
||||||
facultyLabel.setText("New faculty:");
|
facultyLabel.setText("New faculty:");
|
||||||
surnameLabel.setText("New surname:");
|
surnameLabel.setText("New surname:");
|
||||||
|
// birthYearLabel.setText("Year of Birth:");
|
||||||
|
//
|
||||||
|
// birthDayLabel.setText("Day of Birth:");
|
||||||
|
//
|
||||||
|
// birthMonthLabel.setText("Month of Birth:");
|
||||||
|
//
|
||||||
|
// enrolDayLabel.setText("Day of Enrollment:");
|
||||||
|
//
|
||||||
|
// enrolMonthLabel.setText("Month of Enrollment:");
|
||||||
|
//
|
||||||
|
// enrolYearLabel.setText("Year of Enrollment:");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
@@ -69,6 +102,8 @@ public class EditStudentForm extends JFrame {
|
|||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
|
studentCombo.addActionListener(this::studentComboActionPerformed);
|
||||||
|
|
||||||
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
@@ -96,100 +131,189 @@ public class EditStudentForm extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
groupCombo.setSelectedItem(((Student)studentCombo.getSelectedItem()).getGroup());
|
||||||
|
|
||||||
|
facultyCombo.setSelectedItem(((Student) studentCombo.getSelectedItem()).getFaculty());
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(26, 26, 26)
|
.addGap(132, 132, 132)
|
||||||
.addComponent(studentLabel))
|
.addComponent(titleLabel))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(25, 25, 25)
|
.addGap(25, 25, 25)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
.addComponent(surnameLabel)
|
||||||
.addComponent(surnameLabel)
|
.addGap(142, 142, 142)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addComponent(emailLabel)))
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
.addComponent(surnameField, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
|
|
||||||
.addComponent(nameLabel)
|
|
||||||
.addComponent(nameField, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
|
|
||||||
.addComponent(studentCombo, GroupLayout.Alignment.TRAILING, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
||||||
.addGap(36, 36, 36)
|
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
||||||
.addComponent(emailLabel)
|
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(cancelButton)
|
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addComponent(submitButton))
|
|
||||||
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
||||||
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addComponent(groupLabel))
|
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
||||||
.addComponent(facultyLabel)
|
|
||||||
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))))))
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addGap(162, 162, 162)
|
|
||||||
.addComponent(titleLabel)))
|
|
||||||
.addContainerGap(24, Short.MAX_VALUE)));
|
|
||||||
|
|
||||||
layout.setVerticalGroup(
|
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(13, 13, 13)
|
.addGap(21, 21, 21)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(surnameField, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
|
||||||
|
.addComponent(nameField)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(nameLabel))
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthDayLabel))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(birthMonthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(birthMonthField))))
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addGap(67, 67, 67)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addGap(51, 51, 51))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(groupCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(34, 34, 34)
|
||||||
|
.addComponent(facultyCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(32, 32, 32)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(birthYearLabel)
|
||||||
|
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||||
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(enrolDayLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(enrolDayField))
|
||||||
|
.addGap(29, 29, 29)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(enrolMonthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(enrolMonthField, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||||
|
.addGap(55, 55, 55)))
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(enrolYearField, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||||
|
.addGap(43, 43, 43))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(enrolYearLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addContainerGap()))))));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
.addComponent(titleLabel)
|
.addComponent(titleLabel)
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
.addGap(13, 13, 13)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(studentLabel)
|
.addComponent(nameLabel)
|
||||||
.addComponent(groupLabel)
|
.addComponent(groupLabel)
|
||||||
.addComponent(facultyLabel))
|
.addComponent(facultyLabel))
|
||||||
.addGap(3, 3, 3)
|
.addGap(3, 3, 3)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(groupCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(facultyCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(12, 12, 12)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(emailLabel)
|
.addGap(11, 11, 11)
|
||||||
.addComponent(nameLabel))
|
.addComponent(surnameLabel)
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addGap(5, 5, 5))
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(emailLabel)
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
.addGap(4, 4, 4)))
|
||||||
.addComponent(surnameLabel)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addGap(3, 3, 3)
|
.addComponent(surnameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(birthDayLabel)
|
||||||
|
.addComponent(birthMonthLabel)
|
||||||
|
.addComponent(birthYearLabel))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthMonthField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(enrolDayLabel)
|
||||||
|
.addComponent(enrolMonthLabel)
|
||||||
|
.addComponent(enrolYearLabel))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(enrolDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(enrolMonthField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(enrolYearField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(36, 36, 36)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(24, Short.MAX_VALUE)));
|
.addGap(21, 21, 21)));
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cancelButtonActionPerformed(ActionEvent actionEvent) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void studentComboActionPerformed(ActionEvent actionEvent) {
|
||||||
|
surnameField.setText(((Student) Objects.requireNonNull(studentCombo.getSelectedItem())).getSurname());
|
||||||
|
emailField.setText(((Student)studentCombo.getSelectedItem()).getEmail());
|
||||||
|
nameField.setText(((Student)studentCombo.getSelectedItem()).getName());
|
||||||
|
groupCombo.setSelectedItem(((Student)studentCombo.getSelectedItem()).getGroup());
|
||||||
|
facultyCombo.setSelectedItem(((Student) studentCombo.getSelectedItem()).getFaculty());
|
||||||
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
String name = nameField.getText();
|
String name = nameField.getText();
|
||||||
String surname = surnameField.getText();
|
String surname = surnameField.getText();
|
||||||
|
String email = emailField.getText();
|
||||||
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
// int birthYear = Integer.parseInt(birthYearField.getText());
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
// int birthMonth = Integer.parseInt(birthMonthField.getText());
|
// int birthYear = (Integer) Objects.requireNonNull(birthYearField.getSelectedItem());
|
||||||
// int birthDay = Integer.parseInt(birthDayField.getText());
|
// int birthMonth = (Integer) Objects.requireNonNull(birthMonthField.getSelectedItem());
|
||||||
// int enrolYear = Integer.parseInt(enrolYearField.getText());
|
// int birthDay = (Integer) Objects.requireNonNull(birthDayField.getSelectedItem());
|
||||||
// int enrolMonth = Integer.parseInt(enrolMonthField.getText());
|
// int enrolYear = (Integer) Objects.requireNonNull(enrolYearField.getSelectedItem());
|
||||||
// int enrolDay = Integer.parseInt(enrolDayField.getText());
|
// int enrolMonth = (Integer) Objects.requireNonNull(enrolMonthField.getSelectedItem());
|
||||||
// Date birthDate = new Date(birthYear, birthMonth, birthDay);
|
// int enrolDay = (Integer) Objects.requireNonNull(enrolDayField.getSelectedItem());
|
||||||
// Date enrolDate = new Date(enrolYear, enrolMonth, enrolDay);
|
//
|
||||||
// sv.addStudent(name, surname, group, faculty, birthDate, enrolDate);
|
// Calendar birthCalendar = Calendar.getInstance();
|
||||||
|
// Calendar enrolCalendar = Calendar.getInstance();
|
||||||
|
//
|
||||||
|
// birthCalendar.set(Calendar.YEAR, birthYear);
|
||||||
|
// birthCalendar.set(Calendar.MONTH, birthMonth - 1);
|
||||||
|
// birthCalendar.set(Calendar.DAY_OF_MONTH, birthDay);
|
||||||
|
//
|
||||||
|
// enrolCalendar.set(Calendar.YEAR, enrolYear);
|
||||||
|
// enrolCalendar.set(Calendar.MONTH, enrolMonth - 1);
|
||||||
|
// enrolCalendar.set(Calendar.DAY_OF_MONTH, enrolDay);
|
||||||
|
//
|
||||||
|
// Date birthDate = birthCalendar.getTime();
|
||||||
|
// Date enrolDate = enrolCalendar.getTime();
|
||||||
|
|
||||||
|
if (!name.isEmpty() && !surname.isEmpty() && !email.isEmpty()) {
|
||||||
|
sv.editStudent(student, name, surname, email, group, faculty /*, birthDate, enrolDate*/);
|
||||||
|
}
|
||||||
|
|
||||||
|
StudentManagementGUI.displayStudents();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelButtonActionPerformed(ActionEvent evt) {
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,28 +4,36 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.student;
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Grade;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.enums.Subjects;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class GradeStudentForm extends JFrame {
|
public class GradeStudentForm extends JFrame {
|
||||||
|
Integer[] grades = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JTextField gradeField = new JTextField();
|
private final JComboBox<Subjects> subjectCombo;
|
||||||
private final JLabel gradeLabel = new JLabel();
|
private final JLabel gradeLabel = new JLabel();
|
||||||
private final JComboBox<String> studentCombo = new JComboBox<>();
|
private final JComboBox<Student> studentCombo;
|
||||||
|
private final JComboBox<Integer> gradeCombo;
|
||||||
private final JLabel studentLabel = new JLabel();
|
private final JLabel studentLabel = new JLabel();
|
||||||
private final JComboBox<String> subjectCombo = new JComboBox<>();
|
|
||||||
private final JLabel subjectLabel = new JLabel();
|
private final JLabel subjectLabel = new JLabel();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public GradeStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
public GradeStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.subjectCombo = new JComboBox<>(Subjects.values());
|
||||||
|
this.gradeCombo = new JComboBox<>(grades);
|
||||||
|
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +46,6 @@ public class GradeStudentForm extends JFrame {
|
|||||||
titleLabel.setText("Grade a student");
|
titleLabel.setText("Grade a student");
|
||||||
studentLabel.setText("Student:");
|
studentLabel.setText("Student:");
|
||||||
subjectLabel.setText("Subject:");
|
subjectLabel.setText("Subject:");
|
||||||
gradeField.setText("Grade...");
|
|
||||||
submitButton.setText("Submit");
|
submitButton.setText("Submit");
|
||||||
gradeLabel.setText("Grade:");
|
gradeLabel.setText("Grade:");
|
||||||
cancelButton.setText("Cancel");
|
cancelButton.setText("Cancel");
|
||||||
@@ -49,8 +56,23 @@ public class GradeStudentForm extends JFrame {
|
|||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
subjectCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Student)
|
||||||
|
setText(((Student) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
subjectCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Subjects)
|
||||||
|
setText(((Subjects) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -66,7 +88,7 @@ public class GradeStudentForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE)
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(studentLabel)
|
.addComponent(studentLabel)
|
||||||
.addComponent(gradeField, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE))
|
.addComponent(gradeCombo, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
|
||||||
@@ -103,7 +125,7 @@ public class GradeStudentForm extends JFrame {
|
|||||||
.addComponent(gradeLabel)
|
.addComponent(gradeLabel)
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(gradeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(gradeCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(30, Short.MAX_VALUE)));
|
.addContainerGap(30, Short.MAX_VALUE)));
|
||||||
@@ -111,6 +133,21 @@ public class GradeStudentForm extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
Subjects subject = Subjects.getEnum(Objects.requireNonNull(subjectCombo.getSelectedItem()).toString());
|
||||||
|
int intGrade = (Integer) Objects.requireNonNull(gradeCombo.getSelectedItem());
|
||||||
|
Grade grade = new Grade(subject, intGrade);
|
||||||
|
sv.addGrade(student, grade);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("====================================\n");
|
||||||
|
builder.append("Grades for ").append(student.getFullname()).append(" from ").append(student.getGroup().getName()).append(":\n");
|
||||||
|
for (Grade gr : student.getGrades()) {
|
||||||
|
builder.append(gr.getSubject()).append(": ").append(gr.getGrade()).append("\n");
|
||||||
|
}
|
||||||
|
builder.append("====================================\n");
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
|
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
|
||||||
|
*/
|
||||||
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class GraduateStudentForm extends JFrame {
|
||||||
|
private final Supervisor sv;
|
||||||
|
private final JTextArea mainTextLabel;
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JComboBox<Student> studentCombo;
|
||||||
|
private final JLabel studentLabel = new JLabel();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
|
public GraduateStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
|
this.sv = sv;
|
||||||
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", 0, 18)); // NOI18N
|
||||||
|
titleLabel.setText("Graduate a Student");
|
||||||
|
|
||||||
|
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Student)
|
||||||
|
setText(((Student) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
|
submitButton.setBackground(new Color(204, 255, 204));
|
||||||
|
cancelButton.setBackground(new Color(255, 204, 204));
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(21, 21, 21)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(studentLabel))
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addContainerGap(26, Short.MAX_VALUE))
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(51, 51, 51)));
|
||||||
|
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addComponent(studentLabel)
|
||||||
|
.addGap(3, 3, 3)
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(submitButton)
|
||||||
|
.addComponent(cancelButton))
|
||||||
|
.addContainerGap(26, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
student.setGraduated(true);
|
||||||
|
StudentManagementGUI.displayStudents();
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelButtonActionPerformed(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,24 +4,28 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.student;
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ShowStudentForm extends JFrame {
|
public class ShowStudentForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JComboBox<String> studentCombo = new JComboBox<>();
|
private final JComboBox<Student> studentCombo;
|
||||||
private final JLabel studentLabel = new JLabel();
|
private final JLabel studentLabel = new JLabel();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public ShowStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
public ShowStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +46,14 @@ public class ShowStudentForm extends JFrame {
|
|||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Student)
|
||||||
|
setText(((Student) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -85,6 +96,20 @@ public class ShowStudentForm extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
|
||||||
|
text.append("==================== Student Info ======================\n");
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
|
text.append("Name: ").append(student.getFullname()).append(" \n")
|
||||||
|
.append("Group: ").append(student.getGroup().getName())
|
||||||
|
.append(" \nFaculty: ").append(student.getFaculty().getName())
|
||||||
|
.append(" \nEmail: ").append(student.getEmail()).append(" \n")
|
||||||
|
.append("Bday: ").append(student.getDateOfBirth())
|
||||||
|
.append("\nEnrol date: ").append(student.getEnrollmentDate())
|
||||||
|
.append("\nGraduated: ").append(student.isGraduated());
|
||||||
|
text.append("\n==================================================");
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,24 +4,29 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.student;
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Grade;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ShowStudentGradesForm extends JFrame {
|
public class ShowStudentGradesForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JTextArea mainTextLabel;
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
private final JComboBox<String> studentCombo = new JComboBox<>();
|
private final JComboBox<Student> studentCombo;
|
||||||
private final JLabel studentLabel = new JLabel();
|
private final JLabel studentLabel = new JLabel();
|
||||||
private final JButton submitButton = new JButton();
|
private final JButton submitButton = new JButton();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public ShowStudentGradesForm(Supervisor sv, JLabel mainTextLabel) {
|
public ShowStudentGradesForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +47,14 @@ public class ShowStudentGradesForm extends JFrame {
|
|||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Student)
|
||||||
|
setText(((Student) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -85,6 +97,15 @@ public class ShowStudentGradesForm extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("====================================\n");
|
||||||
|
builder.append("Grades for ").append(student.getFullname()).append(" from ").append(student.getGroup().getName()).append(":\n");
|
||||||
|
for (Grade grade : student.getGrades()) {
|
||||||
|
builder.append(grade.getSubject()).append(": ").append(grade.getGrade()).append("\n");
|
||||||
|
}
|
||||||
|
builder.append("====================================\n");
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,11 @@ import java.util.List;
|
|||||||
public class FacultyManager implements Serializable {
|
public class FacultyManager implements Serializable {
|
||||||
|
|
||||||
private final StudentManager sm = new StudentManager();
|
private final StudentManager sm = new StudentManager();
|
||||||
|
|
||||||
private final GroupManager gm = new GroupManager(sm);
|
private final GroupManager gm = new GroupManager(sm);
|
||||||
|
|
||||||
private final List<Faculty> faculties = new ArrayList<>();
|
private final List<Faculty> faculties = new ArrayList<>();
|
||||||
|
|
||||||
public Faculty getFaculty(String facultyName) {
|
|
||||||
for (Faculty fc : faculties)
|
|
||||||
if (fc.getName().equals(facultyName)) return fc;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GroupManager getGm() {
|
public GroupManager getGm() {
|
||||||
return gm;
|
return gm;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,8 @@ public class GroupManager implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final StudentManager sm;
|
private final StudentManager sm;
|
||||||
private final List<Group> groups = new ArrayList<>();
|
|
||||||
|
|
||||||
public Group getGroup(String groupName) {
|
private final List<Group> groups = new ArrayList<>();
|
||||||
for (Group group : groups)
|
|
||||||
if (group.getName().equals(groupName)) return group;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addGroup(Group group) {
|
public void addGroup(Group group) {
|
||||||
groups.add(group);
|
groups.add(group);
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
package org.lumijiez.managers;
|
package org.lumijiez.managers;
|
||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
|
||||||
import org.lumijiez.base.Group;
|
|
||||||
import org.lumijiez.base.Student;
|
import org.lumijiez.base.Student;
|
||||||
import org.lumijiez.util.FullStudentData;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static org.lumijiez.enums.StudyField.DEFAULT_UNASSIGNED;
|
|
||||||
|
|
||||||
public class StudentManager implements Serializable {
|
public class StudentManager implements Serializable {
|
||||||
private final List<Student> students = new ArrayList<>();
|
private final List<Student> students = new ArrayList<>();
|
||||||
@@ -23,13 +17,6 @@ public class StudentManager implements Serializable {
|
|||||||
return students;
|
return students;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Student getStudent(FullStudentData data) {
|
|
||||||
for (Student st : students) {
|
|
||||||
if (st.getFSD().equals(data)) return st;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteStudent(Student student) {
|
public void deleteStudent(Student student) {
|
||||||
students.remove(student);
|
students.remove(student);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ package org.lumijiez.managers;
|
|||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.base.Grade;
|
import org.lumijiez.base.Grade;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.util.FullStudentData;
|
|
||||||
import org.lumijiez.base.Student;
|
import org.lumijiez.base.Student;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Supervisor implements Serializable {
|
public class Supervisor implements Serializable {
|
||||||
private final FacultyManager fm;
|
private final FacultyManager fm;
|
||||||
@@ -31,6 +29,10 @@ public class Supervisor implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addGrade(Student student, Grade grade) {
|
||||||
|
student.addGrade(grade);
|
||||||
|
}
|
||||||
|
|
||||||
public void editGroup(Group group, String name, Faculty faculty) {
|
public void editGroup(Group group, String name, Faculty faculty) {
|
||||||
group.setName(name);
|
group.setName(name);
|
||||||
Faculty oldFac = group.getFaculty();
|
Faculty oldFac = group.getFaculty();
|
||||||
@@ -38,6 +40,7 @@ public class Supervisor implements Serializable {
|
|||||||
faculty.addGroup(group);
|
faculty.addGroup(group);
|
||||||
oldFac.getGroups().remove(group);
|
oldFac.getGroups().remove(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteGroup(Group group) {
|
public void deleteGroup(Group group) {
|
||||||
getFm().getGm().deleteGroup(group);
|
getFm().getGm().deleteGroup(group);
|
||||||
for (Student st : group.getStudents()) {
|
for (Student st : group.getStudents()) {
|
||||||
@@ -45,10 +48,22 @@ public class Supervisor implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStudent(String name, String surname, Group group, Faculty faculty, Date birth, Date enrol) {
|
public void addStudent(String name, String surname, String email, Group group, Faculty faculty, Date birth, Date enrol) {
|
||||||
Student newStudent = new Student(name, surname, group, faculty, birth, enrol);
|
Student newStudent = new Student(name, surname, email, group, faculty, birth, enrol);
|
||||||
getFm().getGm().getSm().addStudent(newStudent);
|
getFm().getGm().getSm().addStudent(newStudent);
|
||||||
group.addStudent(newStudent);
|
}
|
||||||
|
|
||||||
|
public void editStudent(Student student, String name, String surname, String email, Group group, Faculty faculty) {
|
||||||
|
student.getGroup().deleteStudent(student);
|
||||||
|
student.setName(name);
|
||||||
|
student.setSurname(surname);
|
||||||
|
student.setFullname(name + " " + surname);
|
||||||
|
student.setEmail(email);
|
||||||
|
student.setGroup(group);
|
||||||
|
group.addStudent(student);
|
||||||
|
student.setFaculty(faculty);
|
||||||
|
student.setDateOfBirth(student.getDateOfBirth());
|
||||||
|
student.setEnrollmentDate(student.getEnrollmentDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGroup(Group group, Faculty faculty) {
|
public void addGroup(Group group, Faculty faculty) {
|
||||||
@@ -62,54 +77,7 @@ public class Supervisor implements Serializable {
|
|||||||
getFm().getGm().getSm().deleteStudent(st);
|
getFm().getGm().getSm().deleteStudent(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStudentsText() {
|
|
||||||
StringBuilder info = new StringBuilder();
|
|
||||||
for (Student st : fm.getGm().getSm().getStudents()) {
|
|
||||||
info.append(st.getFullname()).append(" ").append(st.getGroup().getName()).append("\n");
|
|
||||||
}
|
|
||||||
return info.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGradesText(FullStudentData data) {
|
|
||||||
StringBuilder info = new StringBuilder();
|
|
||||||
for (Grade gr : fm.getGm().getSm().getStudent(data).getGrades()) {
|
|
||||||
info.append(gr.getSubject()).append(" ").append(gr.getGrade());
|
|
||||||
}
|
|
||||||
return info.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGroupsText() {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (Group gr : fm.getGm().getGroups())
|
|
||||||
builder.append(gr.getName()).append("\n");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFacultiesText() {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (Faculty fc : fm.getFaculties())
|
|
||||||
builder.append(fc.getName()).append("\n");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FacultyManager getFm() {
|
public FacultyManager getFm() {
|
||||||
return fm;
|
return fm;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void changeGroup(NameSurnameGroup NSG, String groupName) {
|
|
||||||
// Group gr = groupManager.findGroup(groupName);
|
|
||||||
// groupManager.getGroup(groupName).getStudent(NSG.name(), NSG.surname()).setGroup(gr);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void addStudent(NameSurnameGroup NSG) {
|
|
||||||
// Group currentGroup = groupManager.getGroup(NSG.group());
|
|
||||||
// currentGroup.addStudent(new Student(NSG.name(), NSG.surname(), currentGroup));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void addGrade(NameSurnameGroup NSG, Grade grade) {
|
|
||||||
// Student student = groupManager.getGroup(NSG.group()).getStudent(NSG.name(), NSG.surname());
|
|
||||||
// student.addGrade(grade);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
package org.lumijiez.util;
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
// Helper class for easier management of names, surnames, and groups
|
|
||||||
public class FullStudentData implements Serializable {
|
|
||||||
private final String name;
|
|
||||||
private final String surname;
|
|
||||||
private final String groupName;
|
|
||||||
|
|
||||||
private final String facultyName;
|
|
||||||
|
|
||||||
public FullStudentData(String name, String surname, String groupName, String facultyName) {
|
|
||||||
this.name = name;
|
|
||||||
this.surname = surname;
|
|
||||||
this.groupName = groupName;
|
|
||||||
this.facultyName = facultyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String surname() {
|
|
||||||
return surname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String group() {
|
|
||||||
return groupName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String faculty() {
|
|
||||||
return facultyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(FullStudentData data) {
|
|
||||||
return this.name.equals(data.name())
|
|
||||||
&& this.surname.equals(data.surname())
|
|
||||||
&& this.groupName.equals(data.group())
|
|
||||||
&& this.facultyName.equals(data.faculty());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return name + " " + surname + " " + groupName + " " + facultyName + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user