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 ## ## View ##
${BUILD}/Graphic/View/JTreeGroupe.class : ${SRC}/Graphic/View/JTreeGroupe.java \ ${BUILD}/Graphic/View/JTreeGroupe.class : ${SRC}/Graphic/View/JTreeGroupe.java \
${BUILD}/Graphic/Controller/TreeSelectionListenerGroupe.class \ ${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 ${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/JTreeGroupe.java
${BUILD}/Graphic/View/FenetreGroupe.class : ${SRC}/Graphic/View/FenetreGroupe.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 ${BUILD}/Graphic/Controller/ActionListenerNouveauEtu.class
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/FenetreSelectionEtu.java ${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 ## ## Controller ##
${BUILD}/Graphic/Controller/ActionListenerChangeEtu.class : ${SRC}/Graphic/Controller/ActionListenerChangeEtu.java ${BUILD}/Graphic/Controller/ActionListenerChangeEtu.class : ${SRC}/Graphic/Controller/ActionListenerChangeEtu.java

View File

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

View File

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

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; package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener; import javax.swing.event.TreeSelectionListener;
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.TreeSelectionEventGroupe; import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.TreeSelectionEventGroupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.TreeSelectionListenerGroupe; import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.TreeSelectionListenerGroupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Model.Model; import fr.iutfbleau.projetIHM2022FI2.Graphic.Model.Model;
public class JTreeGroupe extends JTree{ public class JTreeGroupe extends JTree{
private Groupe groupe;
private Model model; private Model model;
public JTreeGroupe(Groupe g, Model m){ public JTreeGroupe(Model m, DefaultMutableTreeNodeGroupe mut){
super(); super(mut);
this.groupe=g;
this.model=m; this.model=m;
} }
@Override @Override
protected void fireValueChanged(TreeSelectionEvent e) { 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(); TreeSelectionListener[] list=this.getTreeSelectionListeners();
TreeSelectionListenerGroupe l=(TreeSelectionListenerGroupe) list[0]; TreeSelectionListenerGroupe l=(TreeSelectionListenerGroupe) list[0];
l.valueChanged(e); l.valueChanged(e);