Added null checking, fixed overwriting
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class Student implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return fullname;
|
return fullname + " | " + group.getName() + " | " + faculty.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui;
|
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.DataDeserializer;
|
||||||
import org.lumijiez.data.DataSerializer;
|
import org.lumijiez.data.DataSerializer;
|
||||||
import org.lumijiez.gui.forms.faculty.AddFacultyForm;
|
import org.lumijiez.gui.forms.faculty.AddFacultyForm;
|
||||||
@@ -40,15 +37,15 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
|
|
||||||
public StudentManagementGUI() {
|
public StudentManagementGUI() {
|
||||||
sv = DataDeserializer.deserialize();
|
sv = DataDeserializer.deserialize();
|
||||||
this.setSize(new Dimension(1280, 720));
|
this.setSize(650, 720);
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
JMenuItem loadBatchOption = new JMenuItem("Load as Batch", UIManager.getIcon("FileView.directoryIcon"));
|
JMenuItem loadBatchOption = new JMenuItem("Load as Batch", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
JMenuItem saveAsOption = new JMenuItem("Save As", UIManager.getIcon("FileView.directoryIcon"));
|
JMenuItem saveAsOption = new JMenuItem("Save As (WIP)", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
JMenuItem saveAndExitOption = new JMenuItem("Save and Exit", UIManager.getIcon("FileView.directoryIcon"));
|
JMenuItem saveAndExitOption = new JMenuItem("Save and Exit", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
JMenuItem settingsOption = new JMenuItem("Settings", UIManager.getIcon("FileView.directoryIcon"));
|
JMenuItem settingsOption = new JMenuItem("Settings (WIP)", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
JMenuItem showAllStudentsOption = new JMenuItem("Show All Students", UIManager.getIcon("FileView.directoryIcon"));
|
JMenuItem showAllStudentsOption = new JMenuItem("Show All Students", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
JMenuItem showParticularStudentOption = new JMenuItem("Show a Student", UIManager.getIcon("FileView.directoryIcon"));
|
JMenuItem showParticularStudentOption = new JMenuItem("Show a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
JMenuItem showStudentGrade = new JMenuItem("Show Student Grades", UIManager.getIcon("FileView.directoryIcon"));
|
JMenuItem showStudentGrade = new JMenuItem("Show Student Grades", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
@@ -80,7 +77,7 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
facultyMenu.setText("Faculty Options");
|
facultyMenu.setText("Faculty Options");
|
||||||
|
|
||||||
mainTextLabel.setEditable(false);
|
mainTextLabel.setEditable(false);
|
||||||
mainTextLabel.setFont(new java.awt.Font("Segoe UI", 0, 14));
|
mainTextLabel.setFont(new java.awt.Font("Segoe UI", Font.PLAIN, 14));
|
||||||
mainScrollPane.setViewportView(mainTextLabel);
|
mainScrollPane.setViewportView(mainTextLabel);
|
||||||
|
|
||||||
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.lumijiez.gui.forms.faculty;
|
|||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.enums.StudyField;
|
import org.lumijiez.enums.StudyField;
|
||||||
import org.lumijiez.gui.StudentManagementGUI;
|
|
||||||
import org.lumijiez.gui.util.ComponentDecorator;
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
import org.lumijiez.gui.util.DisplayerManager;
|
import org.lumijiez.gui.util.DisplayerManager;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
@@ -120,6 +119,8 @@ public class AddFacultyForm extends JFrame {
|
|||||||
sv.addFaculty(newFaculty);
|
sv.addFaculty(newFaculty);
|
||||||
DisplayerManager.displayFaculties();
|
DisplayerManager.displayFaculties();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Fill in all the fields!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ package org.lumijiez.gui.forms.group;
|
|||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.gui.StudentManagementGUI;
|
|
||||||
import org.lumijiez.gui.util.ComponentDecorator;
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
import org.lumijiez.gui.util.DisplayerManager;
|
import org.lumijiez.gui.util.DisplayerManager;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
@@ -100,11 +99,15 @@ public class AddGroupForm extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
Group gr = new Group(nameField.getText());
|
if (!nameField.getText().isEmpty()) {
|
||||||
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
Group gr = new Group(nameField.getText());
|
||||||
sv.addGroup(gr, fac);
|
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
DisplayerManager.displayGroups();
|
sv.addGroup(gr, fac);
|
||||||
this.dispose();
|
DisplayerManager.displayGroups();
|
||||||
|
this.dispose();
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Fill in all the fields!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelButtonActionPerformed(ActionEvent evt) {
|
private void cancelButtonActionPerformed(ActionEvent evt) {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ package org.lumijiez.gui.forms.student;
|
|||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.gui.StudentManagementGUI;
|
|
||||||
import org.lumijiez.gui.util.ComponentDecorator;
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
import org.lumijiez.gui.util.DisplayerManager;
|
import org.lumijiez.gui.util.DisplayerManager;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
@@ -261,6 +260,8 @@ public class AddStudentForm extends JFrame {
|
|||||||
sv.addStudent(name, surname, email, group, faculty, birthDate, enrolDate);
|
sv.addStudent(name, surname, email, group, faculty, birthDate, enrolDate);
|
||||||
DisplayerManager.displayStudents();
|
DisplayerManager.displayStudents();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Fill in all the fields!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,36 +7,39 @@ package org.lumijiez.gui.forms.student;
|
|||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.base.Student;
|
import org.lumijiez.base.Student;
|
||||||
import org.lumijiez.gui.StudentManagementGUI;
|
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||||
import org.lumijiez.gui.util.ComponentDecorator;
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
import org.lumijiez.gui.util.DisplayerManager;
|
import org.lumijiez.gui.util.DisplayerManager;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class EditStudentForm extends JFrame {
|
public class EditStudentForm extends JFrame {
|
||||||
Integer[] days = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
private final JLabel bdayLabel = new JLabel();
|
||||||
Integer[] months = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
|
private final JComboBox<Integer> birthdayCombo;
|
||||||
Integer[] years = new Integer[100];
|
private final JComboBox<Integer> birthmonthCombo;
|
||||||
private final Supervisor sv;
|
private final JComboBox<Integer> birthyearCombo;
|
||||||
|
private final JLabel bmonthLabel = new JLabel();
|
||||||
|
private final JLabel byearLabel = new JLabel();
|
||||||
private final JButton cancelButton = new JButton();
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JLabel edayLabel = new JLabel();
|
||||||
private final JTextField emailField = new JTextField();
|
private final JTextField emailField = new JTextField();
|
||||||
private final JLabel emailLabel = new JLabel();
|
private final JLabel emailLabel = new JLabel();
|
||||||
|
private final JLabel emonthLabel = new JLabel();
|
||||||
|
private final JComboBox<Integer> enroldayCombo;
|
||||||
|
private final JComboBox<Integer> enrolmonthCombo;
|
||||||
|
private final JComboBox<Integer> enrolyearCombo;
|
||||||
|
private final JLabel eyearLabel = new JLabel();
|
||||||
private final JComboBox<Faculty> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private final JLabel facultyLabel = new JLabel();
|
private final JLabel facultyLabel = new JLabel();
|
||||||
private final JComboBox<Group> groupCombo;
|
private final JComboBox<Group> groupCombo;
|
||||||
private final JLabel groupLabel = new JLabel();
|
private final JLabel groupLabel = new JLabel();
|
||||||
private final JTextField nameField = new JTextField();
|
private final JTextField nameField = new JTextField();
|
||||||
private final JComboBox<Integer> birthYearField;
|
|
||||||
private final JComboBox<Integer> birthDayField;
|
|
||||||
private final JComboBox<Integer> birthMonthField;
|
|
||||||
private final JComboBox<Integer> enrolDayField;
|
|
||||||
private final JComboBox<Integer> enrolMonthField;
|
|
||||||
private final JComboBox<Integer> enrolYearField;
|
|
||||||
private final JLabel nameLabel = new JLabel();
|
private final JLabel nameLabel = new JLabel();
|
||||||
private final JComboBox<Student> studentCombo;
|
private final JComboBox<Student> studentCombo;
|
||||||
private final JLabel studentLabel = new JLabel();
|
private final JLabel studentLabel = new JLabel();
|
||||||
@@ -44,21 +47,33 @@ public class EditStudentForm extends JFrame {
|
|||||||
private final JTextField surnameField = new JTextField();
|
private final JTextField surnameField = new JTextField();
|
||||||
private final JLabel surnameLabel = new JLabel();
|
private final JLabel surnameLabel = new JLabel();
|
||||||
private final JLabel titleLabel = new JLabel();
|
private final JLabel titleLabel = new JLabel();
|
||||||
private final JLabel birthYearLabel = new javax.swing.JLabel();
|
private final Supervisor sv;
|
||||||
private final JLabel birthDayLabel = new javax.swing.JLabel();
|
|
||||||
private final JLabel birthMonthLabel = new javax.swing.JLabel();
|
|
||||||
private final JLabel enrolDayLabel = new javax.swing.JLabel();
|
|
||||||
private final JLabel enrolMonthLabel = new javax.swing.JLabel();
|
|
||||||
private final JLabel enrolYearLabel = new javax.swing.JLabel();
|
|
||||||
|
|
||||||
public EditStudentForm(Supervisor sv) {
|
public EditStudentForm(Supervisor sv) {
|
||||||
|
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
birthDayField = new JComboBox<>(days);
|
|
||||||
birthMonthField = new JComboBox<>(months);
|
Integer[] days = new Integer[31];
|
||||||
birthYearField = new JComboBox<>(years);
|
for (int i = 0; i < 31; i++) {
|
||||||
enrolDayField = new JComboBox<>(days);
|
days[i] = i + 1;
|
||||||
enrolMonthField = new JComboBox<>(months);
|
}
|
||||||
enrolYearField = new JComboBox<>(years);
|
|
||||||
|
Integer[] months = new Integer[12];
|
||||||
|
for (int i = 0; i < 12; i++) {
|
||||||
|
months[i] = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer[] years = new Integer[100];
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
years[i] = 1970 + i;
|
||||||
|
}
|
||||||
|
|
||||||
|
birthdayCombo = new JComboBox<>(days);
|
||||||
|
birthmonthCombo = new JComboBox<>(months);
|
||||||
|
birthyearCombo = new JComboBox<>(years);
|
||||||
|
enroldayCombo = new JComboBox<>(days);
|
||||||
|
enrolmonthCombo = new JComboBox<>(months);
|
||||||
|
enrolyearCombo = new JComboBox<>(years);
|
||||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||||
@@ -69,178 +84,175 @@ public class EditStudentForm extends JFrame {
|
|||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||||
|
|
||||||
titleLabel.setText("Edit a student");
|
titleLabel.setText("Edit a student");
|
||||||
nameField.setText(((Student) Objects.requireNonNull(studentCombo.getSelectedItem())).getName());
|
|
||||||
submitButton.setText("Submit");
|
submitButton.setText("Submit");
|
||||||
cancelButton.setText("Cancel");
|
surnameLabel.setText("New Surname:");
|
||||||
studentLabel.setText("Student:");
|
studentLabel.setText("Student:");
|
||||||
surnameField.setText(((Student)studentCombo.getSelectedItem()).getSurname());
|
facultyLabel.setText("New faculty:");
|
||||||
emailField.setText(((Student)studentCombo.getSelectedItem()).getEmail());
|
groupLabel.setText("New Group:");
|
||||||
nameLabel.setText("New name:");
|
nameLabel.setText("New name:");
|
||||||
emailLabel.setText("New email:");
|
emailLabel.setText("New email:");
|
||||||
groupLabel.setText("New group:");
|
bdayLabel.setText("New birthday:");
|
||||||
facultyLabel.setText("New faculty:");
|
bmonthLabel.setText("New birthmonth:");
|
||||||
surnameLabel.setText("New surname:");
|
byearLabel.setText("New birthyear:");
|
||||||
// birthYearLabel.setText("Year of Birth:");
|
emonthLabel.setText("New enrol month:");
|
||||||
//
|
eyearLabel.setText("New enrol year:");
|
||||||
// birthDayLabel.setText("Day of Birth:");
|
edayLabel.setText("New enrol day:");
|
||||||
//
|
cancelButton.setText("Cancel");
|
||||||
// birthMonthLabel.setText("Month of Birth:");
|
|
||||||
//
|
studentCombo.addActionListener(this::studentComboActionPerformed);
|
||||||
// enrolDayLabel.setText("Day of Enrollment:");
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
//
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
// enrolMonthLabel.setText("Month of Enrollment:");
|
|
||||||
//
|
|
||||||
// enrolYearLabel.setText("Year of Enrollment:");
|
|
||||||
|
|
||||||
ComponentDecorator.submitButton(submitButton);
|
ComponentDecorator.submitButton(submitButton);
|
||||||
ComponentDecorator.cancelButton(cancelButton);
|
ComponentDecorator.cancelButton(cancelButton);
|
||||||
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
|
||||||
studentCombo.addActionListener(this::studentComboActionPerformed);
|
|
||||||
|
|
||||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||||
|
|
||||||
groupCombo.setSelectedItem(((Student)studentCombo.getSelectedItem()).getGroup());
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
facultyCombo.setSelectedItem(student.getFaculty());
|
||||||
|
groupCombo.setSelectedItem(student.getGroup());
|
||||||
|
emailField.setText(student.getEmail());
|
||||||
|
nameField.setText(student.getName());
|
||||||
|
surnameField.setText(student.getSurname());
|
||||||
|
|
||||||
facultyCombo.setSelectedItem(((Student) studentCombo.getSelectedItem()).getFaculty());
|
Calendar birthCalendar = Calendar.getInstance();
|
||||||
|
Calendar enrolCalendar = Calendar.getInstance();
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
birthCalendar.setTime(student.getDateOfBirth());
|
||||||
|
enrolCalendar.setTime(student.getEnrollmentDate());
|
||||||
|
|
||||||
|
birthdayCombo.setSelectedItem(birthCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
birthmonthCombo.setSelectedItem(birthCalendar.get(Calendar.MONTH) + 1);
|
||||||
|
birthyearCombo.setSelectedItem(birthCalendar.get(Calendar.YEAR));
|
||||||
|
|
||||||
|
enroldayCombo.setSelectedItem(enrolCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
enrolmonthCombo.setSelectedItem(enrolCalendar.get(Calendar.MONTH) + 1);
|
||||||
|
enrolyearCombo.setSelectedItem(enrolCalendar.get(Calendar.YEAR));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(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))
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addGap(25, 25, 25)
|
|
||||||
.addComponent(surnameLabel)
|
|
||||||
.addGap(142, 142, 142)
|
|
||||||
.addComponent(emailLabel)))
|
|
||||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(21, 21, 21)
|
.addGap(25, 25, 25)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(surnameField, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
|
.addComponent(enroldayCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(nameField)
|
.addComponent(edayLabel))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGap(33, 33, 33)
|
||||||
.addGap(5, 5, 5)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(nameLabel))
|
.addComponent(emonthLabel)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addComponent(enrolmonthCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGap(40, 40, 40)
|
||||||
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(birthDayLabel))
|
.addComponent(enrolyearCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(eyearLabel)))
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
||||||
.addComponent(birthMonthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addComponent(birthMonthField))))
|
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addComponent(groupLabel)
|
|
||||||
.addGap(67, 67, 67)
|
|
||||||
.addComponent(facultyLabel)
|
|
||||||
.addGap(51, 51, 51))
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addGap(18, 18, 18)
|
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(groupCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addGap(34, 34, 34)
|
|
||||||
.addComponent(facultyCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
||||||
.addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(cancelButton)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addComponent(submitButton))))
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addGap(32, 32, 32)
|
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addComponent(birthYearLabel)
|
|
||||||
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
|
||||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.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()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(enrolMonthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(nameLabel)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthdayCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(bdayLabel)
|
||||||
|
.addComponent(studentLabel))
|
||||||
|
.addGap(33, 33, 33)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addComponent(surnameLabel)
|
||||||
|
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(bmonthLabel)
|
||||||
|
.addComponent(birthmonthCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(40, 40, 40))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(enrolMonthField, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 151, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(55, 55, 55)))
|
.addGap(16, 16, 16)))
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addComponent(birthyearCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(enrolYearField, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
.addComponent(byearLabel)
|
||||||
.addGap(43, 43, 43))
|
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addComponent(emailLabel)))
|
||||||
.addComponent(enrolYearLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addContainerGap()))))));
|
.addComponent(cancelButton)
|
||||||
|
.addGap(34, 34, 34)
|
||||||
|
.addComponent(submitButton)))
|
||||||
|
.addContainerGap(27, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(titleLabel)
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(13, 13, 13)
|
.addGap(36, 36, 36)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addComponent(studentLabel))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(14, 14, 14)
|
||||||
|
.addComponent(titleLabel)))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(surnameLabel)
|
||||||
.addComponent(nameLabel)
|
.addComponent(nameLabel)
|
||||||
|
.addComponent(emailLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(groupLabel)
|
.addComponent(groupLabel)
|
||||||
.addComponent(facultyLabel))
|
.addComponent(facultyLabel))
|
||||||
.addGap(3, 3, 3)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(groupCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
|
||||||
.addComponent(facultyCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addGap(7, 7, 7)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(11, 11, 11)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(surnameLabel)
|
.addComponent(bdayLabel)
|
||||||
.addGap(5, 5, 5))
|
.addComponent(bmonthLabel))
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(emailLabel)
|
.addComponent(birthdayCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(4, 4, 4)))
|
.addComponent(birthmonthCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(surnameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(byearLabel)
|
||||||
.addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
|
.addComponent(birthyearCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
.addComponent(birthDayLabel)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(birthMonthLabel)
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(birthYearLabel))
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addComponent(edayLabel)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addComponent(emonthLabel))
|
||||||
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(birthMonthField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addComponent(enroldayCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(18, 18, 18)
|
.addComponent(enrolmonthCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(enrolDayLabel)
|
.addComponent(eyearLabel)
|
||||||
.addComponent(enrolMonthLabel)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(enrolYearLabel))
|
.addComponent(enrolyearCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addGap(35, 35, 35)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(enrolDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(submitButton)
|
||||||
.addComponent(enrolMonthField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(cancelButton))
|
||||||
.addComponent(enrolYearField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addContainerGap(25, Short.MAX_VALUE))
|
||||||
.addGap(36, 36, 36)
|
);
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
||||||
.addComponent(cancelButton)
|
|
||||||
.addComponent(submitButton))
|
|
||||||
.addGap(21, 21, 21)));
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,14 +260,6 @@ public class EditStudentForm extends JFrame {
|
|||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void studentComboActionPerformed(ActionEvent actionEvent) {
|
|
||||||
surnameField.setText(((Student) Objects.requireNonNull(studentCombo.getSelectedItem())).getSurname());
|
|
||||||
emailField.setText(((Student)studentCombo.getSelectedItem()).getEmail());
|
|
||||||
nameField.setText(((Student)studentCombo.getSelectedItem()).getName());
|
|
||||||
groupCombo.setSelectedItem(((Student)studentCombo.getSelectedItem()).getGroup());
|
|
||||||
facultyCombo.setSelectedItem(((Student) studentCombo.getSelectedItem()).getFaculty());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
String name = nameField.getText();
|
String name = nameField.getText();
|
||||||
String surname = surnameField.getText();
|
String surname = surnameField.getText();
|
||||||
@@ -263,32 +267,56 @@ public class EditStudentForm extends JFrame {
|
|||||||
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
// int birthYear = (Integer) Objects.requireNonNull(birthYearField.getSelectedItem());
|
int birthYear = (Integer) Objects.requireNonNull(birthyearCombo.getSelectedItem());
|
||||||
// int birthMonth = (Integer) Objects.requireNonNull(birthMonthField.getSelectedItem());
|
int birthMonth = (Integer) Objects.requireNonNull(birthmonthCombo.getSelectedItem());
|
||||||
// int birthDay = (Integer) Objects.requireNonNull(birthDayField.getSelectedItem());
|
int birthDay = (Integer) Objects.requireNonNull(birthdayCombo.getSelectedItem());
|
||||||
// int enrolYear = (Integer) Objects.requireNonNull(enrolYearField.getSelectedItem());
|
int enrolYear = (Integer) Objects.requireNonNull(enrolyearCombo.getSelectedItem());
|
||||||
// int enrolMonth = (Integer) Objects.requireNonNull(enrolMonthField.getSelectedItem());
|
int enrolMonth = (Integer) Objects.requireNonNull(enrolmonthCombo.getSelectedItem());
|
||||||
// int enrolDay = (Integer) Objects.requireNonNull(enrolDayField.getSelectedItem());
|
int enrolDay = (Integer) Objects.requireNonNull(enroldayCombo.getSelectedItem());
|
||||||
//
|
|
||||||
// Calendar birthCalendar = Calendar.getInstance();
|
Calendar birthCalendar = Calendar.getInstance();
|
||||||
// Calendar enrolCalendar = Calendar.getInstance();
|
Calendar enrolCalendar = Calendar.getInstance();
|
||||||
//
|
|
||||||
// birthCalendar.set(Calendar.YEAR, birthYear);
|
birthCalendar.set(Calendar.YEAR, birthYear);
|
||||||
// birthCalendar.set(Calendar.MONTH, birthMonth - 1);
|
birthCalendar.set(Calendar.MONTH, birthMonth - 1);
|
||||||
// birthCalendar.set(Calendar.DAY_OF_MONTH, birthDay);
|
birthCalendar.set(Calendar.DAY_OF_MONTH, birthDay);
|
||||||
//
|
|
||||||
// enrolCalendar.set(Calendar.YEAR, enrolYear);
|
enrolCalendar.set(Calendar.YEAR, enrolYear);
|
||||||
// enrolCalendar.set(Calendar.MONTH, enrolMonth - 1);
|
enrolCalendar.set(Calendar.MONTH, enrolMonth - 1);
|
||||||
// enrolCalendar.set(Calendar.DAY_OF_MONTH, enrolDay);
|
enrolCalendar.set(Calendar.DAY_OF_MONTH, enrolDay);
|
||||||
//
|
|
||||||
// Date birthDate = birthCalendar.getTime();
|
Date birthDate = birthCalendar.getTime();
|
||||||
// Date enrolDate = enrolCalendar.getTime();
|
Date enrolDate = enrolCalendar.getTime();
|
||||||
|
|
||||||
if (!name.isEmpty() && !surname.isEmpty() && !email.isEmpty()) {
|
if (!name.isEmpty() && !surname.isEmpty() && !email.isEmpty()) {
|
||||||
sv.editStudent(student, name, surname, email, group, faculty /*, birthDate, enrolDate*/);
|
sv.editStudent(student, name, surname, email, group, faculty, birthDate, enrolDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayerManager.displayStudents();
|
DisplayerManager.displayStudents();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void studentComboActionPerformed(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
facultyCombo.setSelectedItem(student.getFaculty());
|
||||||
|
groupCombo.setSelectedItem(student.getGroup());
|
||||||
|
emailField.setText(student.getEmail());
|
||||||
|
nameField.setText(student.getName());
|
||||||
|
surnameField.setText(student.getSurname());
|
||||||
|
|
||||||
|
Calendar birthCalendar = Calendar.getInstance();
|
||||||
|
Calendar enrolCalendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
birthCalendar.setTime(student.getDateOfBirth());
|
||||||
|
enrolCalendar.setTime(student.getEnrollmentDate());
|
||||||
|
|
||||||
|
birthdayCombo.setSelectedItem(birthCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
birthmonthCombo.setSelectedItem(birthCalendar.get(Calendar.MONTH) + 1);
|
||||||
|
birthyearCombo.setSelectedItem(birthCalendar.get(Calendar.YEAR));
|
||||||
|
|
||||||
|
enroldayCombo.setSelectedItem(enrolCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
enrolmonthCombo.setSelectedItem(enrolCalendar.get(Calendar.MONTH) + 1);
|
||||||
|
enrolyearCombo.setSelectedItem(enrolCalendar.get(Calendar.YEAR));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.lumijiez.enums.StudyField;
|
|||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@@ -15,37 +16,26 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class FilePicker extends JFrame {
|
public class FilePicker extends JFrame {
|
||||||
private JButton browseButton;
|
|
||||||
private JButton cancelButton;
|
|
||||||
private JScrollPane exampleLabel;
|
|
||||||
private JLabel formatLabel;
|
|
||||||
private JLabel jLabel1;
|
|
||||||
private JTextArea jTextArea2;
|
|
||||||
private JTextPane filePane;
|
private JTextPane filePane;
|
||||||
private JButton submitButton;
|
|
||||||
private JButton submitButton1;
|
|
||||||
private JLabel titleLabel;
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
|
|
||||||
public FilePicker(Supervisor sv) {
|
public FilePicker(Supervisor sv) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
initComponents();
|
initComponents();
|
||||||
};
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
submitButton = new JButton();
|
JButton submitButton = new JButton();
|
||||||
jLabel1 = new JLabel();
|
JLabel titleLabel = new JLabel();
|
||||||
titleLabel = new JLabel();
|
JButton browseButton = new JButton();
|
||||||
browseButton = new JButton();
|
JLabel formatLabel = new JLabel();
|
||||||
formatLabel = new JLabel();
|
JScrollPane exampleLabel = new JScrollPane();
|
||||||
exampleLabel = new JScrollPane();
|
JTextArea jTextArea2 = new JTextArea();
|
||||||
jTextArea2 = new JTextArea();
|
JButton cancelButton = new JButton();
|
||||||
cancelButton = new JButton();
|
|
||||||
submitButton1 = new JButton();
|
|
||||||
filePane = new JTextPane();
|
filePane = new JTextPane();
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("Segoe UI", 0, 24)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("Segoe UI", Font.PLAIN, 24));
|
||||||
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
@@ -54,7 +44,7 @@ public class FilePicker extends JFrame {
|
|||||||
ComponentDecorator.submitButton(submitButton);
|
ComponentDecorator.submitButton(submitButton);
|
||||||
ComponentDecorator.cancelButton(cancelButton);
|
ComponentDecorator.cancelButton(cancelButton);
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setText("Pick a file to load a batch");
|
titleLabel.setText("Pick a file to load a batch");
|
||||||
submitButton.setText("Submit");
|
submitButton.setText("Submit");
|
||||||
@@ -127,15 +117,15 @@ public class FilePicker extends JFrame {
|
|||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(filePane.getText()))) {
|
try (BufferedReader reader = new BufferedReader(new FileReader(filePane.getText()))) {
|
||||||
String line = "1";
|
String line;
|
||||||
String name = null;
|
String name;
|
||||||
String surname = null;
|
String surname;
|
||||||
String email = null;
|
String email;
|
||||||
Date birth = null;
|
Date birth;
|
||||||
Date enrol = null;
|
Date enrol;
|
||||||
String groupName = null;
|
String groupName;
|
||||||
String facultyName = null;
|
String facultyName;
|
||||||
StudyField specialty = null;
|
StudyField specialty;
|
||||||
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -190,18 +180,21 @@ public class FilePicker extends JFrame {
|
|||||||
faculty = sv.getFacultyByName(facultyName);
|
faculty = sv.getFacultyByName(facultyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sv.getGroupByName(groupName) == null) {
|
if (sv.getGroupByName(groupName, faculty) == null) {
|
||||||
group = new Group(groupName);
|
group = new Group(groupName);
|
||||||
sv.addGroup(group, sv.getFacultyByName(facultyName));
|
sv.addGroup(group, sv.getFacultyByName(facultyName));
|
||||||
} else {
|
} else {
|
||||||
group = sv.getGroupByName(groupName);
|
group = sv.getGroupByName(groupName, faculty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println(name + "\n" + surname+ "\n" + email+ "\n" + group.getName()+ "\n" + faculty.getName()+ "\n" + birth+ "\n" + enrol);
|
||||||
|
|
||||||
sv.addStudent(name, surname, email, group, faculty, birth, enrol);
|
sv.addStudent(name, surname, email, group, faculty, birth, enrol);
|
||||||
}
|
}
|
||||||
} catch (IOException | ParseException ex) {
|
} catch (IOException | ParseException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
|
DisplayerManager.displayStudents();
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import org.lumijiez.base.Faculty;
|
|||||||
import org.lumijiez.base.Grade;
|
import org.lumijiez.base.Grade;
|
||||||
import org.lumijiez.base.Group;
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.base.Student;
|
import org.lumijiez.base.Student;
|
||||||
import org.lumijiez.enums.StudyField;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -54,7 +53,7 @@ public class Supervisor implements Serializable {
|
|||||||
getFm().getGm().getSm().addStudent(newStudent);
|
getFm().getGm().getSm().addStudent(newStudent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editStudent(Student student, String name, String surname, String email, Group group, Faculty faculty) {
|
public void editStudent(Student student, String name, String surname, String email, Group group, Faculty faculty, Date birth, Date enrol) {
|
||||||
student.getGroup().deleteStudent(student);
|
student.getGroup().deleteStudent(student);
|
||||||
student.setName(name);
|
student.setName(name);
|
||||||
student.setSurname(surname);
|
student.setSurname(surname);
|
||||||
@@ -63,8 +62,8 @@ public class Supervisor implements Serializable {
|
|||||||
student.setGroup(group);
|
student.setGroup(group);
|
||||||
group.addStudent(student);
|
group.addStudent(student);
|
||||||
student.setFaculty(faculty);
|
student.setFaculty(faculty);
|
||||||
student.setDateOfBirth(student.getDateOfBirth());
|
student.setDateOfBirth(birth);
|
||||||
student.setEnrollmentDate(student.getEnrollmentDate());
|
student.setEnrollmentDate(enrol);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGroup(Group group, Faculty faculty) {
|
public void addGroup(Group group, Faculty faculty) {
|
||||||
@@ -86,9 +85,9 @@ public class Supervisor implements Serializable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Group getGroupByName(String groupName) {
|
public Group getGroupByName(String groupName, Faculty faculty) {
|
||||||
for (Group group : getFm().getGm().getGroups()) {
|
for (Group group : getFm().getGm().getGroups()) {
|
||||||
if (group.getName().equals(groupName))
|
if (group.getName().equals(groupName) && group.getFaculty().equals(faculty))
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user