possibiliter même nom etudiant et diminution ressource prise lors du rafraîchissement
This commit is contained in:
parent
3d1dc90f41
commit
2166150995
java/APIGroupe/src/fr/iutfbleau/projetIHM2022FI2/Graphic
@ -21,9 +21,7 @@ public class ObservateurModifGroupe implements ActionListener{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(e.getActionCommand()=="suprimer ce groupe"){
|
||||
Groupe pointpoint=this.groupe.getPointPoint();
|
||||
this.m.delete(this.groupe);
|
||||
this.m.showGroupe(pointpoint);
|
||||
}
|
||||
if(e.getActionCommand()=="créer un sous groupe"){
|
||||
String g[]=new String[2];
|
||||
@ -50,7 +48,6 @@ public class ObservateurModifGroupe implements ActionListener{
|
||||
return;
|
||||
}
|
||||
m.partition(this.groupe, nb, yField.getText());
|
||||
m.showGroupe(this.groupe);
|
||||
}
|
||||
}catch(NumberFormatException er){
|
||||
JOptionPane.showMessageDialog(m.getFenetre(), "erreur dans le nombre de partition", "erreur", JOptionPane.ERROR_MESSAGE);
|
||||
@ -82,7 +79,6 @@ public class ObservateurModifGroupe implements ActionListener{
|
||||
if(JOptionPane.showConfirmDialog(m.getFenetre(), new JScrollPane(myPanel), "Selectionner les étudiant a ajouter", JOptionPane.OK_CANCEL_OPTION) ==JOptionPane.YES_OPTION){
|
||||
if(ajout.size()>=min && ajout.size()<=max){
|
||||
m.free(groupe, yField.getText(), min, max, ajout);
|
||||
m.showGroupe(this.groupe);
|
||||
}else{
|
||||
if(min>ajout.size())
|
||||
JOptionPane.showMessageDialog(m.getFenetre(), "nombre d'etudiant trop petit", "erreur", JOptionPane.ERROR_MESSAGE);
|
||||
@ -100,7 +96,6 @@ public class ObservateurModifGroupe implements ActionListener{
|
||||
if(e.getActionCommand()=="renomer"){
|
||||
String nouveau=JOptionPane.showInputDialog(m.getFenetre(), "Rentrer le nouveau Nom");
|
||||
m.rename(nouveau, this.groupe);
|
||||
m.showGroupe(this.groupe);
|
||||
}
|
||||
if(e.getActionCommand()=="ajouter"){
|
||||
Set<Etudiant> ajout=new LinkedHashSet<>();
|
||||
@ -113,7 +108,6 @@ public class ObservateurModifGroupe implements ActionListener{
|
||||
for(Etudiant et:ajout){
|
||||
m.addEtudiant(this.groupe, et);
|
||||
}
|
||||
m.showGroupe(this.groupe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ public class Model{
|
||||
//On récupère les etudiants contenue du groupe
|
||||
PreparedStatement pst;
|
||||
//Si c'est la promo
|
||||
pst= cnx.prepareStatement("SELECT Etudiant.nom, Etudiant.prenom, Etudiant.id FROM `CONTIENT` JOIN Etudiant on CONTIENT.idEt=Etudiant.id WHERE CONTIENT.idGroupe=1 ORDER BY Etudiant.id ASC");
|
||||
pst= cnx.prepareStatement("SELECT Etudiant.nom, Etudiant.prenom, Etudiant.id FROM `CONTIENT` JOIN Etudiant on CONTIENT.idEt=Etudiant.id WHERE CONTIENT.idGroupe=? ORDER BY Etudiant.id ASC");
|
||||
try{
|
||||
pst.setInt(1, g.getId());
|
||||
ResultSet rs=pst.executeQuery();
|
||||
@ -192,8 +192,11 @@ public class Model{
|
||||
this.promo.addToGroupe(g, new EtudiantNP(rs.getString(1), rs.getString(2), rs.getInt(3)));
|
||||
}else{
|
||||
//autrement on recupere l'etudiant
|
||||
for(Etudiant e: this.promo.getEtudiants(rs.getString(1))){
|
||||
this.promo.addToGroupe(g, e);
|
||||
for(Etudiant e: g.getPointPoint().getEtudiants()){
|
||||
if(e.getId()==rs.getInt(3)){
|
||||
this.promo.addToGroupe(g, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -219,7 +222,6 @@ public class Model{
|
||||
* @param g le groupe a afficher
|
||||
*/
|
||||
public void showGroupe(Groupe g){
|
||||
this.getPromo(null);%/
|
||||
this.fenGr=new FenetreGroupe(g, this);
|
||||
this.fenEtu=new FenetreEtudiant(g);
|
||||
this.fenetre.getContentPane().removeAll();
|
||||
@ -253,6 +255,7 @@ public class Model{
|
||||
//on supprime les groupe
|
||||
this.promo.deleteGroupe(sup);
|
||||
}
|
||||
this.showGroupe(g.getPointPoint());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,6 +281,7 @@ public class Model{
|
||||
*/
|
||||
public void partition(Groupe g, int n, String name){
|
||||
this.promo.createPartition(g, name, n);
|
||||
this.fenGr.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,6 +307,7 @@ public class Model{
|
||||
for(Etudiant e:ajout){
|
||||
this.promo.addToGroupe(creer, e);
|
||||
}
|
||||
this.fenGr.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -312,6 +317,7 @@ public class Model{
|
||||
*/
|
||||
public void rename(String name, Groupe g){
|
||||
g.setName(name);
|
||||
this.fenGr.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -321,5 +327,10 @@ public class Model{
|
||||
*/
|
||||
public void addEtudiant(Groupe g, Etudiant e){
|
||||
g.addEtudiant(e);
|
||||
this.fenEtu.refresh();
|
||||
}
|
||||
|
||||
private void refresh(Groupe g){
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.Etudiant;
|
||||
@ -17,13 +18,27 @@ public class FenetreEtudiant extends JPanel{
|
||||
super();
|
||||
if(g!=null){
|
||||
this.etu=g.getEtudiants();
|
||||
}else{
|
||||
this.etu=new LinkedHashSet<>();
|
||||
}
|
||||
this.draw();
|
||||
}
|
||||
|
||||
private void draw(){
|
||||
if(this.etu.size()!=0){
|
||||
this.setLayout(new GridLayout(this.etu.size(), 1, 10, 0));
|
||||
for(Etudiant e: this.etu){
|
||||
PanelEtudiant p=new PanelEtudiant(e);
|
||||
this.add(p);
|
||||
}
|
||||
}else{
|
||||
this.setLayout(new FlowLayout());
|
||||
this.add(new JLabel("Il n'y a pas d'étudiant"));
|
||||
}
|
||||
}
|
||||
public void refresh(){
|
||||
this.removeAll();
|
||||
this.draw();
|
||||
this.revalidate();
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,22 @@ import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurModifGroupe;
|
||||
|
||||
public class FenetreGroupe extends JPanel{
|
||||
private Groupe g;
|
||||
private Model m;
|
||||
public FenetreGroupe(Groupe g, Model m){
|
||||
super();
|
||||
this.g=g;
|
||||
this.m=m;
|
||||
this.draw();
|
||||
}
|
||||
public Groupe getG() {
|
||||
return this.g;
|
||||
}
|
||||
public void refresh(){
|
||||
this.removeAll();
|
||||
this.draw();
|
||||
this.revalidate();
|
||||
}
|
||||
private void draw(){
|
||||
if(g!=null){
|
||||
this.setLayout(new GridLayout(11+g.getSousGroupes().size(), 1));
|
||||
JButton bout=new JButton("point point");
|
||||
|
Loading…
x
Reference in New Issue
Block a user