Implemented all methods marked with WIP
This commit is contained in:
@@ -3,6 +3,7 @@ package org.lumijiez.base;
|
|||||||
import org.lumijiez.enums.StudyField;
|
import org.lumijiez.enums.StudyField;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Faculty implements Serializable {
|
public class Faculty implements Serializable {
|
||||||
@@ -15,7 +16,7 @@ public class Faculty implements Serializable {
|
|||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String abbreviation;
|
private String abbreviation;
|
||||||
private List<Group> groups;
|
private List<Group> groups = new ArrayList<>();
|
||||||
private StudyField field;
|
private StudyField field;
|
||||||
|
|
||||||
public void addGroup(Group group) {
|
public void addGroup(Group group) {
|
||||||
@@ -54,4 +55,9 @@ public class Faculty implements Serializable {
|
|||||||
this.field = field;
|
this.field = field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,4 +54,9 @@ public class Group implements Serializable {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,14 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Student implements Serializable {
|
public class Student implements Serializable {
|
||||||
|
|
||||||
public Student(String name, String surname, Group group, Faculty faculty) {
|
public Student(String name, String surname, Group group, Faculty faculty, Date birth, Date enrol) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
this.fullname = name + " " + surname;
|
this.fullname = name + " " + surname;
|
||||||
this.group = group;
|
this.group = group;
|
||||||
|
this.faculty = faculty;
|
||||||
|
this.dateOfBirth = birth;
|
||||||
|
this.enrollmentDate = enrol;
|
||||||
this.FSD = new FullStudentData(name, surname, group.getName(), faculty.getName());
|
this.FSD = new FullStudentData(name, surname, group.getName(), faculty.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,4 +119,9 @@ public class Student implements Serializable {
|
|||||||
this.dateOfBirth = dateOfBirth;
|
this.dateOfBirth = dateOfBirth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return fullname;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class DataDeserializer {
|
|||||||
if (serializedFile.exists()) {
|
if (serializedFile.exists()) {
|
||||||
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(serializedFile))) {
|
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(serializedFile))) {
|
||||||
manager = (Supervisor) ois.readObject();
|
manager = (Supervisor) ois.readObject();
|
||||||
System.out.println("Manager object deserialized successfully.");
|
System.out.println("Supervisor object deserialized successfully.");
|
||||||
} catch (IOException | ClassNotFoundException e) {
|
} catch (IOException | ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class DataSerializer {
|
|||||||
public static void serialize(Supervisor manager) {
|
public static void serialize(Supervisor manager) {
|
||||||
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("manager.ser"))) {
|
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("manager.ser"))) {
|
||||||
oos.writeObject(manager);
|
oos.writeObject(manager);
|
||||||
System.out.println("Manager object serialized successfully.");
|
System.out.println("Supervisor object serialized successfully.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,4 +46,9 @@ public enum StudyField implements Serializable {
|
|||||||
public static List<StudyField> getAllEnums() {
|
public static List<StudyField> getAllEnums() {
|
||||||
return Arrays.asList(values());
|
return Arrays.asList(values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
package org.lumijiez.gui;
|
package org.lumijiez.gui;
|
||||||
|
|
||||||
import org.lumijiez.base.Faculty;
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
import org.lumijiez.data.DataDeserializer;
|
import org.lumijiez.data.DataDeserializer;
|
||||||
import org.lumijiez.data.DataSerializer;
|
import org.lumijiez.data.DataSerializer;
|
||||||
import org.lumijiez.gui.forms.faculty.AddFacultyForm;
|
import org.lumijiez.gui.forms.faculty.AddFacultyForm;
|
||||||
@@ -12,6 +14,7 @@ import org.lumijiez.gui.forms.faculty.EditFacultyForm;
|
|||||||
import org.lumijiez.gui.forms.faculty.RemoveFacultyForm;
|
import org.lumijiez.gui.forms.faculty.RemoveFacultyForm;
|
||||||
import org.lumijiez.gui.forms.faculty.ShowFacultyForm;
|
import org.lumijiez.gui.forms.faculty.ShowFacultyForm;
|
||||||
import org.lumijiez.gui.forms.group.AddGroupForm;
|
import org.lumijiez.gui.forms.group.AddGroupForm;
|
||||||
|
import org.lumijiez.gui.forms.group.DeleteGroupForm;
|
||||||
import org.lumijiez.gui.forms.group.EditGroupForm;
|
import org.lumijiez.gui.forms.group.EditGroupForm;
|
||||||
import org.lumijiez.gui.forms.group.ShowGroupForm;
|
import org.lumijiez.gui.forms.group.ShowGroupForm;
|
||||||
import org.lumijiez.gui.forms.student.*;
|
import org.lumijiez.gui.forms.student.*;
|
||||||
@@ -24,44 +27,68 @@ import java.awt.event.WindowEvent;
|
|||||||
|
|
||||||
public class StudentManagementGUI extends JFrame {
|
public class StudentManagementGUI extends JFrame {
|
||||||
private Supervisor sv;
|
private Supervisor sv;
|
||||||
JLabel mainTextLabel = new JLabel();
|
private final JLabel mainTextLabel = new JLabel();
|
||||||
|
private final JMenuBar menuBar = new JMenuBar();
|
||||||
|
private final JMenu fileMenu = new JMenu();
|
||||||
|
private final JMenuItem loadBatchOption = new JMenuItem();
|
||||||
|
private final JMenuItem saveAsOption = new JMenuItem();
|
||||||
|
private final JMenuItem saveAndExitOption = new JMenuItem();
|
||||||
|
private final JMenuItem settingsOption = new JMenuItem();
|
||||||
|
private final JMenu studentMenu = new JMenu();
|
||||||
|
private final JMenuItem showAllStudentsOption = new JMenuItem();
|
||||||
|
private final JMenuItem showParticularStudentOption = new JMenuItem();
|
||||||
|
private final JMenuItem showStudentGrade = new JMenuItem();
|
||||||
|
private final JPopupMenu.Separator studentSeparator = new JPopupMenu.Separator();
|
||||||
|
private final JMenuItem gradeStudentOption = new JMenuItem();
|
||||||
|
private final JMenuItem addStudentOption = new JMenuItem();
|
||||||
|
private final JMenuItem editStudentOption = new JMenuItem();
|
||||||
|
private final JMenuItem deleteStudentOption = new JMenuItem();
|
||||||
|
private final JMenu groupMenu = new JMenu();
|
||||||
|
private final JMenuItem showAllGroupsOption = new JMenuItem();
|
||||||
|
private final JMenuItem showParticularGroupOption = new JMenuItem();
|
||||||
|
private final JPopupMenu.Separator groupSeparator = new JPopupMenu.Separator();
|
||||||
|
private final JMenuItem addGroupOption = new JMenuItem();
|
||||||
|
private final JMenuItem editGroupOption = new JMenuItem();
|
||||||
|
private final JMenuItem deleteGroupOption = new JMenuItem();
|
||||||
|
private final JMenu facultyMenu = new JMenu();
|
||||||
|
private final JMenuItem showAllFacultiesOption = new JMenuItem();
|
||||||
|
private final JMenuItem showParticularFacultyOption = new JMenuItem();
|
||||||
|
private final JPopupMenu.Separator facultySeparator = new JPopupMenu.Separator();
|
||||||
|
private final JMenuItem addFacultyOption = new JMenuItem();
|
||||||
|
private final JMenuItem editFacultyOption = new JMenuItem();
|
||||||
|
private final JMenuItem removeFacultyOption = new JMenuItem();
|
||||||
|
|
||||||
public StudentManagementGUI() {
|
public StudentManagementGUI() {
|
||||||
this.sv = sv;
|
|
||||||
initComponents();
|
|
||||||
this.sv = DataDeserializer.deserialize();
|
this.sv = DataDeserializer.deserialize();
|
||||||
|
initComponents();
|
||||||
}
|
}
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
|
fileMenu.setText("File");
|
||||||
JMenuBar menuBar = new JMenuBar();
|
loadBatchOption.setText("Load Batch File");
|
||||||
JMenu fileMenu = new JMenu();
|
saveAsOption.setText("Save As File");
|
||||||
JMenuItem loadBatchOption = new JMenuItem();
|
saveAndExitOption.setText("Save And Exit");
|
||||||
JMenuItem saveAsOption = new JMenuItem();
|
settingsOption.setText("Settings");
|
||||||
JMenuItem saveAndExitOption = new JMenuItem();
|
studentMenu.setText("Student Options");
|
||||||
JMenuItem settingsOption = new JMenuItem();
|
showAllStudentsOption.setText("Show All Students");
|
||||||
JMenu studentMenu = new JMenu();
|
showParticularStudentOption.setText("Show Student");
|
||||||
JMenuItem showAllStudentsOption = new JMenuItem();
|
showStudentGrade.setText("Show Student Grades");
|
||||||
JMenuItem showParticularStudentOption = new JMenuItem();
|
gradeStudentOption.setText("Grade Student");
|
||||||
JMenuItem showStudentGrade = new JMenuItem();
|
addStudentOption.setText("Add Student");
|
||||||
JPopupMenu.Separator studentSeparator = new JPopupMenu.Separator();
|
editStudentOption.setText("Edit Student");
|
||||||
JMenuItem gradeStudentOption = new JMenuItem();
|
deleteStudentOption.setText("Delete Student");
|
||||||
JMenuItem addStudentOption = new JMenuItem();
|
groupMenu.setText("Group Options");
|
||||||
JMenuItem editStudentOption = new JMenuItem();
|
showAllGroupsOption.setText("Show All Groups");
|
||||||
JMenuItem deleteStudentOption = new JMenuItem();
|
showParticularGroupOption.setText("Show Group");
|
||||||
JMenu groupMenu = new JMenu();
|
addGroupOption.setText("Add Group");
|
||||||
JMenuItem showAllGroupsOption = new JMenuItem();
|
editGroupOption.setText("Edit Group");
|
||||||
JMenuItem showParticularGroupOption = new JMenuItem();
|
deleteGroupOption.setText("Delete Group");
|
||||||
JPopupMenu.Separator groupSeparator = new JPopupMenu.Separator();
|
facultyMenu.setText("Faculty Options");
|
||||||
JMenuItem addGroupOption = new JMenuItem();
|
showAllFacultiesOption.setText("Show Faculties");
|
||||||
JMenuItem editGroupOption = new JMenuItem();
|
showParticularFacultyOption.setText("Show A Faculty");
|
||||||
JMenuItem deleteGroupOption = new JMenuItem();
|
addFacultyOption.setText("Add Faculty");
|
||||||
JMenu facultyMenu = new JMenu();
|
removeFacultyOption.setText("Remove Faculty");
|
||||||
JMenuItem showAllFacultiesOption = new JMenuItem();
|
editFacultyOption.setText("Edit Faculty");
|
||||||
JMenuItem showParticularFacultyOption = new JMenuItem();
|
|
||||||
JPopupMenu.Separator facultySeparator = new JPopupMenu.Separator();
|
|
||||||
JMenuItem addFacultyOption = new JMenuItem();
|
|
||||||
JMenuItem editFacultyOption = new JMenuItem();
|
|
||||||
JMenuItem removeFacultyOption = new JMenuItem();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
|
||||||
@@ -82,103 +109,66 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fileMenu.setText("File");
|
|
||||||
|
|
||||||
loadBatchOption.setText("Load Batch File");
|
|
||||||
loadBatchOption.addActionListener(this::loadBatchOptionActionPerformed);
|
loadBatchOption.addActionListener(this::loadBatchOptionActionPerformed);
|
||||||
fileMenu.add(loadBatchOption);
|
|
||||||
|
|
||||||
saveAsOption.setText("Save As File");
|
|
||||||
saveAsOption.addActionListener(this::saveAsOptionActionPerformed);
|
saveAsOption.addActionListener(this::saveAsOptionActionPerformed);
|
||||||
fileMenu.add(saveAsOption);
|
|
||||||
|
|
||||||
saveAndExitOption.setText("Save And Exit");
|
|
||||||
saveAndExitOption.addActionListener(this::saveAndExitOptionActionPerformed);
|
saveAndExitOption.addActionListener(this::saveAndExitOptionActionPerformed);
|
||||||
fileMenu.add(saveAndExitOption);
|
|
||||||
|
|
||||||
settingsOption.setText("Settings");
|
fileMenu.add(loadBatchOption);
|
||||||
|
fileMenu.add(saveAsOption);
|
||||||
|
fileMenu.add(saveAndExitOption);
|
||||||
fileMenu.add(settingsOption);
|
fileMenu.add(settingsOption);
|
||||||
|
|
||||||
menuBar.add(fileMenu);
|
menuBar.add(fileMenu);
|
||||||
|
|
||||||
studentMenu.setText("Student Options");
|
|
||||||
|
|
||||||
showAllStudentsOption.setText("Show All Students");
|
|
||||||
studentMenu.add(showAllStudentsOption);
|
|
||||||
|
|
||||||
showParticularStudentOption.setText("Show Student");
|
|
||||||
showParticularStudentOption.addActionListener(this::showParticularStudentOptionActionPerformed);
|
showParticularStudentOption.addActionListener(this::showParticularStudentOptionActionPerformed);
|
||||||
studentMenu.add(showParticularStudentOption);
|
|
||||||
|
|
||||||
showStudentGrade.setText("Show Student Grades");
|
|
||||||
showStudentGrade.addActionListener(this::showStudentGradeActionPerformed);
|
showStudentGrade.addActionListener(this::showStudentGradeActionPerformed);
|
||||||
|
gradeStudentOption.addActionListener(this::gradeStudentOptionActionPerformed);
|
||||||
|
addStudentOption.addActionListener(this::addStudentOptionActionPerformed);
|
||||||
|
editStudentOption.addActionListener(this::editStudentOptionActionPerformed);
|
||||||
|
deleteStudentOption.addActionListener(this::deleteStudentOptionActionPerformed);
|
||||||
|
|
||||||
|
studentMenu.add(showAllStudentsOption);
|
||||||
|
studentMenu.add(showParticularStudentOption);
|
||||||
studentMenu.add(showStudentGrade);
|
studentMenu.add(showStudentGrade);
|
||||||
studentMenu.add(studentSeparator);
|
studentMenu.add(studentSeparator);
|
||||||
|
|
||||||
gradeStudentOption.setText("Grade Student");
|
|
||||||
gradeStudentOption.addActionListener(this::gradeStudentOptionActionPerformed);
|
|
||||||
studentMenu.add(gradeStudentOption);
|
studentMenu.add(gradeStudentOption);
|
||||||
|
|
||||||
addStudentOption.setText("Add Student");
|
|
||||||
addStudentOption.addActionListener(this::addStudentOptionActionPerformed);
|
|
||||||
studentMenu.add(addStudentOption);
|
studentMenu.add(addStudentOption);
|
||||||
|
|
||||||
editStudentOption.setText("Edit Student");
|
|
||||||
editStudentOption.addActionListener(this::editStudentOptionActionPerformed);
|
|
||||||
studentMenu.add(editStudentOption);
|
studentMenu.add(editStudentOption);
|
||||||
|
|
||||||
deleteStudentOption.setText("Delete Student");
|
|
||||||
deleteStudentOption.addActionListener(this::deleteStudentOptionActionPerformed);
|
|
||||||
studentMenu.add(deleteStudentOption);
|
studentMenu.add(deleteStudentOption);
|
||||||
|
|
||||||
menuBar.add(studentMenu);
|
menuBar.add(studentMenu);
|
||||||
|
|
||||||
groupMenu.setText("Group Options");
|
|
||||||
|
|
||||||
showAllGroupsOption.setText("Show All Groups");
|
|
||||||
groupMenu.add(showAllGroupsOption);
|
|
||||||
|
|
||||||
showParticularGroupOption.setText("Show Group");
|
|
||||||
showParticularGroupOption.addActionListener(this::showParticularGroupOptionActionPerformed);
|
showParticularGroupOption.addActionListener(this::showParticularGroupOptionActionPerformed);
|
||||||
|
addGroupOption.addActionListener(this::addGroupOptionActionPerformed);
|
||||||
|
editGroupOption.addActionListener(this::editGroupOptionActionPerformed);
|
||||||
|
|
||||||
|
groupMenu.add(showAllGroupsOption);
|
||||||
groupMenu.add(showParticularGroupOption);
|
groupMenu.add(showParticularGroupOption);
|
||||||
groupMenu.add(groupSeparator);
|
groupMenu.add(groupSeparator);
|
||||||
|
|
||||||
addGroupOption.setText("Add Group");
|
|
||||||
addGroupOption.addActionListener(this::addGroupOptionActionPerformed);
|
|
||||||
groupMenu.add(addGroupOption);
|
groupMenu.add(addGroupOption);
|
||||||
|
|
||||||
editGroupOption.setText("Edit Group");
|
|
||||||
editGroupOption.addActionListener(this::editGroupOptionActionPerformed);
|
|
||||||
groupMenu.add(editGroupOption);
|
groupMenu.add(editGroupOption);
|
||||||
|
|
||||||
deleteGroupOption.setText("Delete Group");
|
|
||||||
groupMenu.add(deleteGroupOption);
|
groupMenu.add(deleteGroupOption);
|
||||||
|
|
||||||
menuBar.add(groupMenu);
|
menuBar.add(groupMenu);
|
||||||
|
|
||||||
facultyMenu.setText("Faculty Options");
|
showAllGroupsOption.addActionListener(this::showAllGroupsOptionActionPerformed);
|
||||||
|
showAllStudentsOption.addActionListener(this::showAllStudentsOptionActionPerformed);
|
||||||
showAllFacultiesOption.setText("Show Faculties");
|
|
||||||
showAllFacultiesOption.addActionListener(this::showAllFacultiesOptionActionPerformed);
|
showAllFacultiesOption.addActionListener(this::showAllFacultiesOptionActionPerformed);
|
||||||
facultyMenu.add(showAllFacultiesOption);
|
|
||||||
|
|
||||||
showParticularFacultyOption.setText("Show A Faculty");
|
|
||||||
showParticularFacultyOption.addActionListener(this::showParticularFacultyOptionActionPerformed);
|
showParticularFacultyOption.addActionListener(this::showParticularFacultyOptionActionPerformed);
|
||||||
|
addFacultyOption.addActionListener(this::addFacultyOptionActionPerformed);
|
||||||
|
editFacultyOption.addActionListener(this::editFacultyOptionActionPerformed);
|
||||||
|
deleteGroupOption.addActionListener(this::deleteGroupOptionActionPerformed);
|
||||||
|
removeFacultyOption.addActionListener(this::removeFacultyOptionActionPerformed);
|
||||||
|
|
||||||
|
facultyMenu.add(showAllFacultiesOption);
|
||||||
facultyMenu.add(showParticularFacultyOption);
|
facultyMenu.add(showParticularFacultyOption);
|
||||||
facultyMenu.add(facultySeparator);
|
facultyMenu.add(facultySeparator);
|
||||||
|
|
||||||
addFacultyOption.setText("Add Faculty");
|
|
||||||
addFacultyOption.addActionListener(this::addFacultyOptionActionPerformed);
|
|
||||||
facultyMenu.add(addFacultyOption);
|
facultyMenu.add(addFacultyOption);
|
||||||
|
|
||||||
editFacultyOption.setText("Edit Faculty");
|
|
||||||
editFacultyOption.addActionListener(this::editFacultyOptionActionPerformed);
|
|
||||||
facultyMenu.add(editFacultyOption);
|
facultyMenu.add(editFacultyOption);
|
||||||
|
|
||||||
removeFacultyOption.setText("Remove Faculty");
|
|
||||||
removeFacultyOption.addActionListener(this::removeFacultyOptionActionPerformed);
|
|
||||||
facultyMenu.add(removeFacultyOption);
|
facultyMenu.add(removeFacultyOption);
|
||||||
|
|
||||||
|
|
||||||
menuBar.add(facultyMenu);
|
menuBar.add(facultyMenu);
|
||||||
|
|
||||||
setJMenuBar(menuBar);
|
setJMenuBar(menuBar);
|
||||||
@@ -187,16 +177,39 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 1280, Short.MAX_VALUE)
|
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 1280, Short.MAX_VALUE));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE)
|
.addComponent(mainTextLabel, GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showAllStudentsOptionActionPerformed(ActionEvent actionEvent) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (Student st : sv.getFm().getGm().getSm().getStudents()) {
|
||||||
|
builder.append(st.getFullname()).append("\n");
|
||||||
|
}
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAllGroupsOptionActionPerformed(ActionEvent actionEvent) {
|
||||||
|
if (checkGroup() && checkFaculty()) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (Group gr : sv.getFm().getGm().getGroups())
|
||||||
|
builder.append(gr.getName()).append("\n");
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteGroupOptionActionPerformed(ActionEvent actionEvent) {
|
||||||
|
if (checkGroup() && checkFaculty()) {
|
||||||
|
DeleteGroupForm form = new DeleteGroupForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadBatchOptionActionPerformed(ActionEvent evt) {
|
private void loadBatchOptionActionPerformed(ActionEvent evt) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -206,8 +219,7 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
StudentManagementGUI.this,
|
StudentManagementGUI.this,
|
||||||
"Are you sure you want to exit?",
|
"Are you sure you want to exit?",
|
||||||
"Confirmation",
|
"Confirmation",
|
||||||
JOptionPane.YES_NO_OPTION
|
JOptionPane.YES_NO_OPTION);
|
||||||
);
|
|
||||||
|
|
||||||
if (result == JOptionPane.YES_OPTION) {
|
if (result == JOptionPane.YES_OPTION) {
|
||||||
DataSerializer.serialize(sv);
|
DataSerializer.serialize(sv);
|
||||||
@@ -216,11 +228,13 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showAllFacultiesOptionActionPerformed(ActionEvent evt) {
|
private void showAllFacultiesOptionActionPerformed(ActionEvent evt) {
|
||||||
StringBuilder builder = new StringBuilder();
|
if (checkFaculty()) {
|
||||||
for (Faculty fc : sv.getFm().getFaculties()) {
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(fc.getName()).append(" ").append(fc.getAbbreviation()).append(" ").append(fc.getField().getName());
|
for (Faculty fc : sv.getFm().getFaculties()) {
|
||||||
|
builder.append(fc.getName()).append(" ").append(fc.getAbbreviation()).append(" ").append(fc.getField().getName());
|
||||||
|
}
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
}
|
}
|
||||||
mainTextLabel.setText(builder.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveAsOptionActionPerformed(ActionEvent evt) {
|
private void saveAsOptionActionPerformed(ActionEvent evt) {
|
||||||
@@ -228,8 +242,10 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showParticularGroupOptionActionPerformed(ActionEvent evt) {
|
private void showParticularGroupOptionActionPerformed(ActionEvent evt) {
|
||||||
ShowGroupForm form = new ShowGroupForm(sv, mainTextLabel);
|
if (checkGroup() && checkFaculty()) {
|
||||||
form.setVisible(true);
|
ShowGroupForm form = new ShowGroupForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFacultyOptionActionPerformed(ActionEvent evt) {
|
private void addFacultyOptionActionPerformed(ActionEvent evt) {
|
||||||
@@ -238,57 +254,103 @@ public class StudentManagementGUI extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addStudentOptionActionPerformed(ActionEvent evt) {
|
private void addStudentOptionActionPerformed(ActionEvent evt) {
|
||||||
AddStudentForm form = new AddStudentForm(sv, mainTextLabel);
|
if (checkGroup() && checkFaculty()) {
|
||||||
form.setVisible(true);
|
AddStudentForm form = new AddStudentForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gradeStudentOptionActionPerformed(ActionEvent evt) {
|
private void gradeStudentOptionActionPerformed(ActionEvent evt) {
|
||||||
GradeStudentForm form = new GradeStudentForm(sv, mainTextLabel);
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
form.setVisible(true);
|
GradeStudentForm form = new GradeStudentForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editStudentOptionActionPerformed(ActionEvent evt) {
|
private void editStudentOptionActionPerformed(ActionEvent evt) {
|
||||||
EditStudentForm form = new EditStudentForm(sv, mainTextLabel);
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
form.setVisible(true);
|
EditStudentForm form = new EditStudentForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteStudentOptionActionPerformed(ActionEvent evt) {
|
private void deleteStudentOptionActionPerformed(ActionEvent evt) {
|
||||||
DeleteStudentForm form = new DeleteStudentForm(sv, mainTextLabel);
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
form.setVisible(true);
|
DeleteStudentForm form = new DeleteStudentForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showStudentGradeActionPerformed(ActionEvent evt) {
|
private void showStudentGradeActionPerformed(ActionEvent evt) {
|
||||||
ShowStudentGradesForm form = new ShowStudentGradesForm(sv, mainTextLabel);
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
form.setVisible(true);
|
ShowStudentGradesForm form = new ShowStudentGradesForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showParticularStudentOptionActionPerformed(ActionEvent evt) {
|
private void showParticularStudentOptionActionPerformed(ActionEvent evt) {
|
||||||
ShowStudentForm form = new ShowStudentForm(sv, mainTextLabel);
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
form.setVisible(true);
|
ShowStudentForm form = new ShowStudentForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addGroupOptionActionPerformed(ActionEvent evt) {
|
private void addGroupOptionActionPerformed(ActionEvent evt) {
|
||||||
AddGroupForm form = new AddGroupForm(sv, mainTextLabel);
|
if (checkFaculty()) {
|
||||||
form.setVisible(true);
|
AddGroupForm form = new AddGroupForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editGroupOptionActionPerformed(ActionEvent evt) {
|
private void editGroupOptionActionPerformed(ActionEvent evt) {
|
||||||
EditGroupForm form = new EditGroupForm(sv, mainTextLabel);
|
if (checkGroup() && checkFaculty()) {
|
||||||
form.setVisible(true);
|
EditGroupForm form = new EditGroupForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showParticularFacultyOptionActionPerformed(ActionEvent evt) {
|
private void showParticularFacultyOptionActionPerformed(ActionEvent evt) {
|
||||||
ShowFacultyForm form = new ShowFacultyForm(sv, mainTextLabel);
|
if (checkFaculty()) {
|
||||||
form.setVisible(true);
|
ShowFacultyForm form = new ShowFacultyForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editFacultyOptionActionPerformed(ActionEvent evt) {
|
private void editFacultyOptionActionPerformed(ActionEvent evt) {
|
||||||
EditFacultyForm form = new EditFacultyForm(sv, mainTextLabel);
|
if (checkFaculty()) {
|
||||||
form.setVisible(true);
|
EditFacultyForm form = new EditFacultyForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeFacultyOptionActionPerformed(ActionEvent evt) {
|
private void removeFacultyOptionActionPerformed(ActionEvent evt) {
|
||||||
RemoveFacultyForm form = new RemoveFacultyForm(sv, mainTextLabel);
|
if (checkFaculty()) {
|
||||||
form.setVisible(true);
|
RemoveFacultyForm form = new RemoveFacultyForm(sv, mainTextLabel);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkFaculty() {
|
||||||
|
if (sv.getFm().getFaculties().isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Configure a faculty!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkGroup() {
|
||||||
|
if (sv.getFm().getGm().getGroups().isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Configure a group!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkStudent() {
|
||||||
|
if (sv.getFm().getGm().getSm().getStudents().isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(null, "No students in database!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ import javax.swing.text.Style;
|
|||||||
public class AddFacultyForm extends JFrame {
|
public class AddFacultyForm extends JFrame {
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JComboBox<String> specialtyCombo = new JComboBox<>();
|
||||||
|
private final JTextField nameField = new JTextField();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JLabel nameLabel = new JLabel();
|
||||||
|
private final JTextField abbreviationField = new JTextField();
|
||||||
|
private final JLabel abbreviationLabel = new JLabel();
|
||||||
|
private final JLabel specialtyLabel = new JLabel();
|
||||||
|
|
||||||
private JLabel titleLabel = new JLabel();
|
|
||||||
private JComboBox<String> specialtyCombo = new JComboBox<>();
|
|
||||||
private JTextField nameField = new JTextField();
|
|
||||||
private JButton submitButton = new JButton();
|
|
||||||
private JButton cancelButton = new JButton();
|
|
||||||
private JLabel nameLabel = new JLabel();
|
|
||||||
private JTextField abbreviationField = new JTextField();
|
|
||||||
private JLabel abbreviationLabel = new JLabel();
|
|
||||||
private JLabel specialtyLabel = new JLabel();
|
|
||||||
public AddFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
public AddFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
@@ -33,8 +33,16 @@ public class AddFacultyForm extends JFrame {
|
|||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18));
|
||||||
|
|
||||||
titleLabel.setText("Add a new faculty");
|
titleLabel.setText("Add a new faculty");
|
||||||
|
nameField.setText("Name...");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
nameLabel.setText("Name:");
|
||||||
|
abbreviationField.setText("Abbreviation...");
|
||||||
|
abbreviationLabel.setText("Abbreviation:");
|
||||||
|
specialtyLabel.setText("Specialty Field:");
|
||||||
|
|
||||||
String[] enumList = new String[StudyField.getAllEnums().size()];
|
String[] enumList = new String[StudyField.getAllEnums().size()];
|
||||||
List<StudyField> sfl = StudyField.getAllEnums();
|
List<StudyField> sfl = StudyField.getAllEnums();
|
||||||
@@ -42,26 +50,13 @@ public class AddFacultyForm extends JFrame {
|
|||||||
enumList[i] = sfl.get(i).getName();
|
enumList[i] = sfl.get(i).getName();
|
||||||
|
|
||||||
specialtyCombo.setModel(new DefaultComboBoxModel<>(enumList));
|
specialtyCombo.setModel(new DefaultComboBoxModel<>(enumList));
|
||||||
specialtyCombo.addActionListener(this::specialtyComboActionPerformed);
|
|
||||||
|
|
||||||
nameField.setText("Name...");
|
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
specialtyCombo.addActionListener(this::specialtyComboActionPerformed);
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
nameLabel.setText("Name:");
|
|
||||||
|
|
||||||
abbreviationField.setText("Abbreviation...");
|
|
||||||
|
|
||||||
abbreviationLabel.setText("Abbreviation:");
|
|
||||||
|
|
||||||
specialtyLabel.setText("Specialty Field:");
|
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
@@ -91,6 +86,7 @@ public class AddFacultyForm extends JFrame {
|
|||||||
.addGap(0, 0, Short.MAX_VALUE)
|
.addGap(0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(titleLabel)
|
.addComponent(titleLabel)
|
||||||
.addGap(149, 149, 149)));
|
.addGap(149, 149, 149)));
|
||||||
|
|
||||||
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(7, 7, 7)
|
.addGap(7, 7, 7)
|
||||||
@@ -110,7 +106,6 @@ public class AddFacultyForm extends JFrame {
|
|||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(24, Short.MAX_VALUE)));
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,12 +114,12 @@ public class AddFacultyForm extends JFrame {
|
|||||||
String abbreviation = abbreviationField.getText();
|
String abbreviation = abbreviationField.getText();
|
||||||
StudyField specialty = StudyField.getEnum(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString());
|
StudyField specialty = StudyField.getEnum(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString());
|
||||||
Faculty newFaculty = new Faculty(name, abbreviation, specialty);
|
Faculty newFaculty = new Faculty(name, abbreviation, specialty);
|
||||||
sv.getFm().addFaculty(newFaculty);
|
sv.addFaculty(newFaculty);
|
||||||
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void specialtyComboActionPerformed(ActionEvent evt) {
|
private void specialtyComboActionPerformed(ActionEvent evt) {
|
||||||
abbreviationField.setText(StudyField.getAbbrevFromString(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString()));
|
abbreviationField.setText(StudyField.getAbbrevFromString(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString()));
|
||||||
this.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelButtonActionPerformed(ActionEvent evt) {
|
private void cancelButtonActionPerformed(ActionEvent evt) {
|
||||||
|
|||||||
@@ -4,74 +4,81 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.faculty;
|
package org.lumijiez.gui.forms.faculty;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.enums.StudyField;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class EditFacultyForm extends JFrame {
|
public class EditFacultyForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JTextField abbreviationField;
|
private final JTextField abbreviationField = new JTextField();
|
||||||
private JLabel abbreviationLabel;
|
private final JLabel abbreviationLabel = new JLabel();
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JComboBox<String> facultyCombo;
|
private final JLabel facultyLabel = new JLabel();
|
||||||
private JLabel facultyLabel;
|
private final JTextField nameField = new JTextField();
|
||||||
private JTextField nameField;
|
private final JLabel nameLabel = new JLabel();
|
||||||
private JLabel nameLabel;
|
private final JLabel specialtyLabel = new JLabel();
|
||||||
private JComboBox<String> specialtyCombo;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel specialtyLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private JLabel titleLabel;
|
private final JComboBox<StudyField> specialtyCombo;
|
||||||
|
|
||||||
public EditFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
public EditFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
|
specialtyCombo = new JComboBox<>(StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
nameLabel = new JLabel();
|
|
||||||
nameField = new JTextField();
|
|
||||||
facultyCombo = new JComboBox<>();
|
|
||||||
facultyLabel = new JLabel();
|
|
||||||
abbreviationLabel = new JLabel();
|
|
||||||
abbreviationField = new JTextField();
|
|
||||||
specialtyCombo = new JComboBox<>();
|
|
||||||
specialtyLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
titleLabel.setText("Edit a faculty");
|
titleLabel.setText("Edit a faculty");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
nameLabel.setText("New name:");
|
||||||
|
nameField.setText("Name...");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
abbreviationLabel.setText("New abbreviation:");
|
||||||
|
abbreviationField.setText("Abbreviation...");
|
||||||
|
specialtyLabel.setText("New specialty:");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
|
specialtyCombo.addActionListener(this::specialtyComboActionPerformed);
|
||||||
|
facultyCombo.addActionListener(this::facultyComboActionPerformed);
|
||||||
|
|
||||||
nameLabel.setText("New name:");
|
specialtyCombo.setSelectedItem(((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).getField());
|
||||||
|
|
||||||
nameField.setText("Name...");
|
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Faculty)
|
||||||
|
setText(((Faculty) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
specialtyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
facultyLabel.setText("Faculty:");
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof StudyField)
|
||||||
abbreviationLabel.setText("New abbreviation:");
|
setText(((StudyField) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
abbreviationField.setText("Abbreviation...");
|
}
|
||||||
|
});
|
||||||
specialtyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
|
||||||
|
|
||||||
specialtyLabel.setText("New specialty:");
|
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -102,8 +109,8 @@ public class EditFacultyForm extends JFrame {
|
|||||||
.addGap(18, 18, 18)
|
.addGap(18, 18, 18)
|
||||||
.addComponent(submitButton)))
|
.addComponent(submitButton)))
|
||||||
.addComponent(nameLabel))))))
|
.addComponent(nameLabel))))))
|
||||||
.addContainerGap(24, Short.MAX_VALUE))
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -129,13 +136,22 @@ public class EditFacultyForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addGap(14, 14, 14))
|
.addGap(14, 14, 14)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void facultyComboActionPerformed(ActionEvent actionEvent) {
|
||||||
|
specialtyCombo.setSelectedItem(((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).getField());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void specialtyComboActionPerformed(ActionEvent actionEvent) {
|
||||||
|
abbreviationField.setText(((StudyField) Objects.requireNonNull(specialtyCombo.getSelectedItem())).getAbbreviation());
|
||||||
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setName(nameField.getText());
|
||||||
|
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setAbbreviation(abbreviationField.getText());
|
||||||
|
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setField(((StudyField) Objects.requireNonNull(specialtyCombo.getSelectedItem())));
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,50 +4,55 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.faculty;
|
package org.lumijiez.gui.forms.faculty;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
public class RemoveFacultyForm extends JFrame {
|
public class RemoveFacultyForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JComboBox<String> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private JLabel facultyLabel;
|
private final JLabel facultyLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public RemoveFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
public RemoveFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
facultyCombo = new JComboBox<>();
|
|
||||||
facultyLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
|
|
||||||
titleLabel.setText("Remove a faculty");
|
titleLabel.setText("Remove a faculty");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
facultyLabel.setText("Faculty:");
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Faculty)
|
||||||
|
setText(((Faculty) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -67,8 +72,8 @@ public class RemoveFacultyForm extends JFrame {
|
|||||||
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(titleLabel)
|
.addComponent(titleLabel)
|
||||||
.addGap(48, 48, 48))
|
.addGap(48, 48, 48)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -82,13 +87,12 @@ public class RemoveFacultyForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(21, Short.MAX_VALUE))
|
.addContainerGap(21, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
sv.deleteFaculty(((Faculty)facultyCombo.getSelectedItem()));
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,50 +4,57 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.faculty;
|
package org.lumijiez.gui.forms.faculty;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
public class ShowFacultyForm extends JFrame {
|
public class ShowFacultyForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JComboBox<String> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private JLabel facultyLabel;
|
private final JLabel facultyLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public ShowFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
public ShowFacultyForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
facultyCombo = new JComboBox<>();
|
|
||||||
facultyLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
|
|
||||||
titleLabel.setText("Show a faculty");
|
titleLabel.setText("Show a faculty");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
facultyCombo.addActionListener(this::facultyComboActionPerformed);
|
||||||
|
|
||||||
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
facultyLabel.setText("Faculty:");
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Faculty)
|
||||||
|
setText(((Faculty) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -68,8 +75,8 @@ public class ShowFacultyForm extends JFrame {
|
|||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addComponent(facultyCombo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 171, GroupLayout.PREFERRED_SIZE)))))
|
.addComponent(facultyCombo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 171, GroupLayout.PREFERRED_SIZE)))))
|
||||||
.addContainerGap(27, Short.MAX_VALUE))
|
.addContainerGap(27, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -83,13 +90,23 @@ public class ShowFacultyForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(24, Short.MAX_VALUE))
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void facultyComboActionPerformed(ActionEvent actionEvent) {
|
||||||
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Faculty fac = (Faculty) facultyCombo.getSelectedItem();
|
||||||
|
assert fac != null;
|
||||||
|
builder.append("Name: ").append(fac.getName()).append("\n");
|
||||||
|
builder.append("Specialty: ").append(fac.getField()).append("\n");
|
||||||
|
builder.append("Groups: ").append("\n");
|
||||||
|
for (Group gr : fac.getGroups())
|
||||||
|
builder.append(gr.getName()).append("\n");
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,50 +4,59 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.group;
|
package org.lumijiez.gui.forms.group;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class AddGroupForm extends JFrame {
|
public class AddGroupForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JTextField nameField = new JTextField();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JLabel nameLabel = new JLabel();
|
||||||
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
|
||||||
public AddGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
public AddGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
JLabel titleLabel = new JLabel();
|
|
||||||
JTextField nameField = new JTextField();
|
|
||||||
JButton submitButton = new JButton();
|
|
||||||
JButton cancelButton = new JButton();
|
|
||||||
JLabel nameLabel = new JLabel();
|
|
||||||
JComboBox<String> facultyCombo = new JComboBox<>();
|
|
||||||
JLabel facultyLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
titleLabel.setText("Add a new group");
|
|
||||||
|
|
||||||
|
titleLabel.setText("Add a new group");
|
||||||
nameField.setText("Name...");
|
nameField.setText("Name...");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
nameLabel.setText("Name:");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
nameLabel.setText("Name:");
|
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Faculty)
|
||||||
facultyLabel.setText("Faculty:");
|
setText(((Faculty) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -71,8 +80,8 @@ public class AddGroupForm extends JFrame {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(38, 38, 38)
|
.addGap(38, 38, 38)
|
||||||
.addComponent(titleLabel)))
|
.addComponent(titleLabel)))
|
||||||
.addContainerGap(29, Short.MAX_VALUE))
|
.addContainerGap(29, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -90,13 +99,14 @@ public class AddGroupForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addGap(15, 15, 15))
|
.addGap(15, 15, 15)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
Group gr = new Group(nameField.getText());
|
||||||
|
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
|
sv.addGroup(gr, fac);
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,49 +4,55 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.group;
|
package org.lumijiez.gui.forms.group;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
public class DeleteGroupForm extends JFrame {
|
public class DeleteGroupForm extends JFrame {
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JComboBox<String> groupCombo;
|
private final JComboBox<Group> groupCombo;
|
||||||
private JLabel groupLabel;
|
private final JLabel groupLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public DeleteGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
public DeleteGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
groupCombo = new JComboBox<>();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
groupLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
titleLabel.setText("Delete a group");
|
|
||||||
|
|
||||||
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
titleLabel.setText("Delete a group");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
groupLabel.setText("Group:");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
groupLabel.setText("Group:");
|
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Group)
|
||||||
|
setText(((Group) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -67,8 +73,8 @@ public class DeleteGroupForm extends JFrame {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(54, 54, 54)
|
.addGap(54, 54, 54)
|
||||||
.addComponent(titleLabel)))
|
.addComponent(titleLabel)))
|
||||||
.addContainerGap(29, Short.MAX_VALUE))
|
.addContainerGap(29, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -82,13 +88,12 @@ public class DeleteGroupForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(18, Short.MAX_VALUE))
|
.addContainerGap(18, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
sv.deleteGroup(((Group)groupCombo.getSelectedItem()));
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,66 +4,73 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.group;
|
package org.lumijiez.gui.forms.group;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.enums.StudyField;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class EditGroupForm extends JFrame {
|
public class EditGroupForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JComboBox<String> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private JLabel facultyLabel;
|
private final JLabel facultyLabel = new JLabel();
|
||||||
private JComboBox<String> groupCombo;
|
private final JComboBox<Group> groupCombo;
|
||||||
private JLabel groupLabel;
|
private final JLabel groupLabel = new JLabel();
|
||||||
private JTextField nameField;
|
private final JTextField nameField = new JTextField();
|
||||||
private JLabel nameLabel;
|
private final JLabel nameLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
public EditGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
public EditGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
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();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
groupCombo = new JComboBox<>();
|
|
||||||
nameField = new JTextField();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
nameLabel = new JLabel();
|
|
||||||
facultyCombo = new JComboBox<>();
|
|
||||||
groupLabel = new JLabel();
|
|
||||||
facultyLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
titleLabel.setText("Edit a group");
|
titleLabel.setText("Edit a group");
|
||||||
|
|
||||||
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
|
||||||
|
|
||||||
nameField.setText("Name...");
|
nameField.setText("Name...");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
nameLabel.setText("New name:");
|
||||||
|
groupLabel.setText("Group:");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
nameLabel.setText("New name:");
|
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Faculty)
|
||||||
|
setText(((Faculty) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
groupLabel.setText("Group:");
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Group)
|
||||||
facultyLabel.setText("Faculty:");
|
setText(((Group) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -91,8 +98,8 @@ public class EditGroupForm extends JFrame {
|
|||||||
.addComponent(facultyLabel)
|
.addComponent(facultyLabel)
|
||||||
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(submitButton))))
|
.addComponent(submitButton))))
|
||||||
.addContainerGap(34, Short.MAX_VALUE))
|
.addContainerGap(34, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -116,13 +123,14 @@ public class EditGroupForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(36, Short.MAX_VALUE))
|
.addContainerGap(36, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
|
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
|
sv.editGroup(gr, nameField.getText(), fac);
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,51 +4,56 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.group;
|
package org.lumijiez.gui.forms.group;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
public class ShowGroupForm extends JFrame {
|
public class ShowGroupForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JComboBox<String> groupCombo;
|
private final JComboBox<Group> groupCombo;
|
||||||
private JLabel groupLabel;
|
private final JLabel groupLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
public ShowGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
public ShowGroupForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
groupCombo = new JComboBox<>();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
groupLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
titleLabel.setText("Show a group");
|
titleLabel.setText("Show a group");
|
||||||
|
groupLabel.setText("Group:");
|
||||||
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
cancelButton.setText("Cancel");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
groupLabel.setText("Group:");
|
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Group)
|
||||||
|
setText(((Group) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -69,8 +74,8 @@ public class ShowGroupForm extends JFrame {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(47, 47, 47)
|
.addGap(47, 47, 47)
|
||||||
.addComponent(titleLabel)))
|
.addComponent(titleLabel)))
|
||||||
.addContainerGap(24, Short.MAX_VALUE))
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -84,13 +89,18 @@ public class ShowGroupForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(25, Short.MAX_VALUE))
|
.addContainerGap(25, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
|
builder.append(gr.getName()).append(" ").append(gr.getFaculty().getName()).append(" \n");
|
||||||
|
for (Student st : gr.getStudents()) {
|
||||||
|
builder.append(st.getFullname()).append("\n");
|
||||||
|
}
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,58 +4,77 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.student;
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
import org.lumijiez.util.FullStudentData;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class AddStudentForm extends JFrame {
|
public class AddStudentForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
private JButton cancelButton;
|
private final JComboBox<Group> groupCombo;
|
||||||
private JTextField emailField;
|
private final JTextField nameField = new javax.swing.JTextField();
|
||||||
private JLabel emailLabel;
|
private final JButton submitButton = new javax.swing.JButton();
|
||||||
private JComboBox<String> facultyCombo;
|
private final JButton cancelButton = new javax.swing.JButton();
|
||||||
private JLabel facultyLabel;
|
private final JLabel nameLabel = new javax.swing.JLabel();
|
||||||
private JComboBox<String> groupCombo;
|
private final JTextField surnameField = new javax.swing.JTextField();
|
||||||
private JLabel groupLabel;
|
private final JTextField emailField = new javax.swing.JTextField();
|
||||||
private JTextField nameField;
|
private final JLabel surnameLabel = new javax.swing.JLabel();
|
||||||
private JLabel nameLabel;
|
private final JLabel emailLabel = new javax.swing.JLabel();
|
||||||
private JButton submitButton;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private JTextField surnameField;
|
private final JLabel groupLabel = new javax.swing.JLabel();
|
||||||
private JLabel surnameLabel;
|
private final JLabel facultyLabel = new javax.swing.JLabel();
|
||||||
private JLabel titleLabel;
|
private final JTextField birthYearField = new javax.swing.JTextField();
|
||||||
|
private final JTextField birthDayField = new javax.swing.JTextField();
|
||||||
public AddStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
private final JTextField birthMonthField = new javax.swing.JTextField();
|
||||||
|
private final JLabel surnameLabel1 = new javax.swing.JLabel();
|
||||||
|
private final JLabel birthDayLabel = new javax.swing.JLabel();
|
||||||
|
private final JLabel birthMonthLabel = new javax.swing.JLabel();
|
||||||
|
private final JLabel enrolDayLabel = new javax.swing.JLabel();
|
||||||
|
private final JTextField enrolDayField = new javax.swing.JTextField();
|
||||||
|
private final JTextField enrolMonthField = new javax.swing.JTextField();
|
||||||
|
private final JLabel enrolMonthLabel = new javax.swing.JLabel();
|
||||||
|
private final JTextField enrolYearField = new javax.swing.JTextField();
|
||||||
|
private final JLabel enrolYearLabel = new javax.swing.JLabel();
|
||||||
|
public AddStudentForm(Supervisor sv) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
|
groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
groupCombo = new JComboBox<>();
|
|
||||||
nameField = new JTextField();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
nameLabel = new JLabel();
|
|
||||||
surnameField = new JTextField();
|
|
||||||
emailField = new JTextField();
|
|
||||||
surnameLabel = new JLabel();
|
|
||||||
emailLabel = new JLabel();
|
|
||||||
facultyCombo = new JComboBox<>();
|
|
||||||
groupLabel = new JLabel();
|
|
||||||
facultyLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
titleLabel.setText("Add a new student");
|
titleLabel.setText("Add a new student");
|
||||||
|
|
||||||
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Faculty)
|
||||||
|
setText(((Faculty) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Group)
|
||||||
|
setText(((Group) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
nameField.setText("Name...");
|
nameField.setText("Name...");
|
||||||
|
|
||||||
@@ -65,7 +84,6 @@ public class AddStudentForm extends JFrame {
|
|||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
cancelButton.setText("Cancel");
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
|
||||||
|
|
||||||
nameLabel.setText("Name:");
|
nameLabel.setText("Name:");
|
||||||
|
|
||||||
@@ -77,18 +95,40 @@ public class AddStudentForm extends JFrame {
|
|||||||
|
|
||||||
emailLabel.setText("Email:");
|
emailLabel.setText("Email:");
|
||||||
|
|
||||||
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
|
||||||
|
|
||||||
groupLabel.setText("Group:");
|
groupLabel.setText("Group:");
|
||||||
|
|
||||||
facultyLabel.setText("Faculty:");
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
birthYearField.setText("Surname...");
|
||||||
|
|
||||||
|
birthDayField.setText("Surname...");
|
||||||
|
|
||||||
|
birthMonthField.setText("Surname...");
|
||||||
|
|
||||||
|
surnameLabel1.setText("Year of Birth:");
|
||||||
|
|
||||||
|
birthDayLabel.setText("Day of Birth:");
|
||||||
|
|
||||||
|
birthMonthLabel.setText("Month of Birth:");
|
||||||
|
|
||||||
|
enrolDayLabel.setText("Day of Enrollment:");
|
||||||
|
|
||||||
|
enrolDayField.setText("Surname...");
|
||||||
|
|
||||||
|
enrolMonthField.setText("Surname...");
|
||||||
|
|
||||||
|
enrolMonthLabel.setText("Month of Enrollment:");
|
||||||
|
|
||||||
|
enrolYearField.setText("Surname...");
|
||||||
|
|
||||||
|
enrolYearLabel.setText("Year of Enrollment:");
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(132, 132, 132)
|
.addGap(132, 132, 132)
|
||||||
.addComponent(titleLabel))
|
.addComponent(titleLabel))
|
||||||
@@ -97,88 +137,144 @@ public class AddStudentForm extends JFrame {
|
|||||||
.addComponent(surnameLabel)
|
.addComponent(surnameLabel)
|
||||||
.addGap(142, 142, 142)
|
.addGap(142, 142, 142)
|
||||||
.addComponent(emailLabel)))
|
.addComponent(emailLabel)))
|
||||||
.addGap(69, 138, Short.MAX_VALUE))
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(21, 21, 21)
|
.addGap(21, 21, 21)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(surnameField, GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
|
|
||||||
.addComponent(nameField)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(5, 5, 5)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
.addComponent(nameLabel)))
|
.addComponent(surnameField, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
.addComponent(nameField)
|
||||||
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addGap(5, 5, 5)
|
||||||
.addComponent(groupLabel)
|
.addComponent(nameLabel))
|
||||||
.addGap(67, 67, 67)
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addComponent(facultyLabel)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(51, 51, 51))
|
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthDayLabel))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(birthMonthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(birthMonthField))))
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addGap(67, 67, 67)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addGap(51, 51, 51))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(groupCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(34, 34, 34)
|
||||||
|
.addComponent(facultyCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(32, 32, 32)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(surnameLabel1)
|
||||||
|
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||||
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(18, 18, 18)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
.addComponent(enrolDayLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(enrolDayField))
|
||||||
|
.addGap(29, 29, 29)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(cancelButton)
|
.addComponent(enrolMonthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
|
||||||
.addComponent(submitButton))
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(enrolMonthField, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||||
.addGap(34, 34, 34)
|
.addGap(55, 55, 55)))
|
||||||
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE))
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
.addComponent(enrolYearField, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||||
|
.addGap(43, 43, 43))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(enrolYearLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addContainerGap())))))
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(titleLabel)
|
.addComponent(titleLabel)
|
||||||
.addGap(13, 13, 13)
|
.addGap(13, 13, 13)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(nameLabel)
|
.addComponent(nameLabel)
|
||||||
.addComponent(groupLabel)
|
.addComponent(groupLabel)
|
||||||
.addComponent(facultyLabel))
|
.addComponent(facultyLabel))
|
||||||
.addGap(3, 3, 3)
|
.addGap(3, 3, 3)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(groupCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(facultyCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(11, 11, 11)
|
.addGap(11, 11, 11)
|
||||||
.addComponent(surnameLabel)
|
.addComponent(surnameLabel)
|
||||||
.addGap(5, 5, 5))
|
.addGap(5, 5, 5))
|
||||||
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(emailLabel)
|
.addComponent(emailLabel)
|
||||||
.addGap(4, 4, 4)))
|
.addGap(4, 4, 4)))
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(surnameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(38, 38, 38)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(birthDayLabel)
|
||||||
|
.addComponent(birthMonthLabel)
|
||||||
|
.addComponent(surnameLabel1))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthMonthField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(enrolDayLabel)
|
||||||
|
.addComponent(enrolMonthLabel)
|
||||||
|
.addComponent(enrolYearLabel))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(enrolDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(enrolMonthField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(enrolYearField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(36, 36, 36)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.addGap(21, 21, 21))
|
||||||
);
|
);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
private void cancelButtonActionPerformed(ActionEvent evt) {
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
String name = nameField.getText();
|
String name = nameField.getText();
|
||||||
String surname = surnameField.getText();
|
String surname = surnameField.getText();
|
||||||
FullStudentData data = new FullStudentData(name, surname, "group", "faculty");
|
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
if (!name.isEmpty() && !surname.isEmpty()) {
|
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
sv.getFm().getGm().getSm().addStudent(data, sv);
|
int birthYear = Integer.parseInt(birthYearField.getText());
|
||||||
mainTextLabel.setText("===== Students =====\n" + sv.getStudentsText());
|
int birthMonth = Integer.parseInt(birthMonthField.getText());
|
||||||
System.out.println(data);
|
int birthDay = Integer.parseInt(birthDayField.getText());
|
||||||
System.out.println("LOL");
|
int enrolYear = Integer.parseInt(enrolYearField.getText());
|
||||||
System.out.println(sv.getStudentsText());
|
int enrolMonth = Integer.parseInt(enrolMonthField.getText());
|
||||||
this.dispose();
|
int enrolDay = Integer.parseInt(enrolDayField.getText());
|
||||||
} else JOptionPane.showMessageDialog(this, "Please fill in all fields.");
|
Date birthDate = new Date(birthYear, birthMonth, birthDay);
|
||||||
|
Date enrolDate = new Date(enrolYear, enrolMonth, enrolDay);
|
||||||
|
sv.addStudent(name, surname, group, faculty, birthDate, enrolDate);
|
||||||
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,49 +4,55 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.student;
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class DeleteStudentForm extends JFrame {
|
public class DeleteStudentForm extends JFrame {
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JComboBox<String> studentCombo;
|
private final JComboBox<Student> studentCombo;
|
||||||
private JLabel studentLabel;
|
private final JLabel studentLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public DeleteStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
public DeleteStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
studentCombo = new JComboBox<>();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
studentLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
titleLabel.setText("Delete Student");
|
titleLabel.setText("Delete Student");
|
||||||
|
|
||||||
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
submitButton.setText("Submit");
|
if (value instanceof Student)
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
setText(((Student) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
}
|
||||||
cancelButton.setText("Cancel");
|
});
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
|
||||||
|
|
||||||
studentLabel.setText("Student:");
|
studentLabel.setText("Student:");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -67,8 +73,8 @@ public class DeleteStudentForm extends JFrame {
|
|||||||
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(titleLabel)
|
.addComponent(titleLabel)
|
||||||
.addGap(51, 51, 51))
|
.addGap(51, 51, 51)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -82,13 +88,13 @@ public class DeleteStudentForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(submitButton)
|
.addComponent(submitButton)
|
||||||
.addComponent(cancelButton))
|
.addComponent(cancelButton))
|
||||||
.addContainerGap(26, Short.MAX_VALUE))
|
.addContainerGap(26, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
sv.deleteStudent(student);
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,90 +4,97 @@
|
|||||||
*/
|
*/
|
||||||
package org.lumijiez.gui.forms.student;
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
import org.lumijiez.managers.Supervisor;
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class EditStudentForm extends JFrame {
|
public class EditStudentForm extends JFrame {
|
||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JTextField emailField;
|
private final JTextField emailField = new JTextField();
|
||||||
private JLabel emailLabel;
|
private final JLabel emailLabel = new JLabel();
|
||||||
private JComboBox<String> facultyCombo;
|
private final JComboBox<Faculty> facultyCombo;
|
||||||
private JLabel facultyLabel;
|
private final JLabel facultyLabel = new JLabel();
|
||||||
private JComboBox<String> groupCombo;
|
private final JComboBox<Group> groupCombo;
|
||||||
private JLabel groupLabel;
|
private final JLabel groupLabel = new JLabel();
|
||||||
private JTextField nameField;
|
private final JTextField nameField = new JTextField();
|
||||||
private JLabel nameLabel;
|
private final JLabel nameLabel = new JLabel();
|
||||||
private JComboBox<String> studentCombo;
|
private final JComboBox<Student> studentCombo;
|
||||||
private JLabel studentLabel;
|
private final JLabel studentLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JTextField surnameField;
|
private final JTextField surnameField = new JTextField();
|
||||||
private JLabel surnameLabel;
|
private final JLabel surnameLabel = new JLabel();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public EditStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
public EditStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
this.mainTextLabel = mainTextLabel;
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||||
|
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||||
|
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
studentCombo = new JComboBox<>();
|
|
||||||
nameField = new JTextField();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
studentLabel = new JLabel();
|
|
||||||
surnameField = new JTextField();
|
|
||||||
emailField = new JTextField();
|
|
||||||
nameLabel = new JLabel();
|
|
||||||
emailLabel = new JLabel();
|
|
||||||
groupCombo = new JComboBox<>();
|
|
||||||
groupLabel = new JLabel();
|
|
||||||
facultyLabel = new JLabel();
|
|
||||||
surnameLabel = new JLabel();
|
|
||||||
facultyCombo = new JComboBox<>();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
|
|
||||||
titleLabel.setText("Edit a student");
|
titleLabel.setText("Edit a student");
|
||||||
|
|
||||||
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
|
||||||
|
|
||||||
nameField.setText("Name...");
|
nameField.setText("Name...");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
surnameField.setText("Surname...");
|
||||||
|
emailField.setText("Email...");
|
||||||
|
nameLabel.setText("New name:");
|
||||||
|
emailLabel.setText("New email:");
|
||||||
|
groupLabel.setText("New group:");
|
||||||
|
facultyLabel.setText("New faculty:");
|
||||||
|
surnameLabel.setText("New surname:");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
studentLabel.setText("Student:");
|
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Faculty)
|
||||||
|
setText(((Faculty) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
surnameField.setText("Surname...");
|
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Group)
|
||||||
|
setText(((Group) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
emailField.setText("Email...");
|
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
nameLabel.setText("New name:");
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value instanceof Student)
|
||||||
emailLabel.setText("New email:");
|
setText(((Student) value).getName());
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
groupCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
}
|
||||||
|
});
|
||||||
groupLabel.setText("New group:");
|
|
||||||
|
|
||||||
facultyLabel.setText("New faculty:");
|
|
||||||
|
|
||||||
surnameLabel.setText("New surname:");
|
|
||||||
|
|
||||||
facultyCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -128,8 +135,8 @@ public class EditStudentForm extends JFrame {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(162, 162, 162)
|
.addGap(162, 162, 162)
|
||||||
.addComponent(titleLabel)))
|
.addComponent(titleLabel)))
|
||||||
.addContainerGap(24, Short.MAX_VALUE))
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -160,13 +167,24 @@ public class EditStudentForm extends JFrame {
|
|||||||
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(24, Short.MAX_VALUE))
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitButtonActionPerformed(ActionEvent evt) {
|
private void submitButtonActionPerformed(ActionEvent evt) {
|
||||||
|
String name = nameField.getText();
|
||||||
|
String surname = surnameField.getText();
|
||||||
|
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
|
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
|
// int birthYear = Integer.parseInt(birthYearField.getText());
|
||||||
|
// int birthMonth = Integer.parseInt(birthMonthField.getText());
|
||||||
|
// int birthDay = Integer.parseInt(birthDayField.getText());
|
||||||
|
// int enrolYear = Integer.parseInt(enrolYearField.getText());
|
||||||
|
// int enrolMonth = Integer.parseInt(enrolMonthField.getText());
|
||||||
|
// int enrolDay = Integer.parseInt(enrolDayField.getText());
|
||||||
|
// Date birthDate = new Date(birthYear, birthMonth, birthDay);
|
||||||
|
// Date enrolDate = new Date(enrolYear, enrolMonth, enrolDay);
|
||||||
|
// sv.addStudent(name, surname, group, faculty, birthDate, enrolDate);
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,15 +13,15 @@ public class GradeStudentForm extends JFrame {
|
|||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JTextField gradeField;
|
private final JTextField gradeField = new JTextField();
|
||||||
private JLabel gradeLabel;
|
private final JLabel gradeLabel = new JLabel();
|
||||||
private JComboBox<String> studentCombo;
|
private final JComboBox<String> studentCombo = new JComboBox<>();
|
||||||
private JLabel studentLabel;
|
private final JLabel studentLabel = new JLabel();
|
||||||
private JComboBox<String> subjectCombo;
|
private final JComboBox<String> subjectCombo = new JComboBox<>();
|
||||||
private JLabel subjectLabel;
|
private final JLabel subjectLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public GradeStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
public GradeStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
@@ -31,41 +31,27 @@ public class GradeStudentForm extends JFrame {
|
|||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
studentCombo = new JComboBox<>();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
subjectLabel = new JLabel();
|
|
||||||
subjectCombo = new JComboBox<>();
|
|
||||||
studentLabel = new JLabel();
|
|
||||||
gradeField = new JTextField();
|
|
||||||
gradeLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18));
|
||||||
titleLabel.setText("Grade a student");
|
|
||||||
|
|
||||||
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
titleLabel.setText("Grade a student");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
subjectLabel.setText("Subject:");
|
||||||
|
gradeField.setText("Grade...");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
gradeLabel.setText("Grade:");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
subjectLabel.setText("Subject:");
|
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||||
|
|
||||||
subjectCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
subjectCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||||
|
|
||||||
studentLabel.setText("Student:");
|
|
||||||
|
|
||||||
gradeField.setText("Grade...");
|
|
||||||
|
|
||||||
gradeLabel.setText("Grade:");
|
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
@@ -98,8 +84,8 @@ public class GradeStudentForm extends JFrame {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(129, 129, 129)
|
.addGap(129, 129, 129)
|
||||||
.addComponent(titleLabel)
|
.addComponent(titleLabel)
|
||||||
.addGap(0, 0, Short.MAX_VALUE))
|
.addGap(0, 0, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -120,9 +106,7 @@ public class GradeStudentForm extends JFrame {
|
|||||||
.addComponent(gradeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(gradeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(30, Short.MAX_VALUE))
|
.addContainerGap(30, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ public class ShowStudentForm extends JFrame {
|
|||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JComboBox<String> studentCombo;
|
private final JComboBox<String> studentCombo = new JComboBox<>();
|
||||||
private JLabel studentLabel;
|
private final JLabel studentLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
public ShowStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
public ShowStudentForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
@@ -27,28 +27,22 @@ public class ShowStudentForm extends JFrame {
|
|||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
studentCombo = new JComboBox<>();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
studentLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
titleLabel.setText("Show Student");
|
|
||||||
|
|
||||||
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
titleLabel.setText("Show Student");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
studentLabel.setText("Student:");
|
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -71,8 +65,8 @@ public class ShowStudentForm extends JFrame {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(52, 52, 52)
|
.addGap(52, 52, 52)
|
||||||
.addComponent(titleLabel)))
|
.addComponent(titleLabel)))
|
||||||
.addContainerGap(23, Short.MAX_VALUE))
|
.addContainerGap(23, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -86,9 +80,7 @@ public class ShowStudentForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(22, Short.MAX_VALUE))
|
.addContainerGap(22, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,11 @@ public class ShowStudentGradesForm extends JFrame {
|
|||||||
|
|
||||||
private final Supervisor sv;
|
private final Supervisor sv;
|
||||||
private final JLabel mainTextLabel;
|
private final JLabel mainTextLabel;
|
||||||
private JButton cancelButton;
|
private final JButton cancelButton = new JButton();
|
||||||
private JComboBox<String> studentCombo;
|
private final JComboBox<String> studentCombo = new JComboBox<>();
|
||||||
private JLabel studentLabel;
|
private final JLabel studentLabel = new JLabel();
|
||||||
private JButton submitButton;
|
private final JButton submitButton = new JButton();
|
||||||
private JLabel titleLabel;
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
|
||||||
|
|
||||||
public ShowStudentGradesForm(Supervisor sv, JLabel mainTextLabel) {
|
public ShowStudentGradesForm(Supervisor sv, JLabel mainTextLabel) {
|
||||||
this.sv = sv;
|
this.sv = sv;
|
||||||
@@ -28,28 +27,22 @@ public class ShowStudentGradesForm extends JFrame {
|
|||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
titleLabel = new JLabel();
|
|
||||||
studentCombo = new JComboBox<>();
|
|
||||||
submitButton = new JButton();
|
|
||||||
cancelButton = new JButton();
|
|
||||||
studentLabel = new JLabel();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||||
titleLabel.setText("Show Grades");
|
|
||||||
|
|
||||||
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
titleLabel.setText("Show Grades");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
submitButton.setText("Submit");
|
|
||||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
|
||||||
|
|
||||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
cancelButton.setText("Cancel");
|
|
||||||
|
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||||
|
|
||||||
studentLabel.setText("Student:");
|
studentCombo.setModel(new DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||||
|
|
||||||
GroupLayout layout = new GroupLayout(getContentPane());
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -72,8 +65,8 @@ public class ShowStudentGradesForm extends JFrame {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(50, 50, 50)
|
.addGap(50, 50, 50)
|
||||||
.addComponent(titleLabel)))
|
.addComponent(titleLabel)))
|
||||||
.addContainerGap(30, Short.MAX_VALUE))
|
.addContainerGap(30, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@@ -87,9 +80,7 @@ public class ShowStudentGradesForm extends JFrame {
|
|||||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(submitButton))
|
.addComponent(submitButton))
|
||||||
.addContainerGap(22, Short.MAX_VALUE))
|
.addContainerGap(22, Short.MAX_VALUE)));
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,30 +15,10 @@ import static org.lumijiez.enums.StudyField.DEFAULT_UNASSIGNED;
|
|||||||
public class StudentManager implements Serializable {
|
public class StudentManager implements Serializable {
|
||||||
private final List<Student> students = new ArrayList<>();
|
private final List<Student> students = new ArrayList<>();
|
||||||
|
|
||||||
public void addStudent(FullStudentData data, Supervisor sv) {
|
public void addStudent(Student student) {
|
||||||
Faculty faculty;
|
student.getGroup().addStudent(student);
|
||||||
Group group;
|
students.add(student);
|
||||||
|
|
||||||
if (Objects.isNull(sv.getFm().getFaculty(data.faculty()))) {
|
|
||||||
Faculty newFaculty = new Faculty(data.faculty(), DEFAULT_UNASSIGNED.getAbbreviation(), DEFAULT_UNASSIGNED);
|
|
||||||
sv.getFm().addFaculty(newFaculty);
|
|
||||||
faculty = newFaculty;
|
|
||||||
} else {
|
|
||||||
faculty = sv.getFm().getFaculty(data.faculty());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Objects.isNull(sv.getFm().getGm().getGroup(data.group()))) {
|
|
||||||
Group newGroup = new Group("Unassigned");
|
|
||||||
sv.getFm().getGm().addGroup(newGroup);
|
|
||||||
group = newGroup;
|
|
||||||
} else {
|
|
||||||
group = sv.getFm().getGm().getGroup(data.group());
|
|
||||||
}
|
|
||||||
|
|
||||||
Student newStudent = new Student(data.name(), data.surname(), group, faculty);
|
|
||||||
students.add(newStudent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Student> getStudents() {
|
public List<Student> getStudents() {
|
||||||
return students;
|
return students;
|
||||||
}
|
}
|
||||||
@@ -50,13 +30,8 @@ public class StudentManager implements Serializable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteStudent(FullStudentData data) {
|
public void deleteStudent(Student student) {
|
||||||
students.removeIf(student ->
|
students.remove(student);
|
||||||
student.getName().equals(data.name()) &&
|
|
||||||
student.getSurname().equals(data.surname()) &&
|
|
||||||
student.getGroup().getName().equals(data.group()) &&
|
|
||||||
student.getFaculty().getName().equals(data.faculty())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import org.lumijiez.util.FullStudentData;
|
|||||||
import org.lumijiez.base.Student;
|
import org.lumijiez.base.Student;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Supervisor implements Serializable {
|
public class Supervisor implements Serializable {
|
||||||
private final FacultyManager fm;
|
private final FacultyManager fm;
|
||||||
@@ -15,6 +17,51 @@ public class Supervisor implements Serializable {
|
|||||||
this.fm = new FacultyManager();
|
this.fm = new FacultyManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addFaculty(Faculty faculty) {
|
||||||
|
getFm().addFaculty(faculty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteFaculty(Faculty faculty) {
|
||||||
|
fm.deleteFaculty(faculty);
|
||||||
|
for (Group gr : faculty.getGroups()) {
|
||||||
|
getFm().getGm().deleteGroup(gr);
|
||||||
|
for (Student st : gr.getStudents()) {
|
||||||
|
getFm().getGm().getSm().deleteStudent(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void editGroup(Group group, String name, Faculty faculty) {
|
||||||
|
group.setName(name);
|
||||||
|
Faculty oldFac = group.getFaculty();
|
||||||
|
group.setFaculty(faculty);
|
||||||
|
faculty.addGroup(group);
|
||||||
|
oldFac.getGroups().remove(group);
|
||||||
|
}
|
||||||
|
public void deleteGroup(Group group) {
|
||||||
|
getFm().getGm().deleteGroup(group);
|
||||||
|
for (Student st : group.getStudents()) {
|
||||||
|
getFm().getGm().getSm().deleteStudent(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addStudent(String name, String surname, Group group, Faculty faculty, Date birth, Date enrol) {
|
||||||
|
Student newStudent = new Student(name, surname, group, faculty, birth, enrol);
|
||||||
|
getFm().getGm().getSm().addStudent(newStudent);
|
||||||
|
group.addStudent(newStudent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addGroup(Group group, Faculty faculty) {
|
||||||
|
group.setFaculty(faculty);
|
||||||
|
faculty.addGroup(group);
|
||||||
|
getFm().getGm().addGroup(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteStudent(Student st) {
|
||||||
|
st.getGroup().deleteStudent(st);
|
||||||
|
getFm().getGm().getSm().deleteStudent(st);
|
||||||
|
}
|
||||||
|
|
||||||
public String getStudentsText() {
|
public String getStudentsText() {
|
||||||
StringBuilder info = new StringBuilder();
|
StringBuilder info = new StringBuilder();
|
||||||
for (Student st : fm.getGm().getSm().getStudents()) {
|
for (Student st : fm.getGm().getSm().getStudents()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user