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