Implemented generics to reuse code, clean-ups
This commit is contained in:
@@ -24,5 +24,4 @@ public class DataDeserializer {
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,5 +16,4 @@ public class DataSerializer {
|
||||
System.out.println(Arrays.toString(e.getStackTrace()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.lumijiez.gui.forms.faculty;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.enums.StudyField;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -9,13 +10,12 @@ import org.lumijiez.managers.Supervisor;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AddFacultyForm extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final JComboBox<String> specialtyCombo = new JComboBox<>();
|
||||
private final JComboBox<StudyField> specialtyCombo = new JComboBox<>();
|
||||
private final JTextField nameField = new JTextField();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JButton cancelButton = new JButton();
|
||||
@@ -26,7 +26,6 @@ public class AddFacultyForm extends JFrame {
|
||||
|
||||
public AddFacultyForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Add a Faculty");
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -35,6 +34,7 @@ public class AddFacultyForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Add a Faculty");
|
||||
|
||||
titleLabel.setText("Add a new faculty");
|
||||
submitButton.setText("Submit");
|
||||
@@ -43,20 +43,14 @@ public class AddFacultyForm extends JFrame {
|
||||
abbreviationLabel.setText("Abbreviation:");
|
||||
specialtyLabel.setText("Specialty Field:");
|
||||
|
||||
String[] enumList = new String[StudyField.getAllEnums().size()];
|
||||
List<StudyField> sfl = StudyField.getAllEnums();
|
||||
for (int i = 0; i != enumList.length; i++)
|
||||
enumList[i] = sfl.get(i).getName();
|
||||
|
||||
specialtyCombo.setModel(new DefaultComboBoxModel<>(enumList));
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
specialtyCombo.addActionListener(this::specialtyComboActionPerformed);
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderer.setRenderer(specialtyCombo, StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||
|
||||
abbreviationField.setText(StudyField.getAbbrevFromString(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString()));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.lumijiez.gui.forms.faculty;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.enums.StudyField;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -22,15 +22,12 @@ public class EditFacultyForm extends JFrame {
|
||||
private final JLabel specialtyLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
private final JComboBox<StudyField> specialtyCombo;
|
||||
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||
private final JComboBox<StudyField> specialtyCombo = new JComboBox<>();
|
||||
private final Supervisor sv;
|
||||
|
||||
public EditFacultyForm(Supervisor sv) {
|
||||
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
specialtyCombo = new JComboBox<>(StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||
this.sv = sv;
|
||||
this.setTitle("Edit a Faculty");
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -39,6 +36,7 @@ public class EditFacultyForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Edit a Faculty");
|
||||
|
||||
titleLabel.setText("Edit a faculty");
|
||||
submitButton.setText("Submit");
|
||||
@@ -47,8 +45,7 @@ public class EditFacultyForm extends JFrame {
|
||||
facultyLabel.setText("Faculty:");
|
||||
specialtyLabel.setText("New specialty:");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
@@ -57,16 +54,8 @@ public class EditFacultyForm extends JFrame {
|
||||
|
||||
specialtyCombo.setSelectedItem(((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).getField());
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
|
||||
specialtyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof StudyField)
|
||||
setText(((StudyField) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderer.setRenderer(facultyCombo, sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
ComboBoxRenderer.setRenderer(specialtyCombo, StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.lumijiez.gui.forms.faculty;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -14,15 +14,13 @@ public class RemoveFacultyForm extends JFrame {
|
||||
|
||||
private final Supervisor sv;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||
private final JLabel facultyLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
public RemoveFacultyForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Remove a Faculty");
|
||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -31,19 +29,19 @@ public class RemoveFacultyForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Remove a Faculty");
|
||||
|
||||
titleLabel.setText("Remove a faculty");
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
ComboBoxRenderer.setRenderer(facultyCombo, sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.lumijiez.gui.forms.faculty;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
|
||||
@@ -14,15 +14,16 @@ public class ShowFacultyForm extends JFrame {
|
||||
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||
private final JLabel facultyLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
private final Supervisor sv;
|
||||
|
||||
public ShowFacultyForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.setTitle("Show a Faculty");
|
||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -31,19 +32,19 @@ public class ShowFacultyForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Show a Faculty");
|
||||
|
||||
titleLabel.setText("Show a faculty");
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
ComboBoxRenderer.setRenderer(facultyCombo, sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.lumijiez.gui.forms.faculty;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.enums.StudyField;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class ShowSpecialtyFacultyForm extends JFrame {
|
||||
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<StudyField> specialtyCombo;
|
||||
private final JComboBox<StudyField> specialtyCombo = new JComboBox<>();
|
||||
private final JLabel facultyLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
@@ -23,8 +24,6 @@ public class ShowSpecialtyFacultyForm extends JFrame {
|
||||
public ShowSpecialtyFacultyForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.setTitle("Show a Faculty by Specialty");
|
||||
this.specialtyCombo = new JComboBox<>(StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -33,26 +32,19 @@ public class ShowSpecialtyFacultyForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Show a Faculty by Specialty");
|
||||
|
||||
titleLabel.setText("Show a faculty");
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
specialtyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof StudyField)
|
||||
setText(((StudyField) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderer.setRenderer(specialtyCombo, StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.lumijiez.gui.forms.group;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -20,13 +20,11 @@ public class AddGroupForm extends JFrame {
|
||||
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 JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||
private final JLabel facultyLabel = new JLabel();
|
||||
|
||||
public AddGroupForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Add a Group");
|
||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -35,6 +33,7 @@ public class AddGroupForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Add a Group");
|
||||
|
||||
titleLabel.setText("Add a new group");
|
||||
submitButton.setText("Submit");
|
||||
@@ -42,13 +41,12 @@ public class AddGroupForm extends JFrame {
|
||||
nameLabel.setText("Name:");
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
ComboBoxRenderer.setRenderer(facultyCombo, sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.lumijiez.gui.forms.group;
|
||||
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -13,15 +13,13 @@ import java.awt.event.ActionEvent;
|
||||
public class DeleteGroupForm extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Group> groupCombo;
|
||||
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||
private final JLabel groupLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
public DeleteGroupForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Delete a Group");
|
||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -29,20 +27,20 @@ public class DeleteGroupForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Delete a Group");
|
||||
|
||||
titleLabel.setText("Delete a group");
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
groupLabel.setText("Group:");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
ComboBoxRenderer.setRenderer(groupCombo, sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.lumijiez.gui.forms.group;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -16,9 +16,9 @@ public class EditGroupForm extends JFrame {
|
||||
|
||||
private final Supervisor sv;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||
private final JLabel facultyLabel = new JLabel();
|
||||
private final JComboBox<Group> groupCombo;
|
||||
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||
private final JLabel groupLabel = new JLabel();
|
||||
private final JTextField nameField = new JTextField();
|
||||
private final JLabel nameLabel = new JLabel();
|
||||
@@ -27,9 +27,6 @@ public class EditGroupForm extends JFrame {
|
||||
|
||||
public EditGroupForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Edit a Group");
|
||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -38,6 +35,7 @@ public class EditGroupForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Edit a Group");
|
||||
|
||||
titleLabel.setText("Edit a group");
|
||||
submitButton.setText("Submit");
|
||||
@@ -46,14 +44,13 @@ public class EditGroupForm extends JFrame {
|
||||
groupLabel.setText("Group:");
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
ComboBoxRenderer.setRenderer(facultyCombo, sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
ComboBoxRenderer.setRenderer(groupCombo, sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.lumijiez.gui.forms.group;
|
||||
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
|
||||
@@ -16,15 +16,15 @@ public class ShowGroupForm extends JFrame {
|
||||
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Group> groupCombo;
|
||||
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||
private final JLabel groupLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final Supervisor sv;
|
||||
|
||||
public ShowGroupForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.setTitle("Show a Group");
|
||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -33,18 +33,19 @@ public class ShowGroupForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Show a Group");
|
||||
|
||||
titleLabel.setText("Show a group");
|
||||
groupLabel.setText("Group:");
|
||||
cancelButton.setText("Cancel");
|
||||
submitButton.setText("Submit");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
ComboBoxRenderer.setRenderer(groupCombo, sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.lumijiez.gui.forms.student;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -44,7 +44,6 @@ public class AddStudentForm extends JFrame {
|
||||
|
||||
public AddStudentForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Add a Student");
|
||||
|
||||
Integer[] days = new Integer[31];
|
||||
for (int i = 0; i < 31; i++) {
|
||||
@@ -69,9 +68,6 @@ public class AddStudentForm extends JFrame {
|
||||
enrolMonthField.setModel(new DefaultComboBoxModel<>(months));
|
||||
enrolYearField.setModel(new DefaultComboBoxModel<>(years));
|
||||
|
||||
facultyCombo.setModel(new DefaultComboBoxModel<>(sv.getFm().getFaculties().toArray(new Faculty[0])));
|
||||
groupCombo.setModel(new DefaultComboBoxModel<>(sv.getFm().getGm().getGroups().toArray(new Group[0])));
|
||||
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -81,6 +77,7 @@ public class AddStudentForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Add a Student");
|
||||
|
||||
titleLabel.setText("Add a new student");
|
||||
submitButton.setText("Submit");
|
||||
@@ -97,14 +94,13 @@ public class AddStudentForm extends JFrame {
|
||||
enrolMonthLabel.setText("Month of Enrollment:");
|
||||
enrolYearLabel.setText("Year of Enrollment:");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
ComboBoxRenderer.setRenderer(facultyCombo, sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
ComboBoxRenderer.setRenderer(groupCombo, sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.lumijiez.gui.forms.student;
|
||||
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -14,15 +14,13 @@ import java.util.Objects;
|
||||
public class DeleteStudentForm extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||
private final JLabel studentLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
public DeleteStudentForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Delete a Student");
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -31,16 +29,16 @@ public class DeleteStudentForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
titleLabel.setText("Delete Student");
|
||||
setTitle("Delete a Student");
|
||||
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
ComboBoxRenderer.setRenderer(studentCombo, sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
|
||||
studentLabel.setText("Student:");
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
titleLabel.setText("Delete Student");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.lumijiez.gui.forms.student;
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -31,13 +31,13 @@ public class EditStudentForm extends JFrame {
|
||||
private final JComboBox<Integer> enrolmonthCombo;
|
||||
private final JComboBox<Integer> enrolyearCombo;
|
||||
private final JLabel eyearLabel = new JLabel();
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||
private final JLabel facultyLabel = new JLabel();
|
||||
private final JComboBox<Group> groupCombo;
|
||||
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||
private final JLabel groupLabel = new JLabel();
|
||||
private final JTextField nameField = new JTextField();
|
||||
private final JLabel nameLabel = new JLabel();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||
private final JLabel studentLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JTextField surnameField = new JTextField();
|
||||
@@ -47,7 +47,6 @@ public class EditStudentForm extends JFrame {
|
||||
|
||||
public EditStudentForm(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Edit a Student");
|
||||
|
||||
Integer[] days = new Integer[31];
|
||||
for (int i = 0; i < 31; i++) {
|
||||
@@ -70,9 +69,6 @@ public class EditStudentForm extends JFrame {
|
||||
enroldayCombo = new JComboBox<>(days);
|
||||
enrolmonthCombo = new JComboBox<>(months);
|
||||
enrolyearCombo = new JComboBox<>(years);
|
||||
this.facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
this.groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -81,6 +77,7 @@ public class EditStudentForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Edit a Student");
|
||||
|
||||
titleLabel.setText("Edit a student");
|
||||
submitButton.setText("Submit");
|
||||
@@ -102,15 +99,15 @@ public class EditStudentForm extends JFrame {
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
ComboBoxRenderer.setRenderer(facultyCombo, sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
ComboBoxRenderer.setRenderer(groupCombo, sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
ComboBoxRenderer.setRenderer(studentCombo, sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
|
||||
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||
facultyCombo.setSelectedItem(student.getFaculty());
|
||||
System.out.println("lol:" + facultyCombo.getSelectedItem());
|
||||
groupCombo.setSelectedItem(student.getGroup());
|
||||
emailField.setText(student.getEmail());
|
||||
nameField.setText(student.getName());
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.lumijiez.gui.forms.student;
|
||||
import org.lumijiez.base.Grade;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.enums.Subjects;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
|
||||
@@ -16,23 +16,20 @@ public class GradeStudentForm extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Subjects> subjectCombo;
|
||||
private final JComboBox<Subjects> subjectCombo = new JComboBox<>();
|
||||
private final JLabel gradeLabel = new JLabel();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
private final JComboBox<Integer> gradeCombo;
|
||||
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||
private final JLabel studentLabel = new JLabel();
|
||||
private final JLabel subjectLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
Integer[] grades = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
private final JComboBox<Integer> gradeCombo = new JComboBox<>(grades);
|
||||
|
||||
|
||||
public GradeStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Grade A Student");
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.subjectCombo = new JComboBox<>(Subjects.values());
|
||||
this.gradeCombo = new JComboBox<>(grades);
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -41,6 +38,7 @@ public class GradeStudentForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Grade A Student");
|
||||
|
||||
titleLabel.setText("Grade a student");
|
||||
studentLabel.setText("Student:");
|
||||
@@ -49,14 +47,13 @@ public class GradeStudentForm extends JFrame {
|
||||
gradeLabel.setText("Grade:");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
ComboBoxRenderers.setSubjectRenderer(subjectCombo);
|
||||
ComboBoxRenderer.setRenderer(subjectCombo, Subjects.values());
|
||||
ComboBoxRenderer.setRenderer(studentCombo, sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.lumijiez.gui.forms.student;
|
||||
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.gui.util.DisplayerManager;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
@@ -13,14 +13,15 @@ import java.util.Objects;
|
||||
|
||||
public class GraduateStudentForm extends JFrame {
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||
private final JLabel studentLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
|
||||
private final Supervisor sv;
|
||||
|
||||
public GraduateStudentForm(Supervisor sv) {
|
||||
this.setTitle("Graduate a Student");
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getEnrolled().toArray(new Student[0]));
|
||||
this.sv = sv;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -28,9 +29,10 @@ public class GraduateStudentForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Graduate a Student");
|
||||
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
ComboBoxRenderer.setRenderer(studentCombo, sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
|
||||
studentLabel.setText("Student:");
|
||||
submitButton.setText("Submit");
|
||||
@@ -43,8 +45,7 @@ public class GraduateStudentForm extends JFrame {
|
||||
submitButton.setBackground(new Color(204, 255, 204));
|
||||
cancelButton.setBackground(new Color(255, 204, 204));
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.lumijiez.gui.forms.student;
|
||||
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
|
||||
@@ -13,15 +13,15 @@ import java.util.Objects;
|
||||
public class ShowStudentForm extends JFrame {
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||
private final JLabel studentLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final Supervisor sv;
|
||||
|
||||
public ShowStudentForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.setTitle("Show A Student");
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -29,20 +29,20 @@ public class ShowStudentForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Show A Student");
|
||||
|
||||
titleLabel.setText("Show Student");
|
||||
submitButton.setText("Submit");
|
||||
studentLabel.setText("Student:");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
ComboBoxRenderer.setRenderer(studentCombo, sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.lumijiez.gui.forms.student;
|
||||
|
||||
import org.lumijiez.base.Grade;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderer;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
|
||||
@@ -15,15 +15,15 @@ public class ShowStudentGradesForm extends JFrame {
|
||||
|
||||
private final JTextArea mainTextLabel;
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JComboBox<Student> studentCombo;
|
||||
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||
private final JLabel studentLabel = new JLabel();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final Supervisor sv;
|
||||
|
||||
public ShowStudentGradesForm(Supervisor sv, JTextArea mainTextLabel) {
|
||||
this.sv = sv;
|
||||
this.mainTextLabel = mainTextLabel;
|
||||
this.setTitle("Show Student Grades");
|
||||
this.studentCombo = new JComboBox<>(sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -31,20 +31,20 @@ public class ShowStudentGradesForm extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18)); // NOI18N
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", Font.PLAIN, 18));
|
||||
setTitle("Show Student Grades");
|
||||
|
||||
titleLabel.setText("Show Grades");
|
||||
studentLabel.setText("Student:");
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
ComboBoxRenderer.setRenderer(studentCombo, sv.getFm().getGm().getSm().getStudents().toArray(new Student[0]));
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -17,33 +17,30 @@ import java.io.IOException;
|
||||
|
||||
public class BatchGraduater extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private JTextPane filePane;
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final JButton browseButton = new JButton();
|
||||
private final JLabel formatLabel = new JLabel();
|
||||
private final JScrollPane exampleLabel = new JScrollPane();
|
||||
private final JTextArea exampleText = new JTextArea();
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JTextPane filePane = new JTextPane();
|
||||
|
||||
public BatchGraduater(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Graduate a Batch of Students");
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
|
||||
JButton submitButton = new JButton();
|
||||
JLabel titleLabel = new JLabel();
|
||||
JButton browseButton = new JButton();
|
||||
JLabel formatLabel = new JLabel();
|
||||
JScrollPane exampleLabel = new JScrollPane();
|
||||
JTextArea exampleText = new JTextArea();
|
||||
JButton cancelButton = new JButton();
|
||||
filePane = new JTextPane();
|
||||
|
||||
titleLabel.setFont(new Font("Segoe UI", Font.PLAIN, 24));
|
||||
setTitle("Graduate a Batch of Students");
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
browseButton.addActionListener(this::browseButtonActionPerformed);
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
|
||||
@@ -19,37 +19,30 @@ import java.util.Date;
|
||||
|
||||
public class BatchLoader extends JFrame {
|
||||
private final Supervisor sv;
|
||||
private JTextPane filePane;
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final JButton browseButton = new JButton();
|
||||
private final JLabel formatLabel = new JLabel();
|
||||
private final JScrollPane exampleLabel = new JScrollPane();
|
||||
private final JTextArea exampleText = new JTextArea();
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JTextPane filePane = new JTextPane();
|
||||
|
||||
public BatchLoader(Supervisor sv) {
|
||||
this.sv = sv;
|
||||
this.setTitle("Load a Batch of Students");
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
int x = (screenSize.width - this.getWidth()) / 2;
|
||||
int y = (screenSize.height - this.getHeight()) / 2;
|
||||
this.setLocation(x, y);
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
|
||||
JButton submitButton = new JButton();
|
||||
JLabel titleLabel = new JLabel();
|
||||
JButton browseButton = new JButton();
|
||||
JLabel formatLabel = new JLabel();
|
||||
JScrollPane exampleLabel = new JScrollPane();
|
||||
JTextArea exampleText = new JTextArea();
|
||||
JButton cancelButton = new JButton();
|
||||
filePane = new JTextPane();
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("Segoe UI", Font.PLAIN, 24));
|
||||
setTitle("Load a Batch of Students");
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
browseButton.addActionListener(this::browseButtonActionPerformed);
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.lumijiez.gui.util;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class ComboBoxRenderer {
|
||||
public static <T> void setRenderer(JComboBox<T> comboBox, T[] items) {
|
||||
comboBox.setModel(new DefaultComboBoxModel<>(items));
|
||||
comboBox.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value != null) {
|
||||
setText(value.toString());
|
||||
}
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package org.lumijiez.gui.util;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.enums.Subjects;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class ComboBoxRenderers {
|
||||
public static void setFacultyRenderer(JComboBox<Faculty> facultyCombo) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setGroupRenderer(JComboBox<Group> groupCombo) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setStudentRenderer(JComboBox<Student> studentCombo) {
|
||||
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Student)
|
||||
setText(((Student) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setSubjectRenderer(JComboBox<Subjects> subjectCombo) {
|
||||
subjectCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Subjects)
|
||||
setText(((Subjects) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,8 @@ package org.lumijiez.gui.util;
|
||||
import javax.swing.*;
|
||||
|
||||
public class ComponentDecorator {
|
||||
public static void submitButton(JButton button) {
|
||||
button.setBackground(new java.awt.Color(204, 255, 204));
|
||||
}
|
||||
public static void cancelButton(JButton button) {
|
||||
button.setBackground(new java.awt.Color(255, 204, 204));
|
||||
public static void submitAndCancel(JButton buttonSubmit, JButton buttonCancel) {
|
||||
buttonSubmit.setBackground(new java.awt.Color(204, 255, 204));
|
||||
buttonCancel.setBackground(new java.awt.Color(255, 204, 204));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user