Batch uploading
This commit is contained in:
@@ -2,8 +2,19 @@ package org.lumijiez;
|
||||
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
java.awt.EventQueue.invokeLater(() -> new StudentManagementGUI().setVisible(true));
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
|
||||
System.err.println("Windows LAF not found!");
|
||||
}
|
||||
|
||||
EventQueue.invokeLater(() -> new StudentManagementGUI().setVisible(true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ 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.*;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.gui.util.FilePicker;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -30,74 +32,52 @@ public class StudentManagementGUI extends JFrame {
|
||||
private static Supervisor sv;
|
||||
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 JMenuItem graduateStudent = new JMenuItem();
|
||||
private final JMenuItem showGraduates = new JMenuItem();
|
||||
private final JMenuItem showEnrolled = new JMenuItem();
|
||||
private final JPopupMenu.Separator studentSeparator = new JPopupMenu.Separator();
|
||||
private final 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();
|
||||
private final JScrollPane mainScrollPane = new javax.swing.JScrollPane();
|
||||
private static final JTextArea mainTextLabel = new javax.swing.JTextArea();
|
||||
|
||||
public StudentManagementGUI() {
|
||||
this.sv = DataDeserializer.deserialize();
|
||||
sv = DataDeserializer.deserialize();
|
||||
this.setSize(new Dimension(1280, 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 saveAndExitOption = new JMenuItem("Save and Exit", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem settingsOption = new JMenuItem("Settings", 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"));
|
||||
JMenuItem graduateStudent = new JMenuItem("Graduate Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem showGraduates = new JMenuItem("Show Graduates", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem showEnrolled = new JMenuItem("Show enrolled", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem gradeStudentOption = new JMenuItem("Grade a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem addStudentOption = new JMenuItem("Add a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem editStudentOption = new JMenuItem("Edit a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem deleteStudentOption = new JMenuItem("Delete a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem showAllGroupsOption = new JMenuItem("Show all Groups", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem showParticularGroupOption = new JMenuItem("Show a Group", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem addGroupOption = new JMenuItem("Add a Group", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem editGroupOption = new JMenuItem("Edit a Group", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem deleteGroupOption = new JMenuItem("Delete a Group", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem showAllFacultiesOption = new JMenuItem("Show all Faculties", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem showParticularFacultyOption = new JMenuItem("Show a Faculty", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem addFacultyOption = new JMenuItem("Add a Faculty", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem editFacultyOption = new JMenuItem("Edit a Faculty", UIManager.getIcon("FileView.directoryIcon"));
|
||||
JMenuItem removeFacultyOption = new JMenuItem("Remove Faculty", UIManager.getIcon("FileView.directoryIcon"));
|
||||
|
||||
JPopupMenu.Separator studentSeparator = new JPopupMenu.Separator();
|
||||
JPopupMenu.Separator groupSeparator = new JPopupMenu.Separator();
|
||||
JPopupMenu.Separator facultySeparator = new JPopupMenu.Separator();
|
||||
|
||||
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");
|
||||
graduateStudent.setText("Graduate student");
|
||||
showGraduates.setText("Show Graduates");
|
||||
showEnrolled.setText("Show Enrolled");
|
||||
|
||||
mainTextLabel.setEditable(false);
|
||||
mainTextLabel.setFont(new java.awt.Font("Segoe UI", 0, 14));
|
||||
@@ -191,7 +171,7 @@ public class StudentManagementGUI extends JFrame {
|
||||
|
||||
setJMenuBar(menuBar);
|
||||
|
||||
StudentManagementGUI.displayStudents();
|
||||
DisplayerManager.displayStudents();
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
@@ -208,68 +188,45 @@ public class StudentManagementGUI extends JFrame {
|
||||
|
||||
private void showGraduatesOptionActionPerformed(ActionEvent actionEvent) {
|
||||
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("=================== Students =====================\n");
|
||||
for (Student st : sv.getFm().getGm().getSm().getStudents()) {
|
||||
if (st.isGraduated()) {
|
||||
text.append("Name: ").append(st.getFullname()).append("\nGroup: ").append(st.getGroup().getName())
|
||||
.append("\nGraduated: ").append("Yes");
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
}
|
||||
mainTextLabel.setText(text.toString());
|
||||
DisplayerManager.displayGraduates();
|
||||
}
|
||||
}
|
||||
|
||||
private void showEnrolledOptionActionPerformed(ActionEvent actionEvent) {
|
||||
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("=================== Students =====================\n");
|
||||
for (Student st : sv.getFm().getGm().getSm().getStudents()) {
|
||||
if (!st.isGraduated()) {
|
||||
text.append("Name: ").append(st.getFullname()).append("\nGroup: ").append(st.getGroup().getName())
|
||||
.append("\nGraduated: ").append("No");
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
}
|
||||
mainTextLabel.setText(text.toString());
|
||||
DisplayerManager.displayEnrolled();
|
||||
}
|
||||
}
|
||||
|
||||
private void graduateStudentOptionActionPerformed(ActionEvent actionEvent) {
|
||||
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||
GraduateStudentForm form = new GraduateStudentForm(sv, mainTextLabel);
|
||||
GraduateStudentForm form = new GraduateStudentForm(sv);
|
||||
form.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void showAllStudentsOptionActionPerformed(ActionEvent actionEvent) {
|
||||
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("=================== Students =====================\n");
|
||||
for (Student st : sv.getFm().getGm().getSm().getStudents()) {
|
||||
text.append("Name: ").append(st.getFullname()).append("\nGroup: ").append(st.getGroup().getName());
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
mainTextLabel.setText(text.toString());
|
||||
DisplayerManager.displayStudents();
|
||||
}
|
||||
}
|
||||
|
||||
private void showAllGroupsOptionActionPerformed(ActionEvent actionEvent) {
|
||||
if (checkGroup() && checkFaculty()) {
|
||||
displayGroups();
|
||||
DisplayerManager.displayGroups();
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteGroupOptionActionPerformed(ActionEvent actionEvent) {
|
||||
if (checkGroup() && checkFaculty()) {
|
||||
DeleteGroupForm form = new DeleteGroupForm(sv, mainTextLabel);
|
||||
DeleteGroupForm form = new DeleteGroupForm(sv);
|
||||
form.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBatchOptionActionPerformed(ActionEvent evt) {
|
||||
|
||||
FilePicker picker = new FilePicker(sv);
|
||||
picker.setVisible(true);
|
||||
}
|
||||
|
||||
private void saveAndExitOptionActionPerformed(ActionEvent evt) {
|
||||
@@ -287,15 +244,7 @@ public class StudentManagementGUI extends JFrame {
|
||||
|
||||
private void showAllFacultiesOptionActionPerformed(ActionEvent evt) {
|
||||
if (checkFaculty()) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("==================== Faculties ======================\n");
|
||||
for (Faculty fac : sv.getFm().getFaculties()) {
|
||||
text.append("Name: ").append(fac.getName()).append("\nSpecialty: ").append(fac.getField().getName())
|
||||
.append("\nAbbreviation: ").append(fac.getAbbreviation())
|
||||
.append("\nNumber of groups: ").append(fac.getGroups().size());
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
mainTextLabel.setText(text.toString());
|
||||
DisplayerManager.displayFaculties();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +260,7 @@ public class StudentManagementGUI extends JFrame {
|
||||
}
|
||||
|
||||
private void addFacultyOptionActionPerformed(ActionEvent evt) {
|
||||
AddFacultyForm form = new AddFacultyForm(sv, mainTextLabel);
|
||||
AddFacultyForm form = new AddFacultyForm(sv);
|
||||
form.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -331,14 +280,14 @@ public class StudentManagementGUI extends JFrame {
|
||||
|
||||
private void editStudentOptionActionPerformed(ActionEvent evt) {
|
||||
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||
EditStudentForm form = new EditStudentForm(sv, mainTextLabel);
|
||||
EditStudentForm form = new EditStudentForm(sv);
|
||||
form.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteStudentOptionActionPerformed(ActionEvent evt) {
|
||||
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||
DeleteStudentForm form = new DeleteStudentForm(sv, mainTextLabel);
|
||||
DeleteStudentForm form = new DeleteStudentForm(sv);
|
||||
form.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -359,14 +308,14 @@ public class StudentManagementGUI extends JFrame {
|
||||
|
||||
private void addGroupOptionActionPerformed(ActionEvent evt) {
|
||||
if (checkFaculty()) {
|
||||
AddGroupForm form = new AddGroupForm(sv, mainTextLabel);
|
||||
AddGroupForm form = new AddGroupForm(sv);
|
||||
form.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void editGroupOptionActionPerformed(ActionEvent evt) {
|
||||
if (checkGroup() && checkFaculty()) {
|
||||
EditGroupForm form = new EditGroupForm(sv, mainTextLabel);
|
||||
EditGroupForm form = new EditGroupForm(sv);
|
||||
form.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -380,14 +329,14 @@ public class StudentManagementGUI extends JFrame {
|
||||
|
||||
private void editFacultyOptionActionPerformed(ActionEvent evt) {
|
||||
if (checkFaculty()) {
|
||||
EditFacultyForm form = new EditFacultyForm(sv, mainTextLabel);
|
||||
EditFacultyForm form = new EditFacultyForm(sv);
|
||||
form.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFacultyOptionActionPerformed(ActionEvent evt) {
|
||||
if (checkFaculty()) {
|
||||
RemoveFacultyForm form = new RemoveFacultyForm(sv, mainTextLabel);
|
||||
RemoveFacultyForm form = new RemoveFacultyForm(sv);
|
||||
form.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -416,37 +365,11 @@ public class StudentManagementGUI extends JFrame {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void displayStudents() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("==================== Students ======================\n");
|
||||
for (Student student : sv.getFm().getGm().getSm().getStudents()) {
|
||||
text.append("Name: ").append(student.getFullname()).append("\nGroup: ").append(student.getGroup().getName())
|
||||
.append("\nEmail:: ").append(student.getEmail()).append("\nGraduated: ").append((student.isGraduated() ? "Yes" : "No"));
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
mainTextLabel.setText(text.toString());
|
||||
public static JTextArea getMainLabel() {
|
||||
return mainTextLabel;
|
||||
}
|
||||
|
||||
public static void displayGroups() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("==================== Groups ======================\n");
|
||||
for (Group group : sv.getFm().getGm().getGroups()) {
|
||||
text.append("Name: ").append(group.getName()).append("\nFaculty: ").append(group.getFaculty().getName())
|
||||
.append("\nNumber of students: ").append(group.getStudents().size());
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
mainTextLabel.setText(text.toString());
|
||||
}
|
||||
|
||||
public static void displayFaculties() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("==================== Faculties ======================\n");
|
||||
for (Faculty fac : sv.getFm().getFaculties()) {
|
||||
text.append("Name: ").append(fac.getName()).append("\nSpecialty: ").append(fac.getField().getName())
|
||||
.append("\nAbbreviation: ").append(fac.getAbbreviation())
|
||||
.append("\nNumber of groups: ").append(fac.getGroups().size());
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
mainTextLabel.setText(text.toString());
|
||||
public static Supervisor getSv() {
|
||||
return sv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ 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;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -13,7 +15,6 @@ import javax.swing.*;
|
||||
|
||||
public class AddFacultyForm extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final JComboBox<String> specialtyCombo = new JComboBox<>();
|
||||
private final JTextField nameField = new JTextField();
|
||||
@@ -24,9 +25,8 @@ public class AddFacultyForm extends JFrame {
|
||||
private final JLabel abbreviationLabel = new JLabel();
|
||||
private final JLabel specialtyLabel = new JLabel();
|
||||
|
||||
public AddFacultyForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
public AddFacultyForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class AddFacultyForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18));
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
|
||||
titleLabel.setText("Add a new faculty");
|
||||
submitButton.setText("Submit");
|
||||
@@ -118,7 +118,7 @@ public class AddFacultyForm extends JFrame {
|
||||
if (!name.isEmpty()) {
|
||||
Faculty newFaculty = new Faculty(name, abbreviation, specialty);
|
||||
sv.addFaculty(newFaculty);
|
||||
StudentManagementGUI.displayFaculties();
|
||||
DisplayerManager.displayFaculties();
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
@@ -17,8 +18,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.util.Objects;
|
||||
|
||||
public class EditFacultyForm extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JTextField abbreviationField = new JTextField();
|
||||
private final JLabel abbreviationLabel = new JLabel();
|
||||
private final JButton cancelButton = new JButton();
|
||||
@@ -31,9 +30,7 @@ public class EditFacultyForm extends JFrame {
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
private final JComboBox<StudyField> specialtyCombo;
|
||||
|
||||
public EditFacultyForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
public EditFacultyForm(Supervisor sv) {
|
||||
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
specialtyCombo = new JComboBox<>(StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||
initComponents();
|
||||
@@ -43,7 +40,7 @@ public class EditFacultyForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
titleLabel.setText("Edit a faculty");
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
@@ -147,7 +144,7 @@ public class EditFacultyForm extends JFrame {
|
||||
((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())));
|
||||
StudentManagementGUI.displayFaculties();
|
||||
DisplayerManager.displayFaculties();
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,25 +7,25 @@ package org.lumijiez.gui.forms.faculty;
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
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;
|
||||
|
||||
public class RemoveFacultyForm extends JFrame {
|
||||
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
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, JTextArea mainTextLabel) {
|
||||
public RemoveFacultyForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
initComponents();
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class RemoveFacultyForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Remove a faculty");
|
||||
submitButton.setText("Submit");
|
||||
@@ -88,7 +88,7 @@ public class RemoveFacultyForm extends JFrame {
|
||||
|
||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||
sv.deleteFaculty(((Faculty)facultyCombo.getSelectedItem()));
|
||||
StudentManagementGUI.displayFaculties();
|
||||
DisplayerManager.displayFaculties();
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class ShowFacultyForm extends JFrame {
|
||||
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
@@ -24,7 +24,6 @@ public class ShowFacultyForm extends JFrame {
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
public ShowFacultyForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
initComponents();
|
||||
@@ -34,7 +33,7 @@ public class ShowFacultyForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Show a faculty");
|
||||
submitButton.setText("Submit");
|
||||
@@ -101,8 +100,7 @@ public class ShowFacultyForm extends JFrame {
|
||||
builder.append("==========\n");
|
||||
builder.append("Groups: ").append("\n");
|
||||
for (Group gr : fac.getGroups())
|
||||
builder.append(gr.getName()).append("\n");
|
||||
builder.append("==========\n");
|
||||
builder.append(gr.getName()).append("\n").append("==========\n");
|
||||
builder.append("===================================================");
|
||||
mainTextLabel.setText(builder.toString());
|
||||
this.dispose();
|
||||
|
||||
@@ -8,17 +8,18 @@ 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;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
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 JTextArea mainTextLabel;
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final JTextField nameField = new JTextField();
|
||||
private final JButton submitButton = new JButton();
|
||||
@@ -27,9 +28,8 @@ public class AddGroupForm extends JFrame {
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
private final JLabel facultyLabel = new JLabel();
|
||||
|
||||
public AddGroupForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
public AddGroupForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
initComponents();
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class AddGroupForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Add a new group");
|
||||
nameField.setText("Name...");
|
||||
@@ -103,7 +103,7 @@ public class AddGroupForm extends JFrame {
|
||||
Group gr = new Group(nameField.getText());
|
||||
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||
sv.addGroup(gr, fac);
|
||||
StudentManagementGUI.displayGroups();
|
||||
DisplayerManager.displayGroups();
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,24 +7,24 @@ package org.lumijiez.gui.forms.group;
|
||||
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;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class DeleteGroupForm extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
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, JTextArea mainTextLabel) {
|
||||
public DeleteGroupForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
initComponents();
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class DeleteGroupForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Delete a group");
|
||||
submitButton.setText("Submit");
|
||||
@@ -88,7 +88,7 @@ public class DeleteGroupForm extends JFrame {
|
||||
|
||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||
sv.deleteGroup(((Group)groupCombo.getSelectedItem()));
|
||||
StudentManagementGUI.displayGroups();
|
||||
DisplayerManager.displayGroups();
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,17 +8,18 @@ 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;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
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 JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
private final JLabel facultyLabel = new JLabel();
|
||||
@@ -28,9 +29,8 @@ public class EditGroupForm extends JFrame {
|
||||
private final JLabel nameLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
public EditGroupForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
public EditGroupForm(Supervisor sv) {
|
||||
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();
|
||||
@@ -40,7 +40,7 @@ public class EditGroupForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Edit a group");
|
||||
nameField.setText("Name...");
|
||||
@@ -56,7 +56,7 @@ public class EditGroupForm extends JFrame {
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);;
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
@@ -118,7 +118,7 @@ public class EditGroupForm extends JFrame {
|
||||
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||
sv.editGroup(gr, nameField.getText(), fac);
|
||||
StudentManagementGUI.displayGroups();
|
||||
DisplayerManager.displayGroups();
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
package org.lumijiez.gui.forms.group;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
@@ -11,13 +12,13 @@ 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.Objects;
|
||||
|
||||
|
||||
public class ShowGroupForm extends JFrame {
|
||||
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Group> groupCombo;
|
||||
@@ -25,7 +26,6 @@ public class ShowGroupForm extends JFrame {
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
public ShowGroupForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
initComponents();
|
||||
@@ -35,7 +35,7 @@ public class ShowGroupForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
titleLabel.setText("Show a group");
|
||||
groupLabel.setText("Group:");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
@@ -8,10 +8,12 @@ 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;
|
||||
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;
|
||||
@@ -82,7 +84,7 @@ public class AddStudentForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Add a new student");
|
||||
submitButton.setText("Submit");
|
||||
@@ -257,7 +259,7 @@ public class AddStudentForm extends JFrame {
|
||||
|
||||
if (!name.isEmpty() && !surname.isEmpty() && !email.isEmpty()) {
|
||||
sv.addStudent(name, surname, email, group, faculty, birthDate, enrolDate);
|
||||
StudentManagementGUI.displayStudents();
|
||||
DisplayerManager.displayStudents();
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.lumijiez.gui.forms.student;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
@@ -16,16 +17,14 @@ import java.util.Objects;
|
||||
|
||||
public class DeleteStudentForm extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
private final JLabel studentLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
public DeleteStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
public DeleteStudentForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
initComponents();
|
||||
}
|
||||
@@ -90,9 +89,7 @@ public class DeleteStudentForm extends JFrame {
|
||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||
sv.deleteStudent(student);
|
||||
|
||||
StudentManagementGUI.displayStudents();
|
||||
|
||||
DisplayerManager.displayStudents();
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,12 @@ import org.lumijiez.base.Group;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
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.Objects;
|
||||
|
||||
@@ -21,7 +23,6 @@ public class EditStudentForm extends JFrame {
|
||||
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 JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JTextField emailField = new JTextField();
|
||||
private final JLabel emailLabel = new JLabel();
|
||||
@@ -50,9 +51,8 @@ public class EditStudentForm extends JFrame {
|
||||
private final JLabel enrolMonthLabel = new javax.swing.JLabel();
|
||||
private final JLabel enrolYearLabel = new javax.swing.JLabel();
|
||||
|
||||
public EditStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
public EditStudentForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
birthDayField = new JComboBox<>(days);
|
||||
birthMonthField = new JComboBox<>(months);
|
||||
birthYearField = new JComboBox<>(years);
|
||||
@@ -69,10 +69,10 @@ public class EditStudentForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Edit a student");
|
||||
nameField.setText(((Student)studentCombo.getSelectedItem()).getName());
|
||||
nameField.setText(((Student) Objects.requireNonNull(studentCombo.getSelectedItem())).getName());
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
studentLabel.setText("Student:");
|
||||
@@ -102,7 +102,7 @@ public class EditStudentForm extends JFrame {
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
studentCombo.addActionListener(this::studentComboActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);;
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
|
||||
@@ -288,7 +288,7 @@ public class EditStudentForm extends JFrame {
|
||||
sv.editStudent(student, name, surname, email, group, faculty /*, birthDate, enrolDate*/);
|
||||
}
|
||||
|
||||
StudentManagementGUI.displayStudents();
|
||||
DisplayerManager.displayStudents();
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ 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.Objects;
|
||||
|
||||
@@ -42,7 +43,7 @@ public class GradeStudentForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18));
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
|
||||
titleLabel.setText("Grade a student");
|
||||
studentLabel.setText("Student:");
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.lumijiez.gui.forms.student;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
@@ -16,17 +17,13 @@ import java.awt.event.ActionEvent;
|
||||
import java.util.Objects;
|
||||
|
||||
public class GraduateStudentForm extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
private final JLabel studentLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
public GraduateStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
public GraduateStudentForm(Supervisor sv) {
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
initComponents();
|
||||
}
|
||||
@@ -35,14 +32,17 @@ public class GraduateStudentForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setText("Graduate a Student");
|
||||
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
|
||||
studentLabel.setText("Student:");
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
titleLabel.setText("Graduate a Student");
|
||||
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
|
||||
submitButton.setBackground(new Color(204, 255, 204));
|
||||
cancelButton.setBackground(new Color(255, 204, 204));
|
||||
@@ -91,7 +91,7 @@ public class GraduateStudentForm extends JFrame {
|
||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||
student.setGraduated(true);
|
||||
StudentManagementGUI.displayStudents();
|
||||
DisplayerManager.displayStudents();
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,11 @@ 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.Objects;
|
||||
|
||||
public class ShowStudentForm extends JFrame {
|
||||
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
@@ -24,7 +23,6 @@ public class ShowStudentForm extends JFrame {
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
public ShowStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
initComponents();
|
||||
@@ -34,7 +32,7 @@ public class ShowStudentForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Show Student");
|
||||
submitButton.setText("Submit");
|
||||
|
||||
@@ -11,12 +11,12 @@ 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.Objects;
|
||||
|
||||
public class ShowStudentGradesForm extends JFrame {
|
||||
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
@@ -25,7 +25,6 @@ public class ShowStudentGradesForm extends JFrame {
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
public ShowStudentGradesForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
initComponents();
|
||||
@@ -35,7 +34,7 @@ public class ShowStudentGradesForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Show Grades");
|
||||
studentLabel.setText("Student:");
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.lumijiez.gui.util;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
|
||||
public class DisplayerManager {
|
||||
public static void displayStudents() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("==================== Students ======================\n");
|
||||
for (Student student : StudentManagementGUI.getSv().getFm().getGm().getSm().getStudents()) {
|
||||
text.append("Name: ").append(student.getFullname()).append("\nGroup: ").append(student.getGroup().getName())
|
||||
.append("\nEmail:: ").append(student.getEmail()).append("\nGraduated: ").append((student.isGraduated() ? "Yes" : "No"));
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
StudentManagementGUI.getMainLabel().setText(text.toString());
|
||||
}
|
||||
|
||||
public static void displayGroups() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("==================== Groups ======================\n");
|
||||
for (Group group : StudentManagementGUI.getSv().getFm().getGm().getGroups()) {
|
||||
text.append("Name: ").append(group.getName()).append("\nFaculty: ").append(group.getFaculty().getName())
|
||||
.append("\nNumber of students: ").append(group.getStudents().size());
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
StudentManagementGUI.getMainLabel().setText(text.toString());
|
||||
}
|
||||
|
||||
public static void displayFaculties() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("==================== Faculties ======================\n");
|
||||
for (Faculty fac : StudentManagementGUI.getSv().getFm().getFaculties()) {
|
||||
text.append("Name: ").append(fac.getName()).append("\nSpecialty: ").append(fac.getField().getName())
|
||||
.append("\nAbbreviation: ").append(fac.getAbbreviation())
|
||||
.append("\nNumber of groups: ").append(fac.getGroups().size());
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
StudentManagementGUI.getMainLabel().setText(text.toString());
|
||||
}
|
||||
|
||||
public static void displayGraduates() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("=================== Students =====================\n");
|
||||
for (Student st : StudentManagementGUI.getSv().getFm().getGm().getSm().getStudents()) {
|
||||
if (st.isGraduated()) {
|
||||
text.append("Name: ").append(st.getFullname()).append("\nGroup: ").append(st.getGroup().getName())
|
||||
.append("\nGraduated: ").append("Yes");
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
}
|
||||
StudentManagementGUI.getMainLabel().setText(text.toString());
|
||||
}
|
||||
|
||||
public static void displayEnrolled() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("=================== Students =====================\n");
|
||||
for (Student st : StudentManagementGUI.getSv().getFm().getGm().getSm().getStudents()) {
|
||||
if (!st.isGraduated()) {
|
||||
text.append("Name: ").append(st.getFullname()).append("\nGroup: ").append(st.getGroup().getName())
|
||||
.append("\nGraduated: ").append("No");
|
||||
text.append("\n===============================================\n");
|
||||
}
|
||||
}
|
||||
StudentManagementGUI.getMainLabel().setText(text.toString());
|
||||
}
|
||||
}
|
||||
207
Lab2/src/main/java/org/lumijiez/gui/util/FilePicker.java
Normal file
207
Lab2/src/main/java/org/lumijiez/gui/util/FilePicker.java
Normal file
@@ -0,0 +1,207 @@
|
||||
package org.lumijiez.gui.util;
|
||||
|
||||
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.event.ActionEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
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();
|
||||
filePane = new JTextPane();
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("Segoe UI", 0, 24)); // NOI18N
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
browseButton.addActionListener(this::browseButtonActionPerformed);
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
titleLabel.setText("Pick a file to load a batch");
|
||||
submitButton.setText("Submit");
|
||||
browseButton.setText("Browse");
|
||||
formatLabel.setText("File format example:");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
|
||||
jTextArea2.setColumns(15);
|
||||
jTextArea2.setRows(5);
|
||||
jTextArea2.setText("name: John\nsurname: Doe\nemail: john.doe@example.com\ngroup: FAF-223\nfaculty: FCIM\nbirthdate: 1998-05-15\nenroldate: 2017-09-01\nspecialty: Mechanical Engineering");
|
||||
exampleLabel.setViewportView(jTextArea2);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(25, 25, 25)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(filePane, GroupLayout.PREFERRED_SIZE, 215, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(browseButton))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(104, 104, 104)
|
||||
.addComponent(cancelButton)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(submitButton))
|
||||
.addComponent(formatLabel)
|
||||
.addComponent(exampleLabel, GroupLayout.PREFERRED_SIZE, 307, GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(33, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(41, 41, 41)
|
||||
.addComponent(titleLabel)
|
||||
.addGap(0, 0, Short.MAX_VALUE)));
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(15, 15, 15)
|
||||
.addComponent(titleLabel)
|
||||
.addGap(7, 7, 7)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addComponent(filePane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(browseButton))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(formatLabel)
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(exampleLabel, GroupLayout.PREFERRED_SIZE, 208, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cancelButton)
|
||||
.addComponent(submitButton))
|
||||
.addGap(23, 23, 23)));
|
||||
pack();
|
||||
}
|
||||
|
||||
private void cancelButtonActionPerformed(ActionEvent evt) {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
private void browseButtonActionPerformed(ActionEvent evt) {
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
int returnVal = fileChooser.showOpenDialog(this);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
java.io.File file = fileChooser.getSelectedFile();
|
||||
filePane.setText(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
||||
while (true) {
|
||||
line = reader.readLine();
|
||||
if (line == null) break;
|
||||
if (line.isEmpty()) line = reader.readLine();
|
||||
name = line.substring("name: ".length());
|
||||
|
||||
line = reader.readLine();
|
||||
if (line == null) break;
|
||||
surname = line.substring("surname: ".length());
|
||||
|
||||
line = reader.readLine();
|
||||
if (line == null) break;
|
||||
email = line.substring("email: ".length());
|
||||
|
||||
line = reader.readLine();
|
||||
if (line == null) break;
|
||||
groupName = line.substring("group: ".length());
|
||||
|
||||
line = reader.readLine();
|
||||
if (line == null) break;
|
||||
facultyName = line.substring("faculty: ".length());
|
||||
|
||||
line = reader.readLine();
|
||||
if (line == null) break;
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
birth = dateFormat.parse(line.substring("birthdate: ".length()));
|
||||
|
||||
line = reader.readLine();
|
||||
if (line == null) break;
|
||||
enrol = dateFormat.parse(line.substring("enroldate: ".length()));
|
||||
|
||||
line = reader.readLine();
|
||||
if (line == null) break;
|
||||
String spec = line.substring("specialty: ".length());
|
||||
|
||||
|
||||
if (StudyField.getEnum(spec) == null) {
|
||||
specialty = StudyField.DEFAULT_UNASSIGNED;
|
||||
} else {
|
||||
specialty = StudyField.getEnum(spec);
|
||||
}
|
||||
|
||||
Faculty faculty;
|
||||
Group group;
|
||||
if (sv.getFacultyByName(facultyName) == null) {
|
||||
assert specialty != null;
|
||||
faculty = new Faculty(facultyName, specialty.getAbbreviation(), specialty);
|
||||
sv.addFaculty(faculty);
|
||||
} else {
|
||||
faculty = sv.getFacultyByName(facultyName);
|
||||
}
|
||||
|
||||
if (sv.getGroupByName(groupName) == null) {
|
||||
group = new Group(groupName);
|
||||
sv.addGroup(group, sv.getFacultyByName(facultyName));
|
||||
} else {
|
||||
group = sv.getGroupByName(groupName);
|
||||
}
|
||||
|
||||
sv.addStudent(name, surname, email, group, faculty, birth, enrol);
|
||||
}
|
||||
} catch (IOException | ParseException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ 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;
|
||||
@@ -77,7 +78,24 @@ public class Supervisor implements Serializable {
|
||||
getFm().getGm().getSm().deleteStudent(st);
|
||||
}
|
||||
|
||||
public Faculty getFacultyByName(String facultyName) {
|
||||
for (Faculty faculty : getFm().getFaculties()) {
|
||||
if (faculty.getName().equals(facultyName))
|
||||
return faculty;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Group getGroupByName(String groupName) {
|
||||
for (Group group : getFm().getGm().getGroups()) {
|
||||
if (group.getName().equals(groupName))
|
||||
return group;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public FacultyManager getFm() {
|
||||
return fm;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user