correction de bug MPD et premiere navigation Groupe et Etudiant
This commit is contained in:
parent
82c4b78930
commit
5116d7a998
@ -95,18 +95,29 @@ ${BUILD}/MNP/AbstractChangementFactoryNP.class : ${SRC}/MNP/AbstractChangementFa
|
||||
## Graphic ##
|
||||
|
||||
## View ##
|
||||
${BUILD}/Graphic/View/PaintGroupe.class : ${SRC}/Graphic/View/PaintGroupe.java
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/PaintGroupe.java
|
||||
|
||||
${BUILD}/Graphic/Graphic.class : ${SRC}/Graphic/Graphic.java \
|
||||
${BUILD}/Graphic/View/FenetreGroupe.class : ${SRC}/Graphic/View/FenetreGroupe.java \
|
||||
${BUILD}/Graphic/Controller/ObservateurFenetre.class \
|
||||
${BUILD}/Graphic/View/PaintGroupe.class
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/Graphic.java
|
||||
${BUILD}/Graphic/Controller/ObservateurChangeGroupe.class
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/FenetreGroupe.java
|
||||
|
||||
${BUILD}/Graphic/View/FenetreEtudiant.class :${SRC}/Graphic/View/FenetreEtudiant.java \
|
||||
${BUILD}/Graphic/Controller/ObservateurFenetre.class \
|
||||
${BUILD}/Graphic/Controller/ObservateurChangeGroupe.class
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/FenetreEtudiant.java
|
||||
|
||||
|
||||
${BUILD}/Graphic/Model.class : ${SRC}/Graphic/Model.java \
|
||||
${BUILD}/Graphic/View/FenetreGroupe.class \
|
||||
${BUILD}/Graphic/View/FenetreEtudiant.class
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/Model.java
|
||||
|
||||
## Controller ##
|
||||
${BUILD}/Graphic/Controller/ObservateurFenetre.class : ${SRC}/Graphic/Controller/ObservateurFenetre.java
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/Controller/ObservateurFenetre.java
|
||||
|
||||
${BUILD}/Graphic/Controller/ObservateurChangeGroupe.class : ${SRC}/Graphic/Controller/ObservateurChangeGroupe.java
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/Controller/ObservateurChangeGroupe.java
|
||||
|
||||
|
||||
##....
|
||||
|
||||
@ -118,7 +129,7 @@ ${BUILD}/Graphic/Controller/ObservateurFenetre.class : ${SRC}/Graphic/Controller
|
||||
${BUILD}/MNP/ChangementNP.class \
|
||||
${BUILD}/MNP/AbstractGroupeFactoryNP.class \
|
||||
${BUILD}/MNP/AbstractChangementFactoryNP.class \
|
||||
${BUILD}/Graphic/Graphic.class
|
||||
${BUILD}/Graphic/Model.class
|
||||
${JAVAC} -Xlint:deprecation ${JAVAC_OPTIONS} ${SRC}/Test/TestTexteMNP.java
|
||||
|
||||
# ## JARS ##
|
||||
|
@ -115,6 +115,8 @@ public interface Groupe extends MonPrint {
|
||||
sb.append("\t _ "+ g.getName() + " (" + g.getType() + ", capacité " + g.getMin() + " à " + g.getMax() +", id " + g.getId()+")");
|
||||
sb.append("\n");
|
||||
}
|
||||
sb.append(" ** Groupe Pere **\n");
|
||||
sb.append(getPointPoint().getName()+"\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Graphic.Controller;
|
||||
|
||||
import java.awt.event.*;
|
||||
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Model;
|
||||
|
||||
public class ObservateurChangeGroupe implements ActionListener{
|
||||
private Model m;
|
||||
private Groupe g;
|
||||
public ObservateurChangeGroupe(Model m, Groupe g){
|
||||
this.m=m;
|
||||
this.g=g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
m.showGroupe(this.g);
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,10 @@ package fr.iutfbleau.projetIHM2022FI2.Graphic;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.sql.Connection;
|
||||
import org.mariadb.jdbc.*;
|
||||
import java.sql.DriverManager;
|
||||
@ -13,31 +15,43 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
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.Graphic.View.PaintGroupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurChangeGroupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurFenetre;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreEtudiant;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreGroupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.AbstractGroupeFactoryNP;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.EtudiantNP;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.GroupeNP;
|
||||
|
||||
public class Graphic{
|
||||
private PaintGroupe paint;
|
||||
private JFrame fenetre;
|
||||
public class Model{
|
||||
private FenetreGroupe fenGr;
|
||||
private FenetreEtudiant fenEtu;
|
||||
private AbstractGroupeFactory agf;
|
||||
public Graphic(){
|
||||
this.fenetre=new JFrame("Gestion des étudiants");
|
||||
this.fenetre.setSize(1000, 720);
|
||||
this.fenetre.setLocation(200,200);
|
||||
this.fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
private JFrame fenetre;
|
||||
private Set<Etudiant> etu;
|
||||
public Model(){
|
||||
this.etu=null;
|
||||
this.getPromo();
|
||||
this.fenetre.setVisible(true);
|
||||
|
||||
System.out.println(this.agf.getPromotion().monPrint());
|
||||
Groupe racineDeLaPartition = agf.getPromotion().getSousGroupes().iterator().next();
|
||||
System.out.println(racineDeLaPartition.monPrint());
|
||||
for(Groupe g : racineDeLaPartition.getSousGroupes()){
|
||||
System.out.println(g.monPrint());
|
||||
}
|
||||
this.fenGr=new FenetreGroupe(this.agf.getPromotion(), this);
|
||||
this.fenEtu=new FenetreEtudiant(this.agf.getPromotion());
|
||||
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.DISPOSE_ON_CLOSE);
|
||||
this.fenetre.add(this.fenGr);
|
||||
this.fenetre.add(this.fenEtu);
|
||||
this.fenetre.setVisible(true);
|
||||
}
|
||||
|
||||
private void getPromo(){
|
||||
@ -117,13 +131,22 @@ public class Graphic{
|
||||
private void addEtudiant(Groupe g, Connection cnx){
|
||||
try{
|
||||
PreparedStatement pst= cnx.prepareStatement(
|
||||
"SELECT Etudiant.nom, Etudiant.prenom, Etudiant.id FROM `Etudiant` NATURAL JOIN CONTIENT WHERE CONTIENT.idGroupe=? Group BY Etudiant.id;");
|
||||
"SELECT Etudiant.nom, Etudiant.id FROM `CONTIENT` JOIN Etudiant on CONTIENT.idEt=Etudiant.id WHERE CONTIENT.idGroupe=? Group BY Etudiant.nom; ");
|
||||
try{
|
||||
pst.setString(1, String.valueOf(g.getId()));
|
||||
pst.setInt(1, g.getId());
|
||||
ResultSet rs=pst.executeQuery();
|
||||
try{
|
||||
while(rs.next()){
|
||||
if(g==this.agf.getPromotion()){
|
||||
this.agf.addToGroupe(g, new EtudiantNP(rs.getString(1), rs.getString(2)));
|
||||
}else{
|
||||
Set<Etudiant> contenue=agf.getEtudiants(rs.getString(1));
|
||||
if(contenue.iterator().hasNext()){
|
||||
for(Etudiant e:contenue){
|
||||
agf.addToGroupe(g, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(SQLException e){
|
||||
System.out.println("erreur dans la prise de resultat");
|
||||
@ -137,4 +160,20 @@ public class Graphic{
|
||||
System.out.println("erreur debut requete");
|
||||
}
|
||||
}
|
||||
|
||||
public void showGroupe(Groupe g){
|
||||
this.fenetre.dispose();
|
||||
this.fenGr=new FenetreGroupe(g, this);
|
||||
this.fenEtu=new FenetreEtudiant(g);
|
||||
|
||||
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.DISPOSE_ON_CLOSE);
|
||||
this.fenetre.add(this.fenGr);
|
||||
this.fenetre.add(this.fenEtu);
|
||||
this.fenetre.setVisible(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
|
||||
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import java.awt.GridLayout;
|
||||
import java.util.Set;
|
||||
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.Etudiant;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
||||
|
||||
|
||||
public class FenetreEtudiant extends JPanel{
|
||||
private Set<Etudiant> etu;
|
||||
public FenetreEtudiant(Groupe g){
|
||||
super(new GridLayout(57, 1));
|
||||
this.etu=g.getEtudiants();
|
||||
for(Etudiant e: this.etu){
|
||||
this.add(new JLabel(e.monPrint()));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import java.awt.GridLayout;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Model;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurChangeGroupe;
|
||||
|
||||
|
||||
public class FenetreGroupe extends JPanel{
|
||||
private Groupe g;
|
||||
public FenetreGroupe(Groupe g, Model m){
|
||||
super(new GridLayout(15, 1));
|
||||
this.g=g;
|
||||
JButton bout=new JButton("point point");
|
||||
bout.addActionListener(new ObservateurChangeGroupe(m, this.g.getPointPoint()));
|
||||
this.add(bout);
|
||||
this.add(new JLabel(g.getName()));
|
||||
this.add(new JLabel("id= "+String.valueOf(g.getId())));
|
||||
this.add(new JLabel("min= "+String.valueOf(g.getMin())));
|
||||
this.add(new JLabel("max= "+String.valueOf(g.getMax())));
|
||||
this.add(new JLabel("Sous groupe"));
|
||||
for(Groupe gr: g.getSousGroupes()){
|
||||
JButton b=new JButton(gr.getName());
|
||||
b.addActionListener(new ObservateurChangeGroupe(m, gr));
|
||||
this.add(b);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
|
||||
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.*;
|
||||
import javax.swing.JComponent;
|
||||
import java.awt.Graphics;
|
||||
import java.util.LinkedList;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
|
||||
public class PaintGroupe extends JComponent {
|
||||
private LinkedList<Groupe> tabGroupe=new LinkedList<Groupe>();
|
||||
public PaintGroupe(){}
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
// obligatoire : si le composant n'est pas censé être transparent
|
||||
if (this.isOpaque()) {
|
||||
// obligatoire : on repeint toute la surface avec la couleur de fond
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
// maintenant on dessine ce que l'on veut
|
||||
secondPinceau.setColor(this.getForeground());
|
||||
int y=100;
|
||||
for(Groupe g: this.tabGroupe){
|
||||
secondPinceau.setColor(Color.BLACK);
|
||||
secondPinceau.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 40));
|
||||
FontMetrics metrics = secondPinceau.getFontMetrics(secondPinceau.getFont());
|
||||
secondPinceau.drawString(g.getName().toUpperCase(), (this.getWidth()/2-metrics.stringWidth(g.getName().toUpperCase())/2), (y-metrics.getAscent()));
|
||||
g.getName();
|
||||
y+=100;
|
||||
}
|
||||
}
|
||||
|
||||
public void addGroupe(Groupe g){
|
||||
this.tabGroupe.add(g);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public boolean removeGroupe(Groupe g){
|
||||
int i=this.tabGroupe.indexOf(g);
|
||||
if(i==-1){
|
||||
return false;
|
||||
}else{
|
||||
this.tabGroupe.remove(i);
|
||||
}
|
||||
this.repaint();
|
||||
return true;
|
||||
}
|
||||
}
|
@ -206,15 +206,14 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
|
||||
* @throws java.lang.NullPointerException si le String est null.
|
||||
*/
|
||||
public Set<Etudiant> getEtudiants(String nomEtu){
|
||||
// on cherche bêtement dans la promo.
|
||||
Set<Etudiant> out = new LinkedHashSet<Etudiant>();
|
||||
for (Etudiant e : getPromotion().getEtudiants()){
|
||||
if (e.getNom().equals(nomEtu)){
|
||||
out.add(e);
|
||||
break;
|
||||
Set<Etudiant> s=new LinkedHashSet<>();
|
||||
for(Etudiant e:this.getPromotion().getEtudiants()){
|
||||
//System.out.println("Comparaison de: \""+nomEtu.toLowerCase()+"\" a \"" + e.getNom().toLowerCase()+"\"");
|
||||
if((e.getNom()).equals(nomEtu.toString())){
|
||||
s.add(e);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Test;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.*;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Graphic;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Model;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.*;
|
||||
import java.util.*;
|
||||
import org.mariadb.jdbc.*;
|
||||
@ -26,7 +26,7 @@ public class TestTexteMNP{
|
||||
|
||||
////System.out.println("Test de l\'API");
|
||||
//System.out.print("Création des étudiants");
|
||||
Graphic ga=new Graphic();
|
||||
Model ga=new Model();
|
||||
|
||||
Etudiant e1=new EtudiantNP("césar","lycurgus");
|
||||
Etudiant e2=new EtudiantNP("denis","uranus");
|
||||
@ -238,11 +238,11 @@ public class TestTexteMNP{
|
||||
acf.deleteChangement(itch.next());
|
||||
for (Changement cgt : acf.getAllChangements()){
|
||||
////System.out.println(cgt.monPrint());
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
try{
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
try{
|
||||
@ -252,12 +252,13 @@ public class TestTexteMNP{
|
||||
try{
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"INSERT INTO `CONTIENT` (`idGroupe`, `idEt`) VALUES (?, ?);");
|
||||
Groupe g=agf.getPromotion();
|
||||
for(Etudiant et: g.getEtudiants()){
|
||||
pst.setInt(1, g.getId());
|
||||
for(Groupe k: racineDeLaPartition.getSousGroupes()){
|
||||
for(Etudiant et: k.getEtudiants()){
|
||||
pst.setInt(1, k.getId());
|
||||
pst.setInt(2, et.getId());
|
||||
pst.executeQuery();
|
||||
}
|
||||
}
|
||||
pst.close();
|
||||
}catch(SQLException ef){
|
||||
System.out.println("erreur dans la preparation");
|
||||
|
Loading…
Reference in New Issue
Block a user