repartition ROOT, ETU et utilisation de l'API respecter, correction de bug et ajout fonction visite de groupe d'un etudiant seulement ceux que il connait

This commit is contained in:
2022-11-26 18:09:08 +01:00
parent 203fca24cd
commit 47742b1ddc
35 changed files with 1670 additions and 686 deletions

View File

@@ -0,0 +1,95 @@
package fr.iutfbleau.projetIHM2022FI2.ROOT.View;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import java.awt.Font;
import java.awt.GridLayout;
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
import fr.iutfbleau.projetIHM2022FI2.API.TypeGroupe;
import fr.iutfbleau.projetIHM2022FI2.ROOT.Controller.ObservateurChangeGroupe;
import fr.iutfbleau.projetIHM2022FI2.ROOT.Controller.ObservateurModifGroupe;
import fr.iutfbleau.projetIHM2022FI2.ROOT.Model.Model;
public class FenetreGroupe{
private Groupe g;
private JPanel pan;
private Model m;
public FenetreGroupe(Groupe g, Model m){
super();
this.g=g;
this.m=m;
this.pan=new JPanel();
this.draw();
}
public Groupe getG() {
return this.g;
}
public void refresh(){
this.pan.removeAll();
this.draw();
this.pan.revalidate();
}
private void draw(){
if(g!=null){
int taille=5;
if(g.getType()==TypeGroupe.PARTITION || g.getType()==TypeGroupe.ROOT)
taille--;
if(g.getSousGroupes().size()>0)
this.pan.setLayout(new GridLayout(8, 1));
else{this.pan.setLayout(new GridLayout(7, 1));}
JPanel tache=new JPanel(new GridLayout(1,taille));
if(g.getType()!=TypeGroupe.ROOT){
JButton bout=new JButton(g.getPointPoint().getName());
bout.addActionListener(new ObservateurChangeGroupe(m, this.g.getPointPoint()));
tache.add(bout);
}
JButton renomer=new JButton("rename");
renomer.addActionListener(new ObservateurModifGroupe(m, g));
tache.add(renomer);
JButton ajouter=new JButton("add");
ajouter.addActionListener(new ObservateurModifGroupe(m, g));
tache.add(ajouter);
JButton supprimer=new JButton("supr");
supprimer.addActionListener(new ObservateurModifGroupe(m, g));
tache.add(supprimer);
if(g.getType()!=TypeGroupe.PARTITION){
JButton creer=new JButton("new Groupe");
creer.addActionListener(new ObservateurModifGroupe(m, g));
tache.add(creer);
}
this.pan.add(tache);
JLabel titre=new JLabel("Group : "+g.getName(), JLabel.CENTER);
titre.setFont(new Font(Font.SERIF, Font.BOLD, titre.getFont().getSize()+10));
this.pan.add(titre);
this.pan.add(new JLabel("id= "+String.valueOf(g.getId()),JLabel.CENTER));
this.pan.add(new JLabel("min= "+String.valueOf(g.getMin()),JLabel.CENTER));
this.pan.add(new JLabel("max= "+String.valueOf(g.getMax()),JLabel.CENTER));
this.pan.add(new JLabel(g.getType().name(), JLabel.CENTER));
this.pan.add(new JLabel("Sous groupe:",JLabel.CENTER));
if(g.getSousGroupes().size()>0){
JPanel sous=new JPanel(new GridLayout(g.getSousGroupes().size(), 1));
for(Groupe gr: g.getSousGroupes()){
JButton b=new JButton(gr.getName());
b.addActionListener(new ObservateurChangeGroupe(m, gr));
sous.add(b);
}
this.pan.add(new JScrollPane(sous));
}
}else{
JButton creer=new JButton("créer une promo");
creer.addActionListener(new ObservateurModifGroupe(m, g));
this.pan.add(creer);
}
}
public void setG(Groupe g) {
this.g = g;
}
public JPanel getPan() {
return pan;
}
}