FIProjetIHM2022/src/Test/ProfView.java

124 lines
3.8 KiB
Java
Raw Normal View History

2022-11-15 20:03:04 +01:00
package Test;
2022-11-26 20:34:37 +01:00
import API.Etudiant;
import API.Groupe;
2022-11-15 20:03:04 +01:00
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.GridBagConstraints;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
2022-11-26 19:46:16 +01:00
public class ProfView extends BFrame {
2022-11-15 20:03:04 +01:00
private final ArrayList<Etudiant> e;
private final ArrayList<Groupe> g;
2022-11-26 19:46:16 +01:00
private final Controller listener;
2022-11-26 20:34:37 +01:00
private JComboBox<String> groupeOption;
2022-11-15 20:03:04 +01:00
private JTextField text;
2022-11-26 19:46:16 +01:00
public ProfView(ArrayList<Etudiant> e, ArrayList<Groupe> g, Controller listener) {
2022-11-15 20:03:04 +01:00
super(
2022-11-26 19:46:16 +01:00
"Vue Professeur",
700,
300,
2022-11-15 20:03:04 +01:00
500,
500,
3
);
2022-11-26 19:46:16 +01:00
this.listener = listener;
2022-11-15 20:03:04 +01:00
this.e = e;
this.g = g;
2022-11-26 19:46:16 +01:00
this.Display();
}
public String getComboSelection() {
return (String) this.groupeOption.getSelectedItem();
}
public String getSearchStud() {
return this.text.getText();
}
public int getComboSelectionIndex() {
return this.groupeOption.getSelectedIndex();
2022-11-15 20:03:04 +01:00
}
public void Display() {
BLayout settings = new BLayout();
settings.setPositionX(0);
settings.setPositionY(6);
settings.setPositionY(0);
JButton studList = new JButton("Voir la liste des etudiants");
2022-11-26 20:34:37 +01:00
studList.setActionCommand("pv::GetStudList");
2022-11-26 19:46:16 +01:00
studList.addActionListener(this.listener);
2022-11-15 20:03:04 +01:00
this.add(studList, settings);
settings.setPositionY(1);
this.add(new JLabel(" "), settings);
settings.setPositionY(2);
JLabel gs = new JLabel("Afficher les etudiants se trouvant dans le groupe :");
this.add(gs, settings);
settings.setPositionY(3);
settings.setPadding(new Insets(0, 0, 0, 50));
String[] groupeList = new String[this.g.size()];
for(int i = 0; i <= this.g.size()-1; i++) {
groupeList[i] = this.g.get(i).getName();
}
this.groupeOption = new JComboBox<>(groupeList);
this.groupeOption.setPreferredSize(new Dimension(110, 30));
this.add(groupeOption, settings);
settings.setPositionY(3);
settings.setPadding(new Insets(0, 0, 0, 0));
settings.setAnchor(GridBagConstraints.EAST);
JButton confirm = new JButton("Rechercher");
2022-11-26 20:34:37 +01:00
confirm.setActionCommand("pv::GetListFiltered");
2022-11-26 19:46:16 +01:00
confirm.addActionListener(this.listener);
2022-11-15 20:03:04 +01:00
this.add(confirm, settings);
settings.setAnchor(GridBagConstraints.CENTER);
settings.setPositionY(4);
this.add(new JLabel(" "), settings);
settings.setPositionY(5);
JLabel pf = new JLabel("Rechercher un etudiant : ");
this.add(pf, settings);
settings.setPositionY(6);
settings.setPadding(new Insets(0, 0, 0, 50));
this.text = new JTextField();
this.text.setPreferredSize(new Dimension(110, 30));
text.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
2022-11-26 19:46:16 +01:00
if (text.getText().length() >= 3 )
2022-11-15 20:03:04 +01:00
e.consume();
}
});
this.add(this.text, settings);
settings.setPositionY(6);
settings.setPadding(new Insets(0, 0, 0, 0));
settings.setAnchor(GridBagConstraints.EAST);
JButton searchTLetters = new JButton("Rechercher");
2022-11-26 19:46:16 +01:00
searchTLetters.addActionListener(this.listener);
2022-11-26 20:34:37 +01:00
searchTLetters.setActionCommand("pv::SearchStudentPer3Letters");
2022-11-15 20:03:04 +01:00
this.add(searchTLetters, settings);
2022-11-27 14:14:19 +01:00
this.setResizable(false);
2022-11-15 20:03:04 +01:00
this.openBFrame();
this.refreshBFrame();
}
}