Implemented all methods marked with WIP

This commit is contained in:
2023-09-26 22:25:21 +03:00
parent 120669d859
commit 5253bc2947
23 changed files with 908 additions and 648 deletions

View File

@@ -3,6 +3,7 @@ package org.lumijiez.base;
import org.lumijiez.enums.StudyField;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Faculty implements Serializable {
@@ -15,7 +16,7 @@ public class Faculty implements Serializable {
private String name;
private String abbreviation;
private List<Group> groups;
private List<Group> groups = new ArrayList<>();
private StudyField field;
public void addGroup(Group group) {
@@ -54,4 +55,9 @@ public class Faculty implements Serializable {
this.field = field;
}
@Override
public String toString() {
return getName();
}
}

View File

@@ -54,4 +54,9 @@ public class Group implements Serializable {
}
return null;
}
@Override
public String toString() {
return name;
}
}

View File

@@ -9,11 +9,14 @@ import java.util.List;
public class Student implements Serializable {
public Student(String name, String surname, Group group, Faculty faculty) {
public Student(String name, String surname, Group group, Faculty faculty, Date birth, Date enrol) {
this.name = name;
this.surname = surname;
this.fullname = name + " " + surname;
this.group = group;
this.faculty = faculty;
this.dateOfBirth = birth;
this.enrollmentDate = enrol;
this.FSD = new FullStudentData(name, surname, group.getName(), faculty.getName());
}
@@ -116,4 +119,9 @@ public class Student implements Serializable {
this.dateOfBirth = dateOfBirth;
}
@Override
public String toString() {
return fullname;
}
}

View File

@@ -14,7 +14,7 @@ public class DataDeserializer {
if (serializedFile.exists()) {
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(serializedFile))) {
manager = (Supervisor) ois.readObject();
System.out.println("Manager object deserialized successfully.");
System.out.println("Supervisor object deserialized successfully.");
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}

View File

@@ -11,7 +11,7 @@ public class DataSerializer {
public static void serialize(Supervisor manager) {
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("manager.ser"))) {
oos.writeObject(manager);
System.out.println("Manager object serialized successfully.");
System.out.println("Supervisor object serialized successfully.");
} catch (IOException e) {
e.printStackTrace();
}

View File

@@ -46,4 +46,9 @@ public enum StudyField implements Serializable {
public static List<StudyField> getAllEnums() {
return Arrays.asList(values());
}
@Override
public String toString() {
return getName();
}
}

View File

@@ -5,6 +5,8 @@
package org.lumijiez.gui;
import org.lumijiez.base.Faculty;
import org.lumijiez.base.Group;
import org.lumijiez.base.Student;
import org.lumijiez.data.DataDeserializer;
import org.lumijiez.data.DataSerializer;
import org.lumijiez.gui.forms.faculty.AddFacultyForm;
@@ -12,6 +14,7 @@ import org.lumijiez.gui.forms.faculty.EditFacultyForm;
import org.lumijiez.gui.forms.faculty.RemoveFacultyForm;
import org.lumijiez.gui.forms.faculty.ShowFacultyForm;
import org.lumijiez.gui.forms.group.AddGroupForm;
import org.lumijiez.gui.forms.group.DeleteGroupForm;
import org.lumijiez.gui.forms.group.EditGroupForm;
import org.lumijiez.gui.forms.group.ShowGroupForm;
import org.lumijiez.gui.forms.student.*;
@@ -24,44 +27,68 @@ import java.awt.event.WindowEvent;
public class StudentManagementGUI extends JFrame {
private Supervisor sv;
JLabel mainTextLabel = new JLabel();
private final JLabel mainTextLabel = new JLabel();
private final JMenuBar menuBar = new JMenuBar();
private final JMenu fileMenu = new JMenu();
private final JMenuItem loadBatchOption = new JMenuItem();
private final JMenuItem saveAsOption = new JMenuItem();
private final JMenuItem saveAndExitOption = new JMenuItem();
private final JMenuItem settingsOption = new JMenuItem();
private final JMenu studentMenu = new JMenu();
private final JMenuItem showAllStudentsOption = new JMenuItem();
private final JMenuItem showParticularStudentOption = new JMenuItem();
private final JMenuItem showStudentGrade = new JMenuItem();
private final JPopupMenu.Separator studentSeparator = new JPopupMenu.Separator();
private final JMenuItem gradeStudentOption = new JMenuItem();
private final JMenuItem addStudentOption = new JMenuItem();
private final JMenuItem editStudentOption = new JMenuItem();
private final JMenuItem deleteStudentOption = new JMenuItem();
private final JMenu groupMenu = new JMenu();
private final JMenuItem showAllGroupsOption = new JMenuItem();
private final JMenuItem showParticularGroupOption = new JMenuItem();
private final JPopupMenu.Separator groupSeparator = new JPopupMenu.Separator();
private final JMenuItem addGroupOption = new JMenuItem();
private final JMenuItem editGroupOption = new JMenuItem();
private final JMenuItem deleteGroupOption = new JMenuItem();
private final JMenu facultyMenu = new JMenu();
private final JMenuItem showAllFacultiesOption = new JMenuItem();
private final JMenuItem showParticularFacultyOption = new JMenuItem();
private final JPopupMenu.Separator facultySeparator = new JPopupMenu.Separator();
private final JMenuItem addFacultyOption = new JMenuItem();
private final JMenuItem editFacultyOption = new JMenuItem();
private final JMenuItem removeFacultyOption = new JMenuItem();
public StudentManagementGUI() {
this.sv = sv;
initComponents();
this.sv = DataDeserializer.deserialize();
initComponents();
}
private void initComponents() {
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu();
JMenuItem loadBatchOption = new JMenuItem();
JMenuItem saveAsOption = new JMenuItem();
JMenuItem saveAndExitOption = new JMenuItem();
JMenuItem settingsOption = new JMenuItem();
JMenu studentMenu = new JMenu();
JMenuItem showAllStudentsOption = new JMenuItem();
JMenuItem showParticularStudentOption = new JMenuItem();
JMenuItem showStudentGrade = new JMenuItem();
JPopupMenu.Separator studentSeparator = new JPopupMenu.Separator();
JMenuItem gradeStudentOption = new JMenuItem();
JMenuItem addStudentOption = new JMenuItem();
JMenuItem editStudentOption = new JMenuItem();
JMenuItem deleteStudentOption = new JMenuItem();
JMenu groupMenu = new JMenu();
JMenuItem showAllGroupsOption = new JMenuItem();
JMenuItem showParticularGroupOption = new JMenuItem();
JPopupMenu.Separator groupSeparator = new JPopupMenu.Separator();
JMenuItem addGroupOption = new JMenuItem();
JMenuItem editGroupOption = new JMenuItem();
JMenuItem deleteGroupOption = new JMenuItem();
JMenu facultyMenu = new JMenu();
JMenuItem showAllFacultiesOption = new JMenuItem();
JMenuItem showParticularFacultyOption = new JMenuItem();
JPopupMenu.Separator facultySeparator = new JPopupMenu.Separator();
JMenuItem addFacultyOption = new JMenuItem();
JMenuItem editFacultyOption = new JMenuItem();
JMenuItem removeFacultyOption = new JMenuItem();
fileMenu.setText("File");
loadBatchOption.setText("Load Batch File");
saveAsOption.setText("Save As File");
saveAndExitOption.setText("Save And Exit");
settingsOption.setText("Settings");
studentMenu.setText("Student Options");
showAllStudentsOption.setText("Show All Students");
showParticularStudentOption.setText("Show Student");
showStudentGrade.setText("Show Student Grades");
gradeStudentOption.setText("Grade Student");
addStudentOption.setText("Add Student");
editStudentOption.setText("Edit Student");
deleteStudentOption.setText("Delete Student");
groupMenu.setText("Group Options");
showAllGroupsOption.setText("Show All Groups");
showParticularGroupOption.setText("Show Group");
addGroupOption.setText("Add Group");
editGroupOption.setText("Edit Group");
deleteGroupOption.setText("Delete Group");
facultyMenu.setText("Faculty Options");
showAllFacultiesOption.setText("Show Faculties");
showParticularFacultyOption.setText("Show A Faculty");
addFacultyOption.setText("Add Faculty");
removeFacultyOption.setText("Remove Faculty");
editFacultyOption.setText("Edit Faculty");
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
@@ -82,103 +109,66 @@ public class StudentManagementGUI extends JFrame {
}
});
fileMenu.setText("File");
loadBatchOption.setText("Load Batch File");
loadBatchOption.addActionListener(this::loadBatchOptionActionPerformed);
fileMenu.add(loadBatchOption);
saveAsOption.setText("Save As File");
saveAsOption.addActionListener(this::saveAsOptionActionPerformed);
fileMenu.add(saveAsOption);
saveAndExitOption.setText("Save And Exit");
saveAndExitOption.addActionListener(this::saveAndExitOptionActionPerformed);
fileMenu.add(saveAndExitOption);
settingsOption.setText("Settings");
fileMenu.add(loadBatchOption);
fileMenu.add(saveAsOption);
fileMenu.add(saveAndExitOption);
fileMenu.add(settingsOption);
menuBar.add(fileMenu);
studentMenu.setText("Student Options");
showAllStudentsOption.setText("Show All Students");
studentMenu.add(showAllStudentsOption);
showParticularStudentOption.setText("Show Student");
showParticularStudentOption.addActionListener(this::showParticularStudentOptionActionPerformed);
studentMenu.add(showParticularStudentOption);
showStudentGrade.setText("Show Student Grades");
showStudentGrade.addActionListener(this::showStudentGradeActionPerformed);
gradeStudentOption.addActionListener(this::gradeStudentOptionActionPerformed);
addStudentOption.addActionListener(this::addStudentOptionActionPerformed);
editStudentOption.addActionListener(this::editStudentOptionActionPerformed);
deleteStudentOption.addActionListener(this::deleteStudentOptionActionPerformed);
studentMenu.add(showAllStudentsOption);
studentMenu.add(showParticularStudentOption);
studentMenu.add(showStudentGrade);
studentMenu.add(studentSeparator);
gradeStudentOption.setText("Grade Student");
gradeStudentOption.addActionListener(this::gradeStudentOptionActionPerformed);
studentMenu.add(gradeStudentOption);
addStudentOption.setText("Add Student");
addStudentOption.addActionListener(this::addStudentOptionActionPerformed);
studentMenu.add(addStudentOption);
editStudentOption.setText("Edit Student");
editStudentOption.addActionListener(this::editStudentOptionActionPerformed);
studentMenu.add(editStudentOption);
deleteStudentOption.setText("Delete Student");
deleteStudentOption.addActionListener(this::deleteStudentOptionActionPerformed);
studentMenu.add(deleteStudentOption);
menuBar.add(studentMenu);
groupMenu.setText("Group Options");
showAllGroupsOption.setText("Show All Groups");
groupMenu.add(showAllGroupsOption);
showParticularGroupOption.setText("Show Group");
showParticularGroupOption.addActionListener(this::showParticularGroupOptionActionPerformed);
addGroupOption.addActionListener(this::addGroupOptionActionPerformed);
editGroupOption.addActionListener(this::editGroupOptionActionPerformed);
groupMenu.add(showAllGroupsOption);
groupMenu.add(showParticularGroupOption);
groupMenu.add(groupSeparator);
addGroupOption.setText("Add Group");
addGroupOption.addActionListener(this::addGroupOptionActionPerformed);
groupMenu.add(addGroupOption);
editGroupOption.setText("Edit Group");
editGroupOption.addActionListener(this::editGroupOptionActionPerformed);
groupMenu.add(editGroupOption);
deleteGroupOption.setText("Delete Group");
groupMenu.add(deleteGroupOption);
menuBar.add(groupMenu);
facultyMenu.setText("Faculty Options");
showAllFacultiesOption.setText("Show Faculties");
showAllGroupsOption.addActionListener(this::showAllGroupsOptionActionPerformed);
showAllStudentsOption.addActionListener(this::showAllStudentsOptionActionPerformed);
showAllFacultiesOption.addActionListener(this::showAllFacultiesOptionActionPerformed);
facultyMenu.add(showAllFacultiesOption);
showParticularFacultyOption.setText("Show A Faculty");
showParticularFacultyOption.addActionListener(this::showParticularFacultyOptionActionPerformed);
addFacultyOption.addActionListener(this::addFacultyOptionActionPerformed);
editFacultyOption.addActionListener(this::editFacultyOptionActionPerformed);
deleteGroupOption.addActionListener(this::deleteGroupOptionActionPerformed);
removeFacultyOption.addActionListener(this::removeFacultyOptionActionPerformed);
facultyMenu.add(showAllFacultiesOption);
facultyMenu.add(showParticularFacultyOption);
facultyMenu.add(facultySeparator);
addFacultyOption.setText("Add Faculty");
addFacultyOption.addActionListener(this::addFacultyOptionActionPerformed);
facultyMenu.add(addFacultyOption);
editFacultyOption.setText("Edit Faculty");
editFacultyOption.addActionListener(this::editFacultyOptionActionPerformed);
facultyMenu.add(editFacultyOption);
removeFacultyOption.setText("Remove Faculty");
removeFacultyOption.addActionListener(this::removeFacultyOptionActionPerformed);
facultyMenu.add(removeFacultyOption);
menuBar.add(facultyMenu);
setJMenuBar(menuBar);
@@ -187,16 +177,39 @@ public class StudentManagementGUI extends JFrame {
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 1280, Short.MAX_VALUE)
);
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 1280, Short.MAX_VALUE));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE)
);
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE));
pack();
}
private void showAllStudentsOptionActionPerformed(ActionEvent actionEvent) {
if (checkStudent() && checkGroup() && checkFaculty()) {
StringBuilder builder = new StringBuilder();
for (Student st : sv.getFm().getGm().getSm().getStudents()) {
builder.append(st.getFullname()).append("\n");
}
mainTextLabel.setText(builder.toString());
}
}
private void showAllGroupsOptionActionPerformed(ActionEvent actionEvent) {
if (checkGroup() && checkFaculty()) {
StringBuilder builder = new StringBuilder();
for (Group gr : sv.getFm().getGm().getGroups())
builder.append(gr.getName()).append("\n");
mainTextLabel.setText(builder.toString());
}
}
private void deleteGroupOptionActionPerformed(ActionEvent actionEvent) {
if (checkGroup() && checkFaculty()) {
DeleteGroupForm form = new DeleteGroupForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void loadBatchOptionActionPerformed(ActionEvent evt) {
}
@@ -206,8 +219,7 @@ public class StudentManagementGUI extends JFrame {
StudentManagementGUI.this,
"Are you sure you want to exit?",
"Confirmation",
JOptionPane.YES_NO_OPTION
);
JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.YES_OPTION) {
DataSerializer.serialize(sv);
@@ -216,11 +228,13 @@ public class StudentManagementGUI extends JFrame {
}
private void showAllFacultiesOptionActionPerformed(ActionEvent evt) {
StringBuilder builder = new StringBuilder();
for (Faculty fc : sv.getFm().getFaculties()) {
builder.append(fc.getName()).append(" ").append(fc.getAbbreviation()).append(" ").append(fc.getField().getName());
if (checkFaculty()) {
StringBuilder builder = new StringBuilder();
for (Faculty fc : sv.getFm().getFaculties()) {
builder.append(fc.getName()).append(" ").append(fc.getAbbreviation()).append(" ").append(fc.getField().getName());
}
mainTextLabel.setText(builder.toString());
}
mainTextLabel.setText(builder.toString());
}
private void saveAsOptionActionPerformed(ActionEvent evt) {
@@ -228,8 +242,10 @@ public class StudentManagementGUI extends JFrame {
}
private void showParticularGroupOptionActionPerformed(ActionEvent evt) {
ShowGroupForm form = new ShowGroupForm(sv, mainTextLabel);
form.setVisible(true);
if (checkGroup() && checkFaculty()) {
ShowGroupForm form = new ShowGroupForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void addFacultyOptionActionPerformed(ActionEvent evt) {
@@ -238,57 +254,103 @@ public class StudentManagementGUI extends JFrame {
}
private void addStudentOptionActionPerformed(ActionEvent evt) {
AddStudentForm form = new AddStudentForm(sv, mainTextLabel);
form.setVisible(true);
if (checkGroup() && checkFaculty()) {
AddStudentForm form = new AddStudentForm(sv);
form.setVisible(true);
}
}
private void gradeStudentOptionActionPerformed(ActionEvent evt) {
GradeStudentForm form = new GradeStudentForm(sv, mainTextLabel);
form.setVisible(true);
if (checkStudent() && checkGroup() && checkFaculty()) {
GradeStudentForm form = new GradeStudentForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void editStudentOptionActionPerformed(ActionEvent evt) {
EditStudentForm form = new EditStudentForm(sv, mainTextLabel);
form.setVisible(true);
if (checkStudent() && checkGroup() && checkFaculty()) {
EditStudentForm form = new EditStudentForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void deleteStudentOptionActionPerformed(ActionEvent evt) {
DeleteStudentForm form = new DeleteStudentForm(sv, mainTextLabel);
form.setVisible(true);
if (checkStudent() && checkGroup() && checkFaculty()) {
DeleteStudentForm form = new DeleteStudentForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void showStudentGradeActionPerformed(ActionEvent evt) {
ShowStudentGradesForm form = new ShowStudentGradesForm(sv, mainTextLabel);
form.setVisible(true);
if (checkStudent() && checkGroup() && checkFaculty()) {
ShowStudentGradesForm form = new ShowStudentGradesForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void showParticularStudentOptionActionPerformed(ActionEvent evt) {
ShowStudentForm form = new ShowStudentForm(sv, mainTextLabel);
form.setVisible(true);
if (checkStudent() && checkGroup() && checkFaculty()) {
ShowStudentForm form = new ShowStudentForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void addGroupOptionActionPerformed(ActionEvent evt) {
AddGroupForm form = new AddGroupForm(sv, mainTextLabel);
form.setVisible(true);
if (checkFaculty()) {
AddGroupForm form = new AddGroupForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void editGroupOptionActionPerformed(ActionEvent evt) {
EditGroupForm form = new EditGroupForm(sv, mainTextLabel);
form.setVisible(true);
if (checkGroup() && checkFaculty()) {
EditGroupForm form = new EditGroupForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void showParticularFacultyOptionActionPerformed(ActionEvent evt) {
ShowFacultyForm form = new ShowFacultyForm(sv, mainTextLabel);
form.setVisible(true);
if (checkFaculty()) {
ShowFacultyForm form = new ShowFacultyForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void editFacultyOptionActionPerformed(ActionEvent evt) {
EditFacultyForm form = new EditFacultyForm(sv, mainTextLabel);
form.setVisible(true);
if (checkFaculty()) {
EditFacultyForm form = new EditFacultyForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private void removeFacultyOptionActionPerformed(ActionEvent evt) {
RemoveFacultyForm form = new RemoveFacultyForm(sv, mainTextLabel);
form.setVisible(true);
if (checkFaculty()) {
RemoveFacultyForm form = new RemoveFacultyForm(sv, mainTextLabel);
form.setVisible(true);
}
}
private boolean checkFaculty() {
if (sv.getFm().getFaculties().isEmpty()) {
JOptionPane.showMessageDialog(null, "Configure a faculty!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
return false;
}
return true;
}
private boolean checkGroup() {
if (sv.getFm().getGm().getGroups().isEmpty()) {
JOptionPane.showMessageDialog(null, "Configure a group!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
return false;
}
return true;
}
private boolean checkStudent() {
if (sv.getFm().getGm().getSm().getStudents().isEmpty()) {
JOptionPane.showMessageDialog(null, "No students in database!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
return false;
}
return true;
}
}

View File

@@ -13,16 +13,16 @@ import javax.swing.text.Style;
public class AddFacultyForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private final JLabel titleLabel = new JLabel();
private final JComboBox<String> specialtyCombo = new JComboBox<>();
private final JTextField nameField = new JTextField();
private final JButton submitButton = new JButton();
private final JButton cancelButton = new JButton();
private final JLabel nameLabel = new JLabel();
private final JTextField abbreviationField = new JTextField();
private final JLabel abbreviationLabel = new JLabel();
private final JLabel specialtyLabel = new JLabel();
private JLabel titleLabel = new JLabel();
private JComboBox<String> specialtyCombo = new JComboBox<>();
private JTextField nameField = new JTextField();
private JButton submitButton = new JButton();
private JButton cancelButton = new JButton();
private JLabel nameLabel = new JLabel();
private JTextField abbreviationField = new JTextField();
private JLabel abbreviationLabel = new JLabel();
private JLabel specialtyLabel = new JLabel();
public AddFacultyForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
@@ -33,8 +33,16 @@ public class AddFacultyForm extends JFrame {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18));
titleLabel.setText("Add a new faculty");
nameField.setText("Name...");
submitButton.setText("Submit");
cancelButton.setText("Cancel");
nameLabel.setText("Name:");
abbreviationField.setText("Abbreviation...");
abbreviationLabel.setText("Abbreviation:");
specialtyLabel.setText("Specialty Field:");
String[] enumList = new String[StudyField.getAllEnums().size()];
List<StudyField> sfl = StudyField.getAllEnums();
@@ -42,26 +50,13 @@ public class AddFacultyForm extends JFrame {
enumList[i] = sfl.get(i).getName();
specialtyCombo.setModel(new DefaultComboBoxModel<>(enumList));
specialtyCombo.addActionListener(this::specialtyComboActionPerformed);
nameField.setText("Name...");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
specialtyCombo.addActionListener(this::specialtyComboActionPerformed);
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
nameLabel.setText("Name:");
abbreviationField.setText("Abbreviation...");
abbreviationLabel.setText("Abbreviation:");
specialtyLabel.setText("Specialty Field:");
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
@@ -91,6 +86,7 @@ public class AddFacultyForm extends JFrame {
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(titleLabel)
.addGap(149, 149, 149)));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(7, 7, 7)
@@ -110,7 +106,6 @@ public class AddFacultyForm extends JFrame {
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(24, Short.MAX_VALUE)));
pack();
}
@@ -119,12 +114,12 @@ public class AddFacultyForm extends JFrame {
String abbreviation = abbreviationField.getText();
StudyField specialty = StudyField.getEnum(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString());
Faculty newFaculty = new Faculty(name, abbreviation, specialty);
sv.getFm().addFaculty(newFaculty);
sv.addFaculty(newFaculty);
this.dispose();
}
private void specialtyComboActionPerformed(ActionEvent evt) {
abbreviationField.setText(StudyField.getAbbrevFromString(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString()));
this.dispose();
}
private void cancelButtonActionPerformed(ActionEvent evt) {

View File

@@ -4,74 +4,81 @@
*/
package org.lumijiez.gui.forms.faculty;
import org.lumijiez.base.Faculty;
import org.lumijiez.enums.StudyField;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Arrays;
import java.util.Objects;
public class EditFacultyForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JTextField abbreviationField;
private JLabel abbreviationLabel;
private JButton cancelButton;
private JComboBox<String> facultyCombo;
private JLabel facultyLabel;
private JTextField nameField;
private JLabel nameLabel;
private JComboBox<String> specialtyCombo;
private JLabel specialtyLabel;
private JButton submitButton;
private JLabel titleLabel;
private final JTextField abbreviationField = new JTextField();
private final JLabel abbreviationLabel = new JLabel();
private final JButton cancelButton = new JButton();
private final JLabel facultyLabel = new JLabel();
private final JTextField nameField = new JTextField();
private final JLabel nameLabel = new JLabel();
private final JLabel specialtyLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JLabel titleLabel = new JLabel();
private final JComboBox<Faculty> facultyCombo;
private final JComboBox<StudyField> specialtyCombo;
public EditFacultyForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
specialtyCombo = new JComboBox<>(StudyField.getAllEnums().toArray(new StudyField[0]));
initComponents();
}
private void initComponents() {
titleLabel = new JLabel();
submitButton = new JButton();
cancelButton = new JButton();
nameLabel = new JLabel();
nameField = new JTextField();
facultyCombo = new JComboBox<>();
facultyLabel = new JLabel();
abbreviationLabel = new JLabel();
abbreviationField = new JTextField();
specialtyCombo = new JComboBox<>();
specialtyLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Edit a faculty");
submitButton.setText("Submit");
cancelButton.setText("Cancel");
nameLabel.setText("New name:");
nameField.setText("Name...");
facultyLabel.setText("Faculty:");
abbreviationLabel.setText("New abbreviation:");
abbreviationField.setText("Abbreviation...");
specialtyLabel.setText("New specialty:");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
cancelButton.addActionListener(this::cancelButtonActionPerformed);
submitButton.addActionListener(this::submitButtonActionPerformed);
specialtyCombo.addActionListener(this::specialtyComboActionPerformed);
facultyCombo.addActionListener(this::facultyComboActionPerformed);
nameLabel.setText("New name:");
specialtyCombo.setSelectedItem(((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).getField());
nameField.setText("Name...");
facultyCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Faculty)
setText(((Faculty) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
facultyLabel.setText("Faculty:");
abbreviationLabel.setText("New abbreviation:");
abbreviationField.setText("Abbreviation...");
specialtyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
specialtyLabel.setText("New specialty:");
specialtyCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof StudyField)
setText(((StudyField) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -102,8 +109,8 @@ public class EditFacultyForm extends JFrame {
.addGap(18, 18, 18)
.addComponent(submitButton)))
.addComponent(nameLabel))))))
.addContainerGap(24, Short.MAX_VALUE))
);
.addContainerGap(24, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -129,13 +136,22 @@ public class EditFacultyForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addGap(14, 14, 14))
);
.addGap(14, 14, 14)));
pack();
}
private void facultyComboActionPerformed(ActionEvent actionEvent) {
specialtyCombo.setSelectedItem(((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).getField());
}
private void specialtyComboActionPerformed(ActionEvent actionEvent) {
abbreviationField.setText(((StudyField) Objects.requireNonNull(specialtyCombo.getSelectedItem())).getAbbreviation());
}
private void submitButtonActionPerformed(ActionEvent evt) {
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setName(nameField.getText());
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setAbbreviation(abbreviationField.getText());
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setField(((StudyField) Objects.requireNonNull(specialtyCombo.getSelectedItem())));
this.dispose();
}

View File

@@ -4,50 +4,55 @@
*/
package org.lumijiez.gui.forms.faculty;
import org.lumijiez.base.Faculty;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
public class RemoveFacultyForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JComboBox<String> facultyCombo;
private JLabel facultyLabel;
private JButton submitButton;
private JLabel titleLabel;
private final JButton cancelButton = new JButton();
private final JComboBox<Faculty> facultyCombo;
private final JLabel facultyLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JLabel titleLabel = new JLabel();
public RemoveFacultyForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
initComponents();
}
private void initComponents() {
titleLabel = new JLabel();
submitButton = new JButton();
cancelButton = new JButton();
facultyCombo = new JComboBox<>();
facultyLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Remove a faculty");
submitButton.setText("Submit");
cancelButton.setText("Cancel");
facultyLabel.setText("Faculty:");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
facultyLabel.setText("Faculty:");
facultyCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Faculty)
setText(((Faculty) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -67,8 +72,8 @@ public class RemoveFacultyForm extends JFrame {
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(titleLabel)
.addGap(48, 48, 48))
);
.addGap(48, 48, 48)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -82,13 +87,12 @@ public class RemoveFacultyForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(21, Short.MAX_VALUE))
);
.addContainerGap(21, Short.MAX_VALUE)));
pack();
}
private void submitButtonActionPerformed(ActionEvent evt) {
sv.deleteFaculty(((Faculty)facultyCombo.getSelectedItem()));
this.dispose();
}

View File

@@ -4,50 +4,57 @@
*/
package org.lumijiez.gui.forms.faculty;
import org.lumijiez.base.Faculty;
import org.lumijiez.base.Group;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
public class ShowFacultyForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JComboBox<String> facultyCombo;
private JLabel facultyLabel;
private JButton submitButton;
private JLabel titleLabel;
private final JButton cancelButton = new JButton();
private final JComboBox<Faculty> facultyCombo;
private final JLabel facultyLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JLabel titleLabel = new JLabel();
public ShowFacultyForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
initComponents();
}
private void initComponents() {
titleLabel = new JLabel();
submitButton = new JButton();
cancelButton = new JButton();
facultyCombo = new JComboBox<>();
facultyLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Show a faculty");
submitButton.setText("Submit");
cancelButton.setText("Cancel");
facultyLabel.setText("Faculty:");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
facultyCombo.addActionListener(this::facultyComboActionPerformed);
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
facultyLabel.setText("Faculty:");
facultyCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Faculty)
setText(((Faculty) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -68,8 +75,8 @@ public class ShowFacultyForm extends JFrame {
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(submitButton))
.addComponent(facultyCombo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 171, GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(27, Short.MAX_VALUE))
);
.addContainerGap(27, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -83,13 +90,23 @@ public class ShowFacultyForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(24, Short.MAX_VALUE))
);
.addContainerGap(24, Short.MAX_VALUE)));
pack();
}
private void facultyComboActionPerformed(ActionEvent actionEvent) {
}
private void submitButtonActionPerformed(ActionEvent evt) {
StringBuilder builder = new StringBuilder();
Faculty fac = (Faculty) facultyCombo.getSelectedItem();
assert fac != null;
builder.append("Name: ").append(fac.getName()).append("\n");
builder.append("Specialty: ").append(fac.getField()).append("\n");
builder.append("Groups: ").append("\n");
for (Group gr : fac.getGroups())
builder.append(gr.getName()).append("\n");
mainTextLabel.setText(builder.toString());
this.dispose();
}

View File

@@ -4,50 +4,59 @@
*/
package org.lumijiez.gui.forms.group;
import org.lumijiez.base.Faculty;
import org.lumijiez.base.Group;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Objects;
public class AddGroupForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private final JLabel titleLabel = new JLabel();
private final JTextField nameField = new JTextField();
private final JButton submitButton = new JButton();
private final JButton cancelButton = new JButton();
private final JLabel nameLabel = new JLabel();
private final JComboBox<Faculty> facultyCombo;
private final JLabel facultyLabel = new JLabel();
public AddGroupForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
initComponents();
}
private void initComponents() {
JLabel titleLabel = new JLabel();
JTextField nameField = new JTextField();
JButton submitButton = new JButton();
JButton cancelButton = new JButton();
JLabel nameLabel = new JLabel();
JComboBox<String> facultyCombo = new JComboBox<>();
JLabel facultyLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Add a new group");
titleLabel.setText("Add a new group");
nameField.setText("Name...");
submitButton.setText("Submit");
cancelButton.setText("Cancel");
nameLabel.setText("Name:");
facultyLabel.setText("Faculty:");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
nameLabel.setText("Name:");
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
facultyLabel.setText("Faculty:");
facultyCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Faculty)
setText(((Faculty) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -71,8 +80,8 @@ public class AddGroupForm extends JFrame {
.addGroup(layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(titleLabel)))
.addContainerGap(29, Short.MAX_VALUE))
);
.addContainerGap(29, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -90,13 +99,14 @@ public class AddGroupForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addGap(15, 15, 15))
);
.addGap(15, 15, 15)));
pack();
}
private void submitButtonActionPerformed(ActionEvent evt) {
Group gr = new Group(nameField.getText());
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
sv.addGroup(gr, fac);
this.dispose();
}

View File

@@ -4,49 +4,55 @@
*/
package org.lumijiez.gui.forms.group;
import org.lumijiez.base.Faculty;
import org.lumijiez.base.Group;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
public class DeleteGroupForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JComboBox<String> groupCombo;
private JLabel groupLabel;
private JButton submitButton;
private JLabel titleLabel;
private final JButton cancelButton = new JButton();
private final JComboBox<Group> groupCombo;
private final JLabel groupLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JLabel titleLabel = new JLabel();
public DeleteGroupForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
initComponents();
}
private void initComponents() {
titleLabel = new JLabel();
groupCombo = new JComboBox<>();
submitButton = new JButton();
cancelButton = new JButton();
groupLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Delete a group");
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
titleLabel.setText("Delete a group");
submitButton.setText("Submit");
cancelButton.setText("Cancel");
groupLabel.setText("Group:");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
groupLabel.setText("Group:");
groupCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Group)
setText(((Group) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -67,8 +73,8 @@ public class DeleteGroupForm extends JFrame {
.addGroup(layout.createSequentialGroup()
.addGap(54, 54, 54)
.addComponent(titleLabel)))
.addContainerGap(29, Short.MAX_VALUE))
);
.addContainerGap(29, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -82,13 +88,12 @@ public class DeleteGroupForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(18, Short.MAX_VALUE))
);
.addContainerGap(18, Short.MAX_VALUE)));
pack();
}
private void submitButtonActionPerformed(ActionEvent evt) {
sv.deleteGroup(((Group)groupCombo.getSelectedItem()));
this.dispose();
}

