Implemented UI, fixed serialization inconsistency

This commit is contained in:
2023-09-25 20:30:04 +03:00
parent 24d671f765
commit b703d8f658
12 changed files with 134 additions and 109 deletions

View File

@@ -1,14 +1,14 @@
package org.lumijiez.gui.forms;
import org.lumijiez.base.Grade;
import org.lumijiez.util.NameSurnameGroup;
import org.lumijiez.managers.Supervisor;
import org.lumijiez.util.FullStudentData;
import javax.swing.*;
import java.awt.*;
public class AddGradeForm extends JFrame {
public AddGradeForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
public AddGradeForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
this.setTitle("Add Grade");
this.setSize(400, 300);
this.setLocation(centerX, centerY);
@@ -21,6 +21,8 @@ public class AddGradeForm extends JFrame {
JTextField surnameField = new JTextField();
JLabel groupLabel = new JLabel("Group:");
JTextField groupField = new JTextField();
JLabel facultyLabel = new JLabel("Faculty:");
JTextField facultyField = new JTextField();
JLabel subjectLabel = new JLabel("Subject:");
JTextField subjectField = new JTextField();
JLabel gradeLabel = new JLabel("Grade:");
@@ -28,12 +30,15 @@ public class AddGradeForm extends JFrame {
JButton submitButton = new JButton("Submit");
formPanel.add(nameLabel);
formPanel.add(nameField);
formPanel.add(surnameLabel);
formPanel.add(surnameField);
formPanel.add(groupLabel);
formPanel.add(groupField);
formPanel.add(facultyLabel);
formPanel.add(facultyField);
formPanel.add(subjectLabel);
formPanel.add(subjectField);
formPanel.add(gradeLabel);
@@ -48,10 +53,11 @@ public class AddGradeForm extends JFrame {
String group = groupField.getText();
String subject = subjectField.getText();
String grade = gradeField.getText();
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !subject.isEmpty() && !grade.isEmpty()) {
studentManager.addGrade(new NameSurnameGroup(name, surname, group), new Grade(subject, Integer.parseInt(grade)));
outputTextArea.setText("===== Students =====\n" + studentManager.getStudentsText());
String faculty = facultyField.getText();
FullStudentData data = new FullStudentData(name, surname, group, faculty);
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !subject.isEmpty() && !grade.isEmpty() && !faculty.isEmpty()) {
sv.getFm().getGm().getSm().getStudent(data).addGrade(new Grade(subject, Integer.parseInt(grade)));
outputTextArea.setText("===== Students =====\n" + sv.getStudentsText());
this.dispose();
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
});

View File

@@ -1,13 +1,13 @@
package org.lumijiez.gui.forms;
import org.lumijiez.util.NameSurnameGroup;
import org.lumijiez.managers.Supervisor;
import org.lumijiez.util.FullStudentData;
import javax.swing.*;
import java.awt.*;
public class AddStudentForm extends JFrame {
public AddStudentForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
public AddStudentForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
this.setTitle("Add Student");
this.setSize(400, 300);
this.setLocation(centerX, centerY);
@@ -20,6 +20,8 @@ public class AddStudentForm extends JFrame {
JTextField surnameField = new JTextField();
JLabel groupLabel = new JLabel("Group:");
JTextField groupField = new JTextField();
JLabel facultyLabel = new JLabel("Faculty:");
JTextField facultyField = new JTextField();
JButton submitButton = new JButton("Submit");
formPanel.add(nameLabel);
@@ -28,6 +30,8 @@ public class AddStudentForm extends JFrame {
formPanel.add(surnameField);
formPanel.add(groupLabel);
formPanel.add(groupField);
formPanel.add(facultyLabel);
formPanel.add(facultyField);
formPanel.add(submitButton);
this.add(formPanel);
@@ -36,9 +40,11 @@ public class AddStudentForm extends JFrame {
String name = nameField.getText();
String surname = surnameField.getText();
String group = groupField.getText();
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty()) {
studentManager.addStudent(new NameSurnameGroup(name, surname, group));
outputTextArea.setText("===== Students =====\n" + studentManager.getStudentsText());
String faculty = facultyField.getText();
FullStudentData data = new FullStudentData(name, surname, group, faculty);
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !faculty.isEmpty()) {
sv.getFm().getGm().getSm().addStudent(data);
outputTextArea.setText("===== Students =====\n" + sv.getStudentsText());
this.dispose();
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
});

View File

@@ -1,13 +1,13 @@
package org.lumijiez.gui.forms;
import org.lumijiez.util.NameSurnameGroup;
import org.lumijiez.managers.Supervisor;
import org.lumijiez.util.FullStudentData;
import javax.swing.*;
import java.awt.*;
public class ChangeGroupForm extends JFrame {
public ChangeGroupForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
public ChangeGroupForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
this.setTitle("Change Group");
this.setSize(400, 300);
this.setLocation(centerX, centerY);
@@ -20,6 +20,8 @@ public class ChangeGroupForm extends JFrame {
JTextField surnameField = new JTextField();
JLabel groupLabel = new JLabel("Group:");
JTextField groupField = new JTextField();
JLabel facultyLabel = new JLabel("Faculty:");
JTextField facultyField = new JTextField();
JLabel newgroupLabel = new JLabel("New Group:");
JTextField newgroupField = new JTextField();
JButton submitButton = new JButton("Submit");
@@ -30,6 +32,8 @@ public class ChangeGroupForm extends JFrame {
formPanel.add(surnameField);
formPanel.add(groupLabel);
formPanel.add(groupField);
formPanel.add(facultyLabel);
formPanel.add(facultyField);
formPanel.add(newgroupLabel);
formPanel.add(newgroupField);
formPanel.add(submitButton);
@@ -41,9 +45,11 @@ public class ChangeGroupForm extends JFrame {
String surname = surnameField.getText();
String group = groupField.getText();
String newgroup = newgroupField.getText();
String faculty = facultyField.getText();
FullStudentData data = new FullStudentData(name, surname, group, faculty);
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !newgroup.isEmpty()) {
studentManager.changeGroup(new NameSurnameGroup(name, surname, group), newgroup);
outputTextArea.setText("===== Groups =====\n" + studentManager.getGroupsText());
//studentManager.changeGroup(new NameSurnameGroup(name, surname, group), newgroup);
outputTextArea.setText("===== Groups =====\n" + sv.getGroupsText());
this.dispose();
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
});

View File

@@ -1,13 +1,13 @@
package org.lumijiez.gui.forms;
import org.lumijiez.util.NameSurnameGroup;
import org.lumijiez.managers.Supervisor;
import org.lumijiez.util.FullStudentData;
import javax.swing.*;
import java.awt.*;
public class DeleteStudentForm extends JFrame {
public DeleteStudentForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
public DeleteStudentForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
this.setTitle("Delete Student");
this.setSize(400, 300);
this.setLocation(centerX, centerY);
@@ -20,6 +20,8 @@ public class DeleteStudentForm extends JFrame {
JTextField surnameField = new JTextField();
JLabel groupLabel = new JLabel("Group:");
JTextField groupField = new JTextField();
JLabel facultyLabel = new JLabel("Faculty:");
JTextField facultyField = new JTextField();
JButton submitButton = new JButton("Submit");
formPanel.add(nameLabel);
@@ -28,6 +30,8 @@ public class DeleteStudentForm extends JFrame {
formPanel.add(surnameField);
formPanel.add(groupLabel);
formPanel.add(groupField);
formPanel.add(facultyLabel);
formPanel.add(facultyField);
formPanel.add(submitButton);
this.add(formPanel);
@@ -36,9 +40,11 @@ public class DeleteStudentForm extends JFrame {
String name = nameField.getText();
String surname = surnameField.getText();
String group = groupField.getText();
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty()) {
studentManager.removeStudent(new NameSurnameGroup(name, surname, group));
outputTextArea.setText("===== Students =====\n" + studentManager.getStudentsText());
String faculty = facultyField.getText();
FullStudentData data = new FullStudentData(name, surname, group, faculty);
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !faculty.isEmpty()) {
sv.getFm().getGm().getSm().deleteStudent(data);
outputTextArea.setText("===== Students =====\n" + sv.getStudentsText());
this.dispose();
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
});

View File

@@ -1,13 +1,13 @@
package org.lumijiez.gui.forms;
import org.lumijiez.util.NameSurnameGroup;
import org.lumijiez.util.FullStudentData;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
public class ShowGradesForm extends JFrame {
public ShowGradesForm(int centerX, int centerY, Supervisor studentManager, JTextArea outputTextArea) {
public ShowGradesForm(int centerX, int centerY, Supervisor sv, JTextArea outputTextArea) {
this.setTitle("Show Grades Student");
this.setSize(400, 300);
this.setLocation(centerX, centerY);
@@ -20,6 +20,8 @@ public class ShowGradesForm extends JFrame {
JTextField surnameField = new JTextField();
JLabel groupLabel = new JLabel("Group:");
JTextField groupField = new JTextField();
JLabel facultyLabel = new JLabel("Faculty:");
JTextField facultyField = new JTextField();
JButton submitButton = new JButton("Submit");
formPanel.add(nameLabel);
@@ -28,6 +30,8 @@ public class ShowGradesForm extends JFrame {
formPanel.add(surnameField);
formPanel.add(groupLabel);
formPanel.add(groupField);
formPanel.add(facultyLabel);
formPanel.add(facultyField);
formPanel.add(submitButton);
this.add(formPanel);
@@ -36,9 +40,10 @@ public class ShowGradesForm extends JFrame {
String name = nameField.getText();
String surname = surnameField.getText();
String group = groupField.getText();
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty()) {
NameSurnameGroup nsg = new NameSurnameGroup(name, surname, group);
outputTextArea.setText("===== Grades =====\n" + name + " " + surname + "\n" + studentManager.getGradesText(nsg));
String faculty = facultyField.getText();
FullStudentData data = new FullStudentData(name, surname, group, faculty);
if (!name.isEmpty() && !surname.isEmpty() && !group.isEmpty() && !faculty.isEmpty()) {
outputTextArea.setText("===== Grades =====\n" + name + " " + surname + "\n" + sv.getGradesText(data));
this.dispose();
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
});