2022-11-15 17:38:45 +01:00
|
|
|
package Test;
|
|
|
|
|
|
|
|
import API.*;
|
|
|
|
import MNP.*;
|
2022-11-15 17:53:53 +01:00
|
|
|
import javax.swing.JComboBox;
|
|
|
|
import javax.swing.JTextField;
|
|
|
|
import javax.swing.JButton;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.JTable;
|
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
import java.awt.Dimension;
|
|
|
|
import java.awt.Insets;
|
|
|
|
import java.awt.GridBagConstraints;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.KeyAdapter;
|
|
|
|
import java.awt.event.KeyEvent;
|
2022-11-15 17:38:45 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class ProfView extends BFrame implements ActionListener {
|
|
|
|
private final ArrayList<Etudiant> e;
|
|
|
|
private final ArrayList<Groupe> g;
|
|
|
|
private JComboBox groupeOption;
|
|
|
|
private JTextField text;
|
|
|
|
private BDatabase db;
|
|
|
|
|
|
|
|
public ProfView(ArrayList<Etudiant> e, ArrayList<Groupe> g, BDatabase db) {
|
|
|
|
super(
|
|
|
|
"Vue professeur",
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
500,
|
|
|
|
500,
|
|
|
|
3
|
|
|
|
);
|
|
|
|
|
|
|
|
this.e = e;
|
|
|
|
this.g = g;
|
|
|
|
this.db = db;
|
|
|
|
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Display() {
|
|
|
|
BLayout settings = new BLayout();
|
|
|
|
settings.setPositionX(0);
|
|
|
|
settings.setPositionY(3);
|
|
|
|
|
|
|
|
settings.setPositionY(0);
|
|
|
|
JButton studList = new JButton("Voir la liste des etudiants");
|
|
|
|
studList.setActionCommand("fi::GetStudList");
|
|
|
|
studList.addActionListener(this);
|
|
|
|
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);
|
2022-11-15 17:53:53 +01:00
|
|
|
settings.setPadding(new Insets(0, 0, 0, 50));
|
2022-11-15 17:38:45 +01:00
|
|
|
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);
|
2022-11-15 17:53:53 +01:00
|
|
|
settings.setPadding(new Insets(0, 0, 0, 0));
|
2022-11-15 17:38:45 +01:00
|
|
|
settings.setAnchor(GridBagConstraints.EAST);
|
|
|
|
JButton confirm = new JButton("Rechercher");
|
|
|
|
confirm.setActionCommand("fi::GetListFiltered");
|
|
|
|
confirm.addActionListener(this);
|
|
|
|
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);
|
2022-11-15 17:53:53 +01:00
|
|
|
settings.setPadding(new Insets(0, 0, 0, 50));
|
2022-11-15 17:38:45 +01:00
|
|
|
this.text = new JTextField();
|
|
|
|
this.text.setPreferredSize(new Dimension(110, 30));
|
|
|
|
text.addKeyListener(new KeyAdapter() {
|
|
|
|
public void keyTyped(KeyEvent e) {
|
|
|
|
if (text.getText().length() >= 3 ) // limit textfield to 3 characters
|
|
|
|
e.consume();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.add(this.text, settings);
|
|
|
|
|
|
|
|
settings.setPositionY(6);
|
2022-11-15 17:53:53 +01:00
|
|
|
settings.setPadding(new Insets(0, 0, 0, 0));
|
2022-11-15 17:38:45 +01:00
|
|
|
settings.setAnchor(GridBagConstraints.EAST);
|
|
|
|
JButton searchTLetters = new JButton("Rechercher");
|
|
|
|
searchTLetters.addActionListener(this);
|
|
|
|
searchTLetters.setActionCommand("fi::SearchStudentPer3Letters");
|
|
|
|
this.add(searchTLetters, settings);
|
|
|
|
|
|
|
|
this.openBFrame();
|
|
|
|
this.refreshBFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
String command = e.getActionCommand();
|
|
|
|
|
|
|
|
if (command == "fi::GetStudList") {
|
|
|
|
BFrame frame = new BFrame(
|
|
|
|
"Liste des eleves",
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
500,
|
|
|
|
500,
|
|
|
|
"GridLayout",
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
2
|
|
|
|
);
|
|
|
|
|
|
|
|
String[][] data = new String[this.e.size()][2];
|
|
|
|
|
|
|
|
String[] titre = {
|
|
|
|
"Nom",
|
|
|
|
"Prenom",
|
|
|
|
"Groupe"
|
|
|
|
};
|
|
|
|
|
|
|
|
for(int i = 0; i <= this.e.size()-1; i++) {
|
|
|
|
String[] info = {
|
|
|
|
this.e.get(i).getNom(),
|
|
|
|
this.e.get(i).getPrenom(),
|
|
|
|
String.valueOf(this.e.get(i).getGroupe())
|
|
|
|
};
|
|
|
|
|
|
|
|
data[i] = info;
|
|
|
|
}
|
|
|
|
|
|
|
|
JTable liste = new JTable(data, titre) {
|
|
|
|
public boolean editCellAt(int row, int column, java.util.EventObject e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
liste.getTableHeader().setReorderingAllowed(false);
|
|
|
|
liste.setFillsViewportHeight(true);
|
|
|
|
|
|
|
|
JScrollPane scroll = new JScrollPane(liste);
|
|
|
|
frame.getContentPane().add(scroll);
|
|
|
|
|
|
|
|
frame.openBFrame();
|
|
|
|
} else if(command == "fi::GetListFiltered") {
|
|
|
|
BFrame frame = new BFrame(
|
|
|
|
"Liste des eleves du " + this.groupeOption.getSelectedItem(),
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
500,
|
|
|
|
500,
|
|
|
|
"GridLayout",
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
2
|
|
|
|
);
|
|
|
|
|
|
|
|
String[][] data = new String[this.e.size()][1];
|
|
|
|
|
|
|
|
String[] titre = {
|
|
|
|
"Nom",
|
|
|
|
"Prenom"
|
|
|
|
};
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for(i = 0, j = 0; i <= this.e.size()-1; i++) {
|
|
|
|
if(this.e.get(i).getGroupe() == this.groupeOption.getSelectedIndex()) {
|
|
|
|
String[] info = {
|
|
|
|
this.e.get(i).getNom(),
|
|
|
|
this.e.get(i).getPrenom()
|
|
|
|
};
|
|
|
|
|
|
|
|
data[j] = info;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String[][] data_final = new String[j][1];
|
|
|
|
for(int x = 0; x <= j-1; x++) {
|
|
|
|
data_final[x] = data[x];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JTable liste = new JTable(data_final, titre) {
|
|
|
|
public boolean editCellAt(int row, int column, java.util.EventObject e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
liste.getTableHeader().setReorderingAllowed(false);
|
|
|
|
liste.setFillsViewportHeight(true);
|
|
|
|
|
|
|
|
JScrollPane scroll = new JScrollPane(liste);
|
|
|
|
frame.getContentPane().add(scroll);
|
|
|
|
|
|
|
|
frame.openBFrame();
|
|
|
|
} else if(command == "fi::SearchStudentPer3Letters") {
|
|
|
|
/**
|
|
|
|
* Faire l'interface du filtrage.
|
|
|
|
* */
|
|
|
|
char[] beg = this.text.getText().toCharArray();
|
|
|
|
ArrayList<Etudiant> listFiltered = new ArrayList<>();
|
|
|
|
char[] cur;
|
|
|
|
|
|
|
|
for(int i = 0; i <= this.e.size()-1; i++) {
|
|
|
|
cur = this.e.get(i).getNom().toCharArray();
|
|
|
|
if(cur[0] == beg[0] && cur[1] == beg[1] && cur[2] == beg[2]) {
|
|
|
|
listFiltered.add(new EtudiantNP(
|
|
|
|
this.e.get(i).getNom(),
|
|
|
|
this.e.get(i).getPrenom(),
|
|
|
|
this.e.get(i).getGroupe()
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BFrame frame = new BFrame(
|
|
|
|
"Liste d'eleves d'ou les noms commence par " + beg[0] + beg[1] + beg[2],
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
500,
|
|
|
|
500,
|
|
|
|
"GridLayout",
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
2
|
|
|
|
);
|
|
|
|
|
|
|
|
String[] titre = {
|
|
|
|
"Nom",
|
|
|
|
"Prenom",
|
|
|
|
"Groupe"
|
|
|
|
};
|
|
|
|
|
|
|
|
String[][] data = new String[listFiltered.size()][2];
|
|
|
|
|
|
|
|
for(int i = 0; i <= listFiltered.size()-1; i++){
|
|
|
|
data[i] = new String[]{
|
|
|
|
this.e.get(i).getNom(),
|
|
|
|
this.e.get(i).getPrenom(),
|
|
|
|
String.valueOf(this.e.get(i).getGroupe())
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
JTable liste = new JTable(data, titre) {
|
|
|
|
public boolean editCellAt(int row, int column, java.util.EventObject e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
liste.getTableHeader().setReorderingAllowed(false);
|
|
|
|
liste.setFillsViewportHeight(true);
|
|
|
|
|
|
|
|
JScrollPane scroll = new JScrollPane(liste);
|
|
|
|
frame.getContentPane().add(scroll);
|
|
|
|
|
|
|
|
frame.openBFrame();
|
|
|
|
frame.refreshBFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|