View File

@@ -4,66 +4,73 @@
*/
package org.lumijiez.gui.forms.group;
import org.lumijiez.base.Faculty;
import org.lumijiez.base.Group;
import org.lumijiez.enums.StudyField;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Objects;
public class EditGroupForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JComboBox<String> facultyCombo;
private JLabel facultyLabel;
private JComboBox<String> groupCombo;
private JLabel groupLabel;
private JTextField nameField;
private JLabel nameLabel;
private JButton submitButton;
private JLabel titleLabel;
private final JButton cancelButton = new JButton();
private final JComboBox<Faculty> facultyCombo;
private final JLabel facultyLabel = new JLabel();
private final JComboBox<Group> groupCombo;
private final JLabel groupLabel = new JLabel();
private final JTextField nameField = new JTextField();
private final JLabel nameLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JLabel titleLabel = new JLabel();
public EditGroupForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
initComponents();
}
private void initComponents() {
titleLabel = new JLabel();
groupCombo = new JComboBox<>();
nameField = new JTextField();
submitButton = new JButton();
cancelButton = new JButton();
nameLabel = new JLabel();
facultyCombo = new JComboBox<>();
groupLabel = new JLabel();
facultyLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Edit a group");
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
nameField.setText("Name...");
submitButton.setText("Submit");
cancelButton.setText("Cancel");
nameLabel.setText("New name:");
groupLabel.setText("Group:");
facultyLabel.setText("Faculty:");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
nameLabel.setText("New name:");
facultyCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Faculty)
setText(((Faculty) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
groupLabel.setText("Group:");
facultyLabel.setText("Faculty:");
groupCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Group)
setText(((Group) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -91,8 +98,8 @@ public class EditGroupForm extends JFrame {
.addComponent(facultyLabel)
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(submitButton))))
.addContainerGap(34, Short.MAX_VALUE))
);
.addContainerGap(34, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -116,13 +123,14 @@ public class EditGroupForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(36, Short.MAX_VALUE))
);
.addContainerGap(36, Short.MAX_VALUE)));
pack();
}
private void submitButtonActionPerformed(ActionEvent evt) {
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
sv.editGroup(gr, nameField.getText(), fac);
this.dispose();
}

