This commit is contained in:
martins 2022-11-17 13:46:28 +01:00
parent c5cf0dd4f4
commit 3a2dffd61f
5 changed files with 64 additions and 38 deletions

View File

@ -105,7 +105,8 @@ ${BUILD}/Graphic/Util/BD.class : ${SRC}/Graphic/Util/BD.java
## View ##
${BUILD}/Graphic/View/JTreeGroupe.class : ${SRC}/Graphic/View/JTreeGroupe.java \
${BUILD}/Graphic/Controller/TreeSelectionListenerGroupe.class \
${BUILD}/Graphic/Controller/TreeSelectionEventGroupe.class
${BUILD}/Graphic/Controller/TreeSelectionEventGroupe.class \
${BUILD}/Graphic/View/DefaultMutableTreeNodeGroupe.class
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/JTreeGroupe.java
${BUILD}/Graphic/View/FenetreGroupe.class : ${SRC}/Graphic/View/FenetreGroupe.java \
@ -133,7 +134,8 @@ ${BUILD}/Graphic/View/FenetreSelectionEtu.class : ${SRC}/Graphic/View/FenetreSel
${BUILD}/Graphic/Controller/ActionListenerNouveauEtu.class
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/FenetreSelectionEtu.java
${BUILD}/Graphic/View/DefaultMutableTreeNodeGroupe.class : ${SRC}/Graphic/View/DefaultMutableTreeNodeGroupe.java
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/DefaultMutableTreeNodeGroupe.java
## Controller ##
${BUILD}/Graphic/Controller/ActionListenerChangeEtu.class : ${SRC}/Graphic/Controller/ActionListenerChangeEtu.java

View File

@ -8,7 +8,6 @@ import java.sql.ResultSet;
import javax.swing.*;
import java.awt.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import fr.iutfbleau.projetIHM2022FI2.API.AbstractGroupeFactory;
import fr.iutfbleau.projetIHM2022FI2.API.Etudiant;
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
@ -17,6 +16,7 @@ import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurFenetre;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.TreeSelectionListenerGroupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Util.BD;
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.Chargement;
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.DefaultMutableTreeNodeGroupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreEtudiant;
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreGroupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.JTreeGroupe;
@ -27,19 +27,27 @@ import fr.iutfbleau.projetIHM2022FI2.MNP.GroupeNP;
* Le Model de L'IHM
*/
public class Model{
private JPanel panGroupe;
private FenetreGroupe fenGr;
private FenetreEtudiant fenEtu;
private AbstractGroupeFactory promo;
private JFrame fenetre;
private JTree tree;
private BD bd;
public Model(){
this.fenetre=new JFrame();
this.fenetre.setSize(1200, 720);
this.fenetre.setLocation(100,100);
this.fenetre.addWindowListener(new ObservateurFenetre());
this.fenetre.setLayout(new GridLayout(1,2));
this.fenetre.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.fenetre.setMinimumSize(this.fenetre.getSize());
this.fenetre.setVisible(true);
this.bd=new BD(this.fenetre);
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);
@ -47,19 +55,20 @@ public class Model{
this.fenGr=new FenetreGroupe(this.promo.getPromotion(), this);
this.fenEtu=new FenetreEtudiant(this.promo.getPromotion(), this);
}
this.bd.setFenetre(this.fenetre);
this.fenetre.setLocation(100,100);
this.fenetre.addWindowListener(new ObservateurFenetre());
this.fenetre.setLayout(new GridLayout(1,2));
this.fenetre.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.fenetre.setMinimumSize(this.fenetre.getSize());
this.fenetre.add(tree.add(this.fenGr));
JScrollPane scroll=new JScrollPane(this.fenEtu);
scroll.getVerticalScrollBar().setUnitIncrement(15);
this.fenetre.add(scroll);
this.fenetre.setVisible(true);
if(this.promo!=null)
this.panGroupe=new JPanel(new GridLayout(2,1));
DefaultMutableTreeNodeGroupe root=new DefaultMutableTreeNodeGroupe(this.promo.getPromotion());
this.tree=new JTreeGroupe(this, root);
this.tree.setEditable(true);
this.tree.setShowsRootHandles(true);
this.tree.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
this.tree.addTreeSelectionListener(new TreeSelectionListenerGroupe());
if(this.promo!=null){
this.showGroupe(this.promo.getPromotion());
}else{
this.showGroupe(null);
}
}
/**
@ -69,19 +78,15 @@ public class Model{
public void showGroupe(Groupe g){
if(g!=null)
g=this.bd.refreshALL(g);
/*
JTree arbre = new JTreeGroupe(g, this);
arbre.setEditable(true);
arbre.setShowsRootHandles(true);
arbre.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
arbre.addTreeSelectionListener(new TreeSelectionListenerGroupe());
this.fenetre.add(arbre);
*/
this.panGroupe.removeAll();
this.fenGr=new FenetreGroupe(g, this);
this.fenEtu=new FenetreEtudiant(g, this);
this.fenetre.getContentPane().removeAll();
this.fenetre.add(this.fenGr);
this.panGroupe.add(this.tree);
this.panGroupe.add(this.fenGr);
this.fenetre.add(this.panGroupe);
JScrollPane scroll=new JScrollPane(this.fenEtu);
scroll.getVerticalScrollBar().setUnitIncrement(15);
this.fenetre.add(scroll);
@ -311,6 +316,11 @@ public class Model{
}
}
private void setTree(DefaultMutableTreeNode mut, Groupe g){
}
public boolean deleteEtu(Etudiant e){
if(this.deleteEtutoChildren(e, this.fenGr.getG())){
this.bd.deleteEtu(e, this.fenGr.getG());

View File

@ -369,9 +369,6 @@ public class BD {
this.close(cnx);
return ret;
}
public void setFenetre(JFrame fenetre) {
this.fenetre = fenetre;
}
public void deleteEtu(Etudiant et, Groupe g){
Connection cnx=this.cnx();

View File

@ -0,0 +1,20 @@
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
import javax.swing.tree.DefaultMutableTreeNode;
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
public class DefaultMutableTreeNodeGroupe extends DefaultMutableTreeNode{
private Groupe groupe;
public DefaultMutableTreeNodeGroupe(Groupe g){
super(g.getName());
this.groupe=g;
}
public Groupe getGroupe() {
return groupe;
}
public void setGroupe(Groupe groupe) {
this.groupe = groupe;
}
}

View File

@ -1,26 +1,23 @@
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.TreeSelectionEventGroupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.TreeSelectionListenerGroupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Model.Model;
public class JTreeGroupe extends JTree{
private Groupe groupe;
private Model model;
public JTreeGroupe(Groupe g, Model m){
super();
this.groupe=g;
public JTreeGroupe(Model m, DefaultMutableTreeNodeGroupe mut){
super(mut);
this.model=m;
}
@Override
protected void fireValueChanged(TreeSelectionEvent e) {
e=new TreeSelectionEventGroupe(this, getSelectionPaths(), null, getLeadSelectionPath(), getLeadSelectionPath(), this.groupe, this.model);
DefaultMutableTreeNodeGroupe node=(DefaultMutableTreeNodeGroupe) this.getLastSelectedPathComponent();
e=new TreeSelectionEventGroupe(this, getSelectionPaths(), null, getLeadSelectionPath(), getLeadSelectionPath(), node.getGroupe(), this.model);
TreeSelectionListener[] list=this.getTreeSelectionListeners();
TreeSelectionListenerGroupe l=(TreeSelectionListenerGroupe) list[0];
l.valueChanged(e);