debut changement
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.ETU.Model;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.AbstractChangementFactory;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.AbstractGroupeFactory;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.Etudiant;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.TypeGroupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.AbstractChangementFactoryNP;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.AbstractGroupeFactoryNP;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.GroupeNP;
|
||||
import fr.iutfbleau.projetIHM2022FI2.ETU.Controller.ObservateurFenetre;
|
||||
@@ -28,9 +32,10 @@ public class Model{
|
||||
private FenetreGroupe fenGr;
|
||||
private FenetreEtudiant fenEtu;
|
||||
private AbstractGroupeFactory promo;
|
||||
private AbstractChangementFactory changement;
|
||||
private JFrame fenetre;
|
||||
private Etudiant Selected;
|
||||
//private JTree tree;
|
||||
|
||||
private BD bd;
|
||||
public Model(){
|
||||
this.fenetre=new JFrame();
|
||||
@@ -48,10 +53,12 @@ public class Model{
|
||||
this.initEtu(null);
|
||||
if(this.promo==null){
|
||||
this.fenGr=new FenetreGroupe(null, this, null);
|
||||
this.fenEtu=new FenetreEtudiant(null, this.Selected);
|
||||
this.fenEtu=new FenetreEtudiant(null, this.Selected, this);
|
||||
this.changement=null;
|
||||
}else{
|
||||
this.changement=new AbstractChangementFactoryNP(promo, this.fenetre);
|
||||
this.fenGr=new FenetreGroupe(this.promo.getPromotion(), this,this.promo.getGroupesOfEtudiant(this.Selected));
|
||||
this.fenEtu=new FenetreEtudiant(this.promo.getPromotion(), this.Selected);
|
||||
this.fenEtu=new FenetreEtudiant(this.promo.getPromotion(), this.Selected, this);
|
||||
}
|
||||
this.panGroupe=new JPanel(new GridLayout(1,1));
|
||||
if(this.promo!=null){
|
||||
@@ -70,7 +77,7 @@ public void showGroupe(Groupe g){
|
||||
g=this.bd.refreshALL(g);
|
||||
this.panGroupe.removeAll();
|
||||
this.fenGr=new FenetreGroupe(g, this, this.promo.getGroupesOfEtudiant(this.Selected));
|
||||
this.fenEtu=new FenetreEtudiant(g, this.Selected);
|
||||
this.fenEtu=new FenetreEtudiant(g, this.Selected, this);
|
||||
this.fenetre.getContentPane().removeAll();
|
||||
this.panGroupe.add(this.fenGr.getPan());
|
||||
this.panGroupe.revalidate();
|
||||
@@ -153,7 +160,7 @@ public void showGroupe(Groupe g){
|
||||
}
|
||||
panel.add(myPanel);
|
||||
|
||||
if(JOptionPane.showConfirmDialog(null, panel, "login", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION){
|
||||
if(JOptionPane.showConfirmDialog(this.fenetre, panel, "login", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION){
|
||||
this.fenetre.dispose();
|
||||
System.exit(0);
|
||||
}else{
|
||||
@@ -261,6 +268,7 @@ public void showGroupe(Groupe g){
|
||||
if(JOptionPane.showConfirmDialog(this.fenetre, "Attention ête vous sûr de vouloir supprimer la promo", "Attention", JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
|
||||
this.promo.deleteGroupe(g);
|
||||
this.promo=null;
|
||||
this.changement=null;
|
||||
this.showGroupe(null);
|
||||
}else{
|
||||
return;
|
||||
@@ -352,6 +360,7 @@ public void showGroupe(Groupe g){
|
||||
public void addPromo(int min, int max, String name, Set<Etudiant> ajout){
|
||||
Chargement ch=new Chargement(this.fenetre);
|
||||
this.promo=new AbstractGroupeFactoryNP(name, min, max, this.fenetre);
|
||||
this.changement=new AbstractChangementFactoryNP(promo, this.fenetre);
|
||||
this.fenetre.setVisible(false);
|
||||
ch.addPourcent(20);
|
||||
int pourcent=85/ajout.size();
|
||||
@@ -364,4 +373,32 @@ public void showGroupe(Groupe g){
|
||||
this.showGroupe(this.promo.getPromotion());
|
||||
}
|
||||
|
||||
|
||||
// **************************
|
||||
// FONCTION POUR LES CHANGEMENTS
|
||||
// ******************************
|
||||
public void changeGroupe(Etudiant e, Groupe b){
|
||||
if(b==null)
|
||||
return;
|
||||
b=this.bd.refreshGroupe(b);
|
||||
if(b.getEtudiants()!=null && b.getMax()>b.getEtudiants().size()+1){
|
||||
this.changement.createChangement(this.fenGr.getG(), e, b);
|
||||
}else{
|
||||
JOptionPane.showMessageDialog(this.fenetre, "impossible trop d'etudiant dans l'autre Groupe", "erreur", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
this.showGroupe(this.fenGr.getG());
|
||||
}
|
||||
|
||||
public Set<Groupe> getGroupePartition(){
|
||||
Set<Groupe> retour=new HashSet<>();
|
||||
if(this.fenGr.getG().getPointPoint().getType()!=TypeGroupe.PARTITION)
|
||||
throw new IllegalStateException("impossible de changer un étudiant d'un groupe ne provenant pas d'une partition");
|
||||
for(Groupe sous:this.fenGr.getG().getPointPoint().getSousGroupes()){
|
||||
if(sous.getId()!=this.fenGr.getG().getId()){
|
||||
retour.add(sous);
|
||||
}
|
||||
}
|
||||
return retour;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user