View File

@@ -4,51 +4,56 @@
*/
package org.lumijiez.gui.forms.group;
import org.lumijiez.base.Group;
import org.lumijiez.base.Student;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Objects;
public class ShowGroupForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JComboBox<String> groupCombo;
private JLabel groupLabel;
private JButton submitButton;
private JLabel titleLabel;
private final JButton cancelButton = new JButton();
private final JComboBox<Group> groupCombo;
private final JLabel groupLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JLabel titleLabel = new JLabel();
public ShowGroupForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
initComponents();
}
private void initComponents() {
titleLabel = new JLabel();
groupCombo = new JComboBox<>();
submitButton = new JButton();
cancelButton = new JButton();
groupLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Show a group");
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
groupLabel.setText("Group:");
cancelButton.setText("Cancel");
submitButton.setText("Submit");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
groupLabel.setText("Group:");
groupCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Group)
setText(((Group) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -69,8 +74,8 @@ public class ShowGroupForm extends JFrame {
.addGroup(layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(titleLabel)))
.addContainerGap(24, Short.MAX_VALUE))
);
.addContainerGap(24, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -84,13 +89,18 @@ public class ShowGroupForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(25, Short.MAX_VALUE))
);
.addContainerGap(25, Short.MAX_VALUE)));
pack();
}
private void submitButtonActionPerformed(ActionEvent evt) {
StringBuilder builder = new StringBuilder();
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
builder.append(gr.getName()).append(" ").append(gr.getFaculty().getName()).append(" \n");
for (Student st : gr.getStudents()) {
builder.append(st.getFullname()).append("\n");
}
mainTextLabel.setText(builder.toString());
this.dispose();
}

View File

@@ -4,58 +4,77 @@
*/
package org.lumijiez.gui.forms.student;
import org.lumijiez.base.Faculty;
import org.lumijiez.base.Group;
import org.lumijiez.managers.Supervisor;
import org.lumijiez.util.FullStudentData;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Date;
import java.util.Objects;
public class AddStudentForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JTextField emailField;
private JLabel emailLabel;
private JComboBox<String> facultyCombo;
private JLabel facultyLabel;
private JComboBox<String> groupCombo;
private JLabel groupLabel;
private JTextField nameField;
private JLabel nameLabel;
private JButton submitButton;
private JTextField surnameField;
private JLabel surnameLabel;
private JLabel titleLabel;
public AddStudentForm(Supervisor sv, JLabel mainTextLabel) {
private final JLabel titleLabel = new JLabel();
private final JComboBox<Group> groupCombo;
private final JTextField nameField = new javax.swing.JTextField();
private final JButton submitButton = new javax.swing.JButton();
private final JButton cancelButton = new javax.swing.JButton();
private final JLabel nameLabel = new javax.swing.JLabel();
private final JTextField surnameField = new javax.swing.JTextField();
private final JTextField emailField = new javax.swing.JTextField();
private final JLabel surnameLabel = new javax.swing.JLabel();
private final JLabel emailLabel = new javax.swing.JLabel();
private final JComboBox<Faculty> facultyCombo;
private final JLabel groupLabel = new javax.swing.JLabel();
private final JLabel facultyLabel = new javax.swing.JLabel();
private final JTextField birthYearField = new javax.swing.JTextField();
private final JTextField birthDayField = new javax.swing.JTextField();
private final JTextField birthMonthField = new javax.swing.JTextField();
private final JLabel surnameLabel1 = 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 JTextField enrolDayField = new javax.swing.JTextField();
private final JTextField enrolMonthField = new javax.swing.JTextField();
private final JLabel enrolMonthLabel = new javax.swing.JLabel();
private final JTextField enrolYearField = new javax.swing.JTextField();
private final JLabel enrolYearLabel = new javax.swing.JLabel();
public AddStudentForm(Supervisor sv) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
initComponents();
}
private void initComponents() {
titleLabel = new JLabel();
groupCombo = new JComboBox<>();
nameField = new JTextField();
submitButton = new JButton();
cancelButton = new JButton();
nameLabel = new JLabel();
surnameField = new JTextField();
emailField = new JTextField();
surnameLabel = new JLabel();
emailLabel = new JLabel();
facultyCombo = new JComboBox<>();
groupLabel = new JLabel();
facultyLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Add a new student");
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
facultyCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Faculty)
setText(((Faculty) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
groupCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Group)
setText(((Group) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
nameField.setText("Name...");
@@ -65,7 +84,6 @@ public class AddStudentForm extends JFrame {
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
cancelButton.addActionListener(this::cancelButtonActionPerformed);
nameLabel.setText("Name:");
@@ -77,18 +95,40 @@ public class AddStudentForm extends JFrame {
emailLabel.setText("Email:");
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
groupLabel.setText("Group:");
facultyLabel.setText("Faculty:");
GroupLayout layout = new GroupLayout(getContentPane());
birthYearField.setText("Surname...");
birthDayField.setText("Surname...");
birthMonthField.setText("Surname...");
surnameLabel1.setText("Year of Birth:");
birthDayLabel.setText("Day of Birth:");
birthMonthLabel.setText("Month of Birth:");
enrolDayLabel.setText("Day of Enrollment:");
enrolDayField.setText("Surname...");
enrolMonthField.setText("Surname...");
enrolMonthLabel.setText("Month of Enrollment:");
enrolYearField.setText("Surname...");
enrolYearLabel.setText("Year of Enrollment:");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(132, 132, 132)
.addComponent(titleLabel))
@@ -97,88 +137,144 @@ public class AddStudentForm extends JFrame {
.addComponent(surnameLabel)
.addGap(142, 142, 142)
.addComponent(emailLabel)))
.addGap(69, 138, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
.addComponent(surnameField, GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
.addComponent(nameField)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(nameLabel)))
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(groupLabel)
.addGap(67, 67, 67)
.addComponent(facultyLabel)
.addGap(51, 51, 51))
.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(surnameLabel1)
.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()
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
.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(cancelButton)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(submitButton))
.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(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(34, 34, 34)
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.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(GroupLayout.Alignment.LEADING)
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(titleLabel)
.addGap(13, 13, 13)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nameLabel)
.addComponent(groupLabel)
.addComponent(facultyLabel))
.addGap(3, 3, 3)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(groupCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(facultyCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(surnameLabel)
.addGap(5, 5, 5))
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(emailLabel)
.addGap(4, 4, 4)))
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, 38)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(surnameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.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(surnameLabel1))
.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(submitButton))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(21, 21, 21))
);
pack();
}
private void cancelButtonActionPerformed(ActionEvent evt) {
this.dispose();
}
private void submitButtonActionPerformed(ActionEvent evt) {
String name = nameField.getText();
String surname = surnameField.getText();
FullStudentData data = new FullStudentData(name, surname, "group", "faculty");
if (!name.isEmpty() && !surname.isEmpty()) {
sv.getFm().getGm().getSm().addStudent(data, sv);
mainTextLabel.setText("===== Students =====\n" + sv.getStudentsText());
System.out.println(data);
System.out.println("LOL");
System.out.println(sv.getStudentsText());
this.dispose();
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
int birthYear = Integer.parseInt(birthYearField.getText());
int birthMonth = Integer.parseInt(birthMonthField.getText());
int birthDay = Integer.parseInt(birthDayField.getText());
int enrolYear = Integer.parseInt(enrolYearField.getText());
int enrolMonth = Integer.parseInt(enrolMonthField.getText());
int enrolDay = Integer.parseInt(enrolDayField.getText());
Date birthDate = new Date(birthYear, birthMonth, birthDay);
Date enrolDate = new Date(enrolYear, enrolMonth, enrolDay);
sv.addStudent(name, surname, group, faculty, birthDate, enrolDate);
this.dispose();
}
}

View File

@@ -4,49 +4,55 @@
*/
package org.lumijiez.gui.forms.student;
import org.lumijiez.base.Student;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Objects;
public class DeleteStudentForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JComboBox<String> studentCombo;
private JLabel studentLabel;
private JButton submitButton;
private JLabel titleLabel;
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 DeleteStudentForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
initComponents();
}
private void initComponents() {
titleLabel = new JLabel();
studentCombo = new JComboBox<>();
submitButton = new JButton();
cancelButton = new JButton();
studentLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Delete Student");
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
cancelButton.addActionListener(this::cancelButtonActionPerformed);
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 java.awt.Color(204, 255, 204));
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -67,8 +73,8 @@ public class DeleteStudentForm extends JFrame {
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(titleLabel)
.addGap(51, 51, 51))
);
.addGap(51, 51, 51)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -82,13 +88,13 @@ public class DeleteStudentForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(submitButton)
.addComponent(cancelButton))
.addContainerGap(26, Short.MAX_VALUE))
);
.addContainerGap(26, Short.MAX_VALUE)));
pack();
}
private void submitButtonActionPerformed(ActionEvent evt) {
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
sv.deleteStudent(student);
this.dispose();
}

View File

@@ -4,90 +4,97 @@
*/
package org.lumijiez.gui.forms.student;
import org.lumijiez.base.Faculty;
import org.lumijiez.base.Group;
import org.lumijiez.base.Student;
import org.lumijiez.managers.Supervisor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Date;
import java.util.Objects;
public class EditStudentForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JTextField emailField;
private JLabel emailLabel;
private JComboBox<String> facultyCombo;
private JLabel facultyLabel;
private JComboBox<String> groupCombo;
private JLabel groupLabel;
private JTextField nameField;
private JLabel nameLabel;
private JComboBox<String> studentCombo;
private JLabel studentLabel;
private JButton submitButton;
private JTextField surnameField;
private JLabel surnameLabel;
private JLabel titleLabel;
private final JButton cancelButton = new JButton();
private final JTextField emailField = new JTextField();
private final JLabel emailLabel = new JLabel();
private final JComboBox<Faculty> facultyCombo;
private final JLabel facultyLabel = new JLabel();
private final JComboBox<Group> groupCombo;
private final JLabel groupLabel = new JLabel();
private final JTextField nameField = new JTextField();
private final JLabel nameLabel = new JLabel();
private final JComboBox<Student> studentCombo;
private final JLabel studentLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JTextField surnameField = new JTextField();
private final JLabel surnameLabel = new JLabel();
private final JLabel titleLabel = new JLabel();
public EditStudentForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
this.mainTextLabel = mainTextLabel;
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[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]));
initComponents();
}
private void initComponents() {
titleLabel = new JLabel();
studentCombo = new JComboBox<>();
nameField = new JTextField();
submitButton = new JButton();
cancelButton = new JButton();
studentLabel = new JLabel();
surnameField = new JTextField();
emailField = new JTextField();
nameLabel = new JLabel();
emailLabel = new JLabel();
groupCombo = new JComboBox<>();
groupLabel = new JLabel();
facultyLabel = new JLabel();
surnameLabel = new JLabel();
facultyCombo = new JComboBox<>();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Edit a student");
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
nameField.setText("Name...");
submitButton.setText("Submit");
cancelButton.setText("Cancel");
studentLabel.setText("Student:");
surnameField.setText("Surname...");
emailField.setText("Email...");
nameLabel.setText("New name:");
emailLabel.setText("New email:");
groupLabel.setText("New group:");
facultyLabel.setText("New faculty:");
surnameLabel.setText("New surname:");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
cancelButton.addActionListener(this::cancelButtonActionPerformed);
studentLabel.setText("Student:");
facultyCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Faculty)
setText(((Faculty) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
surnameField.setText("Surname...");
groupCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Group)
setText(((Group) value).getName());
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
emailField.setText("Email...");
nameLabel.setText("New name:");
emailLabel.setText("New email:");
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
groupLabel.setText("New group:");
facultyLabel.setText("New faculty:");
surnameLabel.setText("New surname:");
facultyCombo.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());
getContentPane().setLayout(layout);
@@ -128,8 +135,8 @@ public class EditStudentForm extends JFrame {
.addGroup(layout.createSequentialGroup()
.addGap(162, 162, 162)
.addComponent(titleLabel)))
.addContainerGap(24, Short.MAX_VALUE))
);
.addContainerGap(24, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -160,13 +167,24 @@ public class EditStudentForm extends JFrame {
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(24, Short.MAX_VALUE))
);
.addContainerGap(24, Short.MAX_VALUE)));
pack();
}
private void submitButtonActionPerformed(ActionEvent evt) {
String name = nameField.getText();
String surname = surnameField.getText();
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
// int birthYear = Integer.parseInt(birthYearField.getText());
// int birthMonth = Integer.parseInt(birthMonthField.getText());
// int birthDay = Integer.parseInt(birthDayField.getText());
// int enrolYear = Integer.parseInt(enrolYearField.getText());
// int enrolMonth = Integer.parseInt(enrolMonthField.getText());
// int enrolDay = Integer.parseInt(enrolDayField.getText());
// Date birthDate = new Date(birthYear, birthMonth, birthDay);
// Date enrolDate = new Date(enrolYear, enrolMonth, enrolDay);
// sv.addStudent(name, surname, group, faculty, birthDate, enrolDate);
this.dispose();
}

View File

@@ -13,15 +13,15 @@ public class GradeStudentForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JTextField gradeField;
private JLabel gradeLabel;
private JComboBox<String> studentCombo;
private JLabel studentLabel;
private JComboBox<String> subjectCombo;
private JLabel subjectLabel;
private JButton submitButton;
private JLabel titleLabel;
private final JButton cancelButton = new JButton();
private final JTextField gradeField = new JTextField();
private final JLabel gradeLabel = new JLabel();
private final JComboBox<String> studentCombo = new JComboBox<>();
private final JLabel studentLabel = new JLabel();
private final JComboBox<String> subjectCombo = new JComboBox<>();
private final JLabel subjectLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JLabel titleLabel = new JLabel();
public GradeStudentForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
@@ -31,41 +31,27 @@ public class GradeStudentForm extends JFrame {
private void initComponents() {
titleLabel = new JLabel();
studentCombo = new JComboBox<>();
submitButton = new JButton();
cancelButton = new JButton();
subjectLabel = new JLabel();
subjectCombo = new JComboBox<>();
studentLabel = new JLabel();
gradeField = new JTextField();
gradeLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Grade a student");
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18));
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
titleLabel.setText("Grade a student");
studentLabel.setText("Student:");
subjectLabel.setText("Subject:");
gradeField.setText("Grade...");
submitButton.setText("Submit");
gradeLabel.setText("Grade:");
cancelButton.setText("Cancel");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
subjectLabel.setText("Subject:");
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
subjectCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
studentLabel.setText("Student:");
gradeField.setText("Grade...");
gradeLabel.setText("Grade:");
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@@ -98,8 +84,8 @@ public class GradeStudentForm extends JFrame {
.addGroup(layout.createSequentialGroup()
.addGap(129, 129, 129)
.addComponent(titleLabel)
.addGap(0, 0, Short.MAX_VALUE))
);
.addGap(0, 0, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -120,9 +106,7 @@ public class GradeStudentForm extends JFrame {
.addComponent(gradeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(30, Short.MAX_VALUE))
);
.addContainerGap(30, Short.MAX_VALUE)));
pack();
}

View File

@@ -13,11 +13,11 @@ public class ShowStudentForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JComboBox<String> studentCombo;
private JLabel studentLabel;
private JButton submitButton;
private JLabel titleLabel;
private final JButton cancelButton = new JButton();
private final JComboBox<String> studentCombo = new JComboBox<>();
private final JLabel studentLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JLabel titleLabel = new JLabel();
public ShowStudentForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
@@ -27,28 +27,22 @@ public class ShowStudentForm extends JFrame {
private void initComponents() {
titleLabel = new JLabel();
studentCombo = new JComboBox<>();
submitButton = new JButton();
cancelButton = new JButton();
studentLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Show Student");
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
titleLabel.setText("Show Student");
submitButton.setText("Submit");
studentLabel.setText("Student:");
cancelButton.setText("Cancel");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
studentLabel.setText("Student:");
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -71,8 +65,8 @@ public class ShowStudentForm extends JFrame {
.addGroup(layout.createSequentialGroup()
.addGap(52, 52, 52)
.addComponent(titleLabel)))
.addContainerGap(23, Short.MAX_VALUE))
);
.addContainerGap(23, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -86,9 +80,7 @@ public class ShowStudentForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(22, Short.MAX_VALUE))
);
.addContainerGap(22, Short.MAX_VALUE)));
pack();
}

View File

@@ -13,12 +13,11 @@ public class ShowStudentGradesForm extends JFrame {
private final Supervisor sv;
private final JLabel mainTextLabel;
private JButton cancelButton;
private JComboBox<String> studentCombo;
private JLabel studentLabel;
private JButton submitButton;
private JLabel titleLabel;
private final JButton cancelButton = new JButton();
private final JComboBox<String> studentCombo = new JComboBox<>();
private final JLabel studentLabel = new JLabel();
private final JButton submitButton = new JButton();
private final JLabel titleLabel = new JLabel();
public ShowStudentGradesForm(Supervisor sv, JLabel mainTextLabel) {
this.sv = sv;
@@ -28,28 +27,22 @@ public class ShowStudentGradesForm extends JFrame {
private void initComponents() {
titleLabel = new JLabel();
studentCombo = new JComboBox<>();
submitButton = new JButton();
cancelButton = new JButton();
studentLabel = new JLabel();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
titleLabel.setText("Show Grades");
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
titleLabel.setText("Show Grades");
studentLabel.setText("Student:");
submitButton.setText("Submit");
cancelButton.setText("Cancel");
submitButton.setBackground(new java.awt.Color(204, 255, 204));
submitButton.setText("Submit");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
cancelButton.setText("Cancel");
submitButton.addActionListener(this::submitButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
studentLabel.setText("Student:");
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -72,8 +65,8 @@ public class ShowStudentGradesForm extends JFrame {
.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addComponent(titleLabel)))
.addContainerGap(30, Short.MAX_VALUE))
);
.addContainerGap(30, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -87,9 +80,7 @@ public class ShowStudentGradesForm extends JFrame {
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(submitButton))
.addContainerGap(22, Short.MAX_VALUE))
);
.addContainerGap(22, Short.MAX_VALUE)));
pack();
}

View File

@@ -15,30 +15,10 @@ import static org.lumijiez.enums.StudyField.DEFAULT_UNASSIGNED;
public class StudentManager implements Serializable {
private final List<Student> students = new ArrayList<>();
public void addStudent(FullStudentData data, Supervisor sv) {
Faculty faculty;
Group group;
if (Objects.isNull(sv.getFm().getFaculty(data.faculty()))) {
Faculty newFaculty = new Faculty(data.faculty(), DEFAULT_UNASSIGNED.getAbbreviation(), DEFAULT_UNASSIGNED);
sv.getFm().addFaculty(newFaculty);
faculty = newFaculty;
} else {
faculty = sv.getFm().getFaculty(data.faculty());
}
if (Objects.isNull(sv.getFm().getGm().getGroup(data.group()))) {
Group newGroup = new Group("Unassigned");
sv.getFm().getGm().addGroup(newGroup);
group = newGroup;
} else {
group = sv.getFm().getGm().getGroup(data.group());
}
Student newStudent = new Student(data.name(), data.surname(), group, faculty);
students.add(newStudent);
public void addStudent(Student student) {
student.getGroup().addStudent(student);
students.add(student);
}
public List<Student> getStudents() {
return students;
}
@@ -50,13 +30,8 @@ public class StudentManager implements Serializable {
return null;
}
public void deleteStudent(FullStudentData data) {
students.removeIf(student ->
student.getName().equals(data.name()) &&
student.getSurname().equals(data.surname()) &&
student.getGroup().getName().equals(data.group()) &&
student.getFaculty().getName().equals(data.faculty())
);
public void deleteStudent(Student student) {
students.remove(student);
}
}

View File

@@ -7,6 +7,8 @@ import org.lumijiez.util.FullStudentData;
import org.lumijiez.base.Student;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
public class Supervisor implements Serializable {
private final FacultyManager fm;
@@ -15,6 +17,51 @@ public class Supervisor implements Serializable {
this.fm = new FacultyManager();
}
public void addFaculty(Faculty faculty) {
getFm().addFaculty(faculty);
}
public void deleteFaculty(Faculty faculty) {
fm.deleteFaculty(faculty);
for (Group gr : faculty.getGroups()) {
getFm().getGm().deleteGroup(gr);
for (Student st : gr.getStudents()) {
getFm().getGm().getSm().deleteStudent(st);
}
}
}
public void editGroup(Group group, String name, Faculty faculty) {
group.setName(name);
Faculty oldFac = group.getFaculty();
group.setFaculty(faculty);
faculty.addGroup(group);
oldFac.getGroups().remove(group);
}
public void deleteGroup(Group group) {
getFm().getGm().deleteGroup(group);
for (Student st : group.getStudents()) {
getFm().getGm().getSm().deleteStudent(st);
}
}
public void addStudent(String name, String surname, Group group, Faculty faculty, Date birth, Date enrol) {
Student newStudent = new Student(name, surname, group, faculty, birth, enrol);
getFm().getGm().getSm().addStudent(newStudent);
group.addStudent(newStudent);
}
public void addGroup(Group group, Faculty faculty) {
group.setFaculty(faculty);
faculty.addGroup(group);
getFm().getGm().addGroup(group);
}
public void deleteStudent(Student st) {
st.getGroup().deleteStudent(st);
getFm().getGm().getSm().deleteStudent(st);
}
public String getStudentsText() {
StringBuilder info = new StringBuilder();
for (Student st : fm.getGm().getSm().getStudents()) {