ok
This commit is contained in:
parent
3c518bd6d1
commit
203fca24cd
@ -1,6 +1,7 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Graphic.Model;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
@ -31,9 +32,9 @@ public class Model{
|
||||
private FenetreEtudiant fenEtu;
|
||||
private AbstractGroupeFactory promo;
|
||||
private JFrame fenetre;
|
||||
private JTree tree;
|
||||
//private JTree tree;
|
||||
private BD bd;
|
||||
|
||||
private HashMap<Integer,DefaultMutableTreeNodeGroupe> brain;
|
||||
public Model(){
|
||||
this.fenetre=new JFrame();
|
||||
this.fenetre.setSize(1200, 720);
|
||||
@ -42,7 +43,7 @@ public class Model{
|
||||
this.fenetre.setLayout(new GridLayout(1,2));
|
||||
this.fenetre.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
this.fenetre.setMinimumSize(this.fenetre.getSize());
|
||||
|
||||
this.brain=new HashMap<>();
|
||||
this.bd=new BD(this.fenetre);
|
||||
Chargement ch=new Chargement(this.fenetre.getSize());
|
||||
this.promo=this.getPromo(ch);
|
||||
@ -55,8 +56,12 @@ public class Model{
|
||||
this.fenGr=new FenetreGroupe(this.promo.getPromotion(), this);
|
||||
this.fenEtu=new FenetreEtudiant(this.promo.getPromotion(), this);
|
||||
}
|
||||
this.panGroupe=new JPanel(new GridLayout(2,1));
|
||||
this.initJtree(this.promo.getPromotion());
|
||||
this.panGroupe=new JPanel(new GridLayout(1,1));
|
||||
if(this.promo!=null){
|
||||
//this.initJtree(this.promo.getPromotion());
|
||||
}else{
|
||||
//this.initJtree(null);
|
||||
}
|
||||
if(this.promo!=null){
|
||||
this.showGroupe(this.promo.getPromotion());
|
||||
}else{
|
||||
@ -71,13 +76,11 @@ public class Model{
|
||||
public void showGroupe(Groupe g){
|
||||
if(g!=null)
|
||||
g=this.bd.refreshALL(g);
|
||||
|
||||
//this.initJtree(this.promo.getPromotion());
|
||||
this.panGroupe.removeAll();
|
||||
this.fenGr=new FenetreGroupe(g, this);
|
||||
this.fenEtu=new FenetreEtudiant(g, this);
|
||||
this.fenetre.getContentPane().removeAll();
|
||||
this.panGroupe.add(this.tree);
|
||||
//this.panGroupe.add(this.tree);
|
||||
this.panGroupe.add(this.fenGr);
|
||||
this.panGroupe.revalidate();
|
||||
this.fenetre.add(this.panGroupe);
|
||||
@ -102,7 +105,9 @@ public class Model{
|
||||
if(g==this.promo.getPromotion()){
|
||||
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=null;
|
||||
this.bd.suprGroupe(g);
|
||||
if(this.bd.suprGroupe(g)){
|
||||
this.initJtree(null);
|
||||
}
|
||||
this.showGroupe(null);
|
||||
}else{
|
||||
return;
|
||||
@ -112,7 +117,9 @@ public class Model{
|
||||
//autrement on récupere les groupe a supprimer par ordre avec une fonction recursive
|
||||
//elle contiendra les sous-groupe remontant j'usqau groupe a supprimer
|
||||
//On initialise la liste
|
||||
this.bd.suprGroupe(g);
|
||||
if(this.bd.suprGroupe(g)){
|
||||
//this.refreshTree(this.brain.get(g.getId()), g);
|
||||
}
|
||||
this.showGroupe(g.getPointPoint());
|
||||
}
|
||||
}
|
||||
@ -139,7 +146,9 @@ public class Model{
|
||||
for(Groupe gr: g.getSousGroupes()){
|
||||
if(gr.getSousGroupes().size()>0 && gr.getSousGroupes().iterator().next().getName().contains(name)){
|
||||
this.fenetre.setVisible(false);
|
||||
this.bd.saveGroupe(gr, 100/this.getTailleGroupe(gr)+1, ch);
|
||||
if(this.bd.saveGroupe(gr, 100/this.getTailleGroupe(gr)+1, ch)){
|
||||
//this.refreshTree(this.brain.get(g.getId()), g);
|
||||
}
|
||||
ch.dispose();
|
||||
this.fenetre.setVisible(true);
|
||||
break;
|
||||
@ -331,28 +340,34 @@ public class Model{
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initJtree(Groupe g){
|
||||
private void initJtree(Groupe g){/*
|
||||
this.brain=new HashMap<>();
|
||||
DefaultMutableTreeNodeGroupe mut;
|
||||
if(g!=null){
|
||||
mut=new DefaultMutableTreeNodeGroupe(g, g.getName());
|
||||
this.brain.put(g.getId(), mut);
|
||||
for(Groupe sous:g.getSousGroupes()){
|
||||
this.treeRecursif(sous, mut);
|
||||
}
|
||||
}else{
|
||||
mut=new DefaultMutableTreeNodeGroupe(g, null);
|
||||
}
|
||||
this.tree=new JTreeGroupe(this, mut);
|
||||
//this.tree=new JTreeGroupe(this, mut);*/
|
||||
}
|
||||
|
||||
private void treeRecursif(Groupe g, DefaultMutableTreeNodeGroupe m){
|
||||
private void treeRecursif(Groupe g, DefaultMutableTreeNodeGroupe m){/*
|
||||
this.brain.put(g.getId(), m);
|
||||
DefaultMutableTreeNodeGroupe mut=new DefaultMutableTreeNodeGroupe(g, g.getName());
|
||||
m.add(mut);
|
||||
for(Groupe sous: g.getSousGroupes()){
|
||||
this.treeRecursif(sous, mut);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private void refreshTree(Groupe g){
|
||||
|
||||
private void refreshTree(DefaultMutableTreeNodeGroupe m, Groupe g){
|
||||
/* m.removeAllChildren();
|
||||
for(Groupe sous:g.getSousGroupes()){
|
||||
this.treeRecursif(sous, m);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user