This commit is contained in:
2022-11-17 13:13:43 +01:00
parent 6c05981b8d
commit c5cf0dd4f4
12 changed files with 201 additions and 40 deletions

View File

@@ -19,6 +19,7 @@ import fr.iutfbleau.projetIHM2022FI2.Graphic.Util.BD;
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.Chargement;
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreEtudiant;
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreGroupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.JTreeGroupe;
import fr.iutfbleau.projetIHM2022FI2.MNP.AbstractGroupeFactoryNP;
import fr.iutfbleau.projetIHM2022FI2.MNP.GroupeNP;
@@ -32,21 +33,20 @@ public class Model{
private JFrame fenetre;
private BD bd;
public Model(){
this.fenetre=new JFrame();
this.fenetre.setSize(1200, 720);
this.bd=new BD(this.fenetre);
Chargement ch=new Chargement();
Chargement ch=new Chargement(this.fenetre.getSize());
this.promo=this.getPromo(ch);
ch.dispose();
JTree tree=new JTree();
if(this.promo==null){
this.fenGr=new FenetreGroupe(null, this);
this.fenEtu=new FenetreEtudiant(null);
this.fenEtu=new FenetreEtudiant(null, this);
}else{
this.fenGr=new FenetreGroupe(this.promo.getPromotion(), this);
this.fenEtu=new FenetreEtudiant(this.promo.getPromotion());
this.fenEtu=new FenetreEtudiant(this.promo.getPromotion(), this);
}
this.fenetre=new JFrame();
this.fenetre.setSize(1200, 720);
this.bd.setFenetre(this.fenetre);
this.fenetre.setLocation(100,100);
this.fenetre.addWindowListener(new ObservateurFenetre());
@@ -62,9 +62,6 @@ public class Model{
this.showGroupe(this.promo.getPromotion());
}
private void nouvelleCible(TreePath e){
System.out.println(e.getLastPathComponent().toString());
}
/**
* Fonction pour refresh/changer de groupe d'affichage
* @param g le groupe a afficher
@@ -72,19 +69,19 @@ public class Model{
public void showGroupe(Groupe g){
if(g!=null)
g=this.bd.refreshALL(g);
DefaultMutableTreeNode mut=new DefaultMutableTreeNode(g);
JTree arbre = new JTree(mut);
/*
JTree arbre = new JTreeGroupe(g, this);
arbre.setEditable(true);
arbre.setShowsRootHandles(true);
arbre.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
arbre.addTreeSelectionListener(new TreeSelectionListenerGroupe(this));
this.fenGr=new FenetreGroupe(g, this);
this.fenEtu=new FenetreEtudiant(g);
this.fenetre.getContentPane().removeAll();
arbre.addTreeSelectionListener(new TreeSelectionListenerGroupe());
this.fenetre.add(arbre);
*/
this.fenGr=new FenetreGroupe(g, this);
this.fenEtu=new FenetreEtudiant(g, this);
this.fenetre.getContentPane().removeAll();
this.fenetre.add(this.fenGr);
JScrollPane scroll=new JScrollPane(this.fenEtu);
scroll.getVerticalScrollBar().setUnitIncrement(15);
this.fenetre.add(scroll);
@@ -136,7 +133,7 @@ public class Model{
* @param name le nom des partition
*/
public void partition(Groupe g, int n, String name){
Chargement ch=new Chargement();
Chargement ch=new Chargement(this.fenetre.getSize());
this.promo.createPartition(g, name, n);
//On recherche le groupe Partitionner pour le sauvegarder dans la BD
@@ -207,7 +204,7 @@ public class Model{
public void addPromo(int min, int max, String name, Set<Etudiant> ajout){
Chargement ch=new Chargement();
Chargement ch=new Chargement(this.fenetre.getSize());
this.promo=new AbstractGroupeFactoryNP(name, min, max);
this.fenetre.setVisible(false);
this.bd.saveGroupe(this.promo.getPromotion(), this.getTailleGroupe(this.promo.getPromotion()), ch);
@@ -313,4 +310,25 @@ public class Model{
this.init(gr, pourcentage, ch);
}
}
public boolean deleteEtu(Etudiant e){
if(this.deleteEtutoChildren(e, this.fenGr.getG())){
this.bd.deleteEtu(e, this.fenGr.getG());
this.showGroupe(this.fenGr.getG());
return true;
}else{
return false;
}
}
private boolean deleteEtutoChildren(Etudiant e, Groupe g){
if(g.getMax()<g.getEtudiants().size()-1)
return false;
for(Groupe sous: g.getSousGroupes()){
if(this.deleteEtutoChildren(e, sous)==false){
return false;
}
}
return true;
}